-
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 call _render
when an item changes
#3626
Comments
Yeah, it seems inconsistent that updating a single array item with |
Arthur, this is a problem when binding the array to a firebase-collection. Even if you use this.splice locally firebase-collection will call this.set('data', array[index]) |
Maybe it is enough to just check in the However, it is possible you have set an item which is identical to the old one (just not by ref), so that would be a little inefficient in such cases. |
As far as I always understood you need to set |
Kaste, the scope of observe is items.*.someProp. So it wouldn't work in this case even though an item in the array changed |
Did you try? I'm talking about something like this http://jsbin.com/kesofavofu/edit?html,output |
what is observe=# doing? or rather, why is it doing that? |
@kaste that really is a nice hack you have there, but as always, a hack is a hack, not a solution. @ryanwtyler the reason this works is the following code: if(path.indexOf(paths[i]) === 0) {
// ...
this.debounce('render', this._render, this.delay);
// ...
} Of course Theoretically, this means if your items all have the properties |
If nobody calls here, I'll do a fix. |
The fix to the initial problem here, you think it would be sufficient to just check if the path is of form Also, the condition I mentioned above can incorrectly match as per your hack. But I see why it works this way, because if the change path is |
You're correct about the |
It's actually, if you listen to |
Ah true, if the path is As for It appears |
Right, As for Otherwise, throughout Polymer the following rules apply: Say you listen for |
Fixes Polymer#3626 by triggering a render when a single item changes in a sorted/filtered dom-repeat.
* For efficiency do not process `items.length` changes * Ensure observing `foo` is not triggered by a `foobar` etc. * Ensure assignments like `items.Polymer#2` etc. will trigger a resort/-filter Fixes Polymer#3626.
@43081j Ahhrg, why didn't you say, you had some code. My approach: #3630. There is something not right here and/or confusing, @arthurevans, cc @kevinpschaaf. Actually |
@kaste you can ignore it if you like, I had written it before discussing with you so it is likely not the best way of doing it :) I will comment on yours instead. Also FYI, the
& i guess you are saying that |
* For efficiency do not process `items.length` changes * Ensure observing `foo` is not triggered by a `foobar` etc. * Ensure assignments like `items.Polymer#2` etc. will trigger a resort/-filter Fixes Polymer#3626.
I'm inclined to agree with @kaste here. polymer/src/standard/notify-path.html Line 179 in 1b02e96
Tagging @kevinpschaaf to review and comment. I don't know if this is short-term fixable or if we need to tell people to use |
Firebase-collection is calling set('item.' + index, val). It's using the index. Not the key. Don't know if that matters |
That matters, I confused both too. In the jsbin above I used |
I think there's a simple fix in |
Sure, #3630 |
Is this going to be fixed or should the use of |
The change must probably be made in |
Ensure re-sort/filter always happens after array item set. Fixes #3626
Description
If you have a sorted dom-repeat and a change occurs to an item (such that the path is like
items.#2
), then_render
will not be called internally (because of this).This seems to be because it assumes any path which isn't
items
oritems.splices
must be a sub-property change, and thus should follow through to the logic for theobserve
property.However, not all other paths are sub-property changes, clearly. Some can be of the form
items.#2
.Should this not trigger a re-render? Or somehow check if the properties defined in
observe
have changed?Live Demo
http://plnkr.co/edit/fACxm4GDp1RsLKerazjW?p=preview
Clicking the button will set one of the children to a new object, causing a
items.#2
change notification.As you can see, a workaround is in this demo, the observer manually calls
render()
if you uncomment it.The text was updated successfully, but these errors were encountered: