-
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
Databinding breaks after removing and reattaching an element to the DOM #311
Comments
Bindings are removed asynchronously when the element is removed from the document. To avoid that, call cancelUnbindAll() immediately after the element is removed. |
As Frankie noted, the intention is that you call cancelUnbindAll after removing sub1 or sub2. However, you'll currently need to also call CustomElements.takeRecords to ensure that the sub's leftViewCallback is processed first. Here's a working version: I've made another issue, linked above, to avoid the need to write polyfill aware code. |
I'd like to point out that using conditional templates makes this type of construction very simple. Here's an example: Also see #312. The new |
Based on fix in webcomponents/webcomponentsjs#340.
Hi,
in the most recent version from git (date 2013-09-10), databinding seems to break if one removes an element from the DOM and reattaches it afterwards.
Tested in current versions of all evergreen browsers (especially chrome 30.0.1599.69 m).
Following fiddle demonstrates the problem: http://jsfiddle.net/Ysasn/1/
It contains a button that switches between two instances of an element that contains some basic databinding (the elements simply mirror the input of a textbox to a span; each button click removes the previously displayed instance from the DOM and (re)attaches the other instance of this databinding-test-element).
The databinding works fine for the first two clicks, when the my-binding-test elements get attached to the DOM the first time. BUT, after having clicked a third time (when the first my-binding-test instance gets reattached to the DOM) the data-binding is broken and doesn't propagate any changes anymore. Of course, this demo works fine, when reinstantiating the my-binding-test elements on each button click.
Don't hestitate to ask if you need any further information.
Regards,
André
The text was updated successfully, but these errors were encountered: