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

Extension errors when re-defining a property. #117

Closed
justinbmeyer opened this issue Dec 16, 2016 · 1 comment
Closed

Extension errors when re-defining a property. #117

justinbmeyer opened this issue Dec 16, 2016 · 1 comment
Assignees
Labels

Comments

@justinbmeyer
Copy link
Contributor

http://jsbin.com/meyuhateqe/edit?html,js,output

cc @bmomberger-bitovi

@justinbmeyer
Copy link
Contributor Author

justinbmeyer commented Dec 16, 2016

Taking this example:

var A = DefineMap.extend("A", {
    foo: {
        type: "string",
        value: "blah"
    }
});


A.extend("B", {
    foo: {
        type: "string",
        value: "flub"
    }
});

The problem here is that when B is being created, an instance of A is created (we'll call this aA. aA is the prototype of B. We set the new foo on aA in _overwrite like:

aA.foo = { type: "string",  value: "flub" }

This causes the foo setter to run, which accesses aA._data, which sets up the non-configurable aA._data.

I'm not sure what the right solution is.

One solution might be to decorate aA as it's being extended (similar to what we do with __inSetup here ).

The better solution is to change _overwrite to use Object.defineProperty() to avoid the setter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant