-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Custom elements seem to cache data after being deleted and re-added #159
Comments
The problem here is that the foo property has been set to a static object Instead, when a property needs to be a non-shared object value, the proper
|
For the language lawyers, static is a tricky term, more simply the For posterity: The tricky part is that, normally, setting a property in an instance creates that property on the instance. If I put The answer is that when you set a property like Fwiw, I believe that this particular footgun is why ES6 disallows (non-function) properties in Class definitions. |
Thanks, that helps a lot! I've refactored my code to avoid this problem. Note that there are some examples with similar code in the docs:
So it kind of looks like this is the "right way" to initialize a property. |
I think there's a subtle point here that the element registration is On Thu, May 23, 2013 at 12:40 PM, anniesullie notifications@github.comwrote:
|
The key concept here is that the thing you are registering is a
Most of these issues flow from the nature of |
You are right, that's extremely bad. :) |
Thanks for all the explanations! For me, changing the "person" example in the documentation and including the note about registration (once vs every instance) would be good improvements to the docs. I agree a really in-depth explanation of what's happening here is definitely out of scope for the current Polymer docs. |
Fixed up the docs and made a note for object initialization: |
The context for this is crbug.com/242701
I made a jsfiddle to reduce the problem a bit:
http://jsfiddle.net/jqUs7/
The fiddle has a my-element custom element, with this.foo = {}. Click on the element and it sets this.foo.bar = 'hello!'. Then click the button, the element is deleted, a new one is created using document.createElement, and appended to the div. The new element renders {{foo.bar}} as 'hello!' when it should be undefined.
The text was updated successfully, but these errors were encountered: