Skip to content

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

@aplatti

Description

@aplatti

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions