-
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
dom-repeat doesn't stamp correctly #3946
Comments
@kevinpschaaf FYI |
If only the items sub properties are changing, then the best way to trigger an update of the values that are changing is to use one of the notification apis, particularly on a sub-property of an item object: . Example: for(var i=0; i<i.items.length; i++){ this.set([“t.items”, i, “name”], this.t.items[i].name); }, while a bit tedious it works. If you are interacting with the dom to change the item[properties], or the items proper, var model= modelForElement(e.target);var item= itemForElement(e.target)l; model.set(item, [newValue]); if you know the id of the template repeater, and are in the local dom of the repeater, you can use the A js mutation observer could also do the trick. I am about to try using the templatizer and an native mutation observer to see if I can’t both compose complex elements on the fly, maintain the updates of deeper mutations, and just do something cool. Will let send a demo if anything works out. Hope that helped. Sincerely, Jason PS… the document get element will likely be a bust in shadow dom, and there were a few other little things from my quick look at your code, I didn’t go further only because i couldn’t run the demo. I pulled the error log pasted below: "ReferenceError: customElements is not defined
|
Fwiw, in the repro, the additional elements are being created, but they each have (what appears to be) only a single-space as content. Also, fwiw, I tried experiments which set |
@ Scott J. Miles… That’s interesting, now I really wanna see it. Will find the link and look. Thanks. Scott. You know why they are popping a single space?
|
This is due to bad interaction between removal of 2.0's Object/Array dirty checking and the Collection abstraction's use of array identity for key tracking, which still needs to be resolved in the 2.0 codebase. For time being please revert to using the legacy array path API's for mutating array data, which should still work. |
Fwiw, it's also possible to treat the array as an immutable data structure and create a fresh instance for each modification, ala: var items = t.items.slice();
items.push({
name: 'item ' + t.items.length
});
t.items = items; |
Closed via #3970. |
Description
dom-repeat
should update the values when settingt.items = t.items
and update the dom with the new values. This currently happens only on the first setting of the array.Live Demo
http://jsbin.com/rumiko/2/edit?html,console,output
Steps to Reproduce
add
buttonExpected Results
Dom should have 2 paragraphs with
item 0
,item 1
...as many times as add was clickedThe text was updated successfully, but these errors were encountered: