Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Box.Context and Box.TestServiceProvider have incorrect constructor properties set to Object #172

Closed
aplatti opened this issue May 12, 2016 · 3 comments

Comments

@aplatti
Copy link

aplatti commented May 12, 2016

Hi T3!

I'm running into an issue in my project that is caused by subtle problem with the way that Box.Context and Box.TestServiceProvider are defined. The methods on those objects are set by completely replacing the prototype properties with a new object, which causes the constructor property to become Object, instead of the correct Box constructor functions.

The current code defines the methods on these object like this:

    function Context(application, element) {
        this.application = application;
        this.element = element;
    }

    Context.prototype = {
        broadcast: function(name, data) {...},
        getService: function(serviceName) {...},
        ...
    }   

Because the prototype is replaced by {}, the constructor becomes object.

The fix is simple:

    function Context(application, element) {
        this.application = application;
        this.element = element;
    }

    Context.prototype.broadcast: function(name, data) {...};
    Context.prototype.getService: function(serviceName) {...};
    ...

I'm happy to create a PR, but just wanted to run it by you guys first for feedback.

Thanks!
Adam

@j3tan
Copy link
Contributor

j3tan commented May 13, 2016

Hi Adam,

I think the changes you proposed are perfectly fine and a PR would be most helpful!

@nzakas
Copy link
Contributor

nzakas commented May 15, 2016

You can also restore the constructor, for a smaller change:

    function Context(application, element) {
        this.application = application;
        this.element = element;
    }

    Context.prototype = {
        constructor: Context,
        broadcast: function(name, data) {...},
        getService: function(serviceName) {...},
        ...
    }   

@aplatti
Copy link
Author

aplatti commented May 21, 2016

Hi guys, I made a pull request here:
#173

Thanks!

j3tan added a commit that referenced this issue May 21, 2016
Fixes constructor reference in instances of Box.Context and Box.TestServiceProvider (fixes #172)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants