-
Notifications
You must be signed in to change notification settings - Fork 30
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
Problem with bindings of child classes being set on the parent class resulting in polluted bindings #95
base: master
Are you sure you want to change the base?
Conversation
hold on, I encountered an issue, going to try debug it. |
false alarm, error in our code we had binding name started with dataXXX and it got lost when it become data-xxx. Previously without ts-decorator, angular was more forgiving. |
Martijn, great mind think a like :) I am glad we have the same solution, hopefully it will get merged. |
Sorry, was a bit overloaded at work lately. Seems that @MartijnWelker solution is a bit more elegant, although it seems to be a bug there |
@vsternbach I actually changed the fix I had in my pull request over at rentmanpublic@d58e488, if you want I can open a pull request with those changes. |
Just want to make sure the change can be used in IE11, not sure spread operator is valid for IE11, which we need to support. |
@coolblades I assumed the typescript compilation process would take care of that, but it's a good idea to test that 👍 |
there's no any problem in using es6+ features since it's compiled to es5 anyway |
Afaik from angular extending classes are not getting any of the inputs and outputs from the parent class, so I think I'll be changing that here as well, so each call to getMetadata will be replaced with getOwnMetadata, so this will be kind of braking change here, but then this code will be easier to port to angular |
We have been using this for 3 months now, and like it so far - it is our intermediate step to go from ng1.5 to ng7.
We have create a base class with @input and many child classes off that and each child class has its own @input.
We started to see the instance of the child class contained many extra properties that are not part it.
I traced the code to what I have updated in my pull request:
The Reflection returns object back and it gets the meta of the child class's parent first, and it will find the parent class' binding object and returning that. And in ts-decorator it add a binding to the object returned (parent's object) and store back to itself. Since object is by reference, this mean the child and parent is sharing the same object. So my change is to clone the object returned (shallow) and add new binding to that and store the new object back.
I tested locally with our code and that solve the issues we were seeing.
I went ahead and update any of the decorators that is placed inside of a class. Please review it and see if it is ok.
Btw, I tried to build it with npm run install, but no luck. Not sure how you build it :)
Jonathan