-
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
Binding input fields to and setting elements of a flat array behaves unexpectedly #3859
Comments
I've tracked the bug down a bit, and the source of the issue seems to be in how Polymer.Collection handles mapping arrays of non-objects: https://github.com/Polymer/polymer/blob/master/src/lib/collection.html#L37
Making these work-around changes in notify-path "set" function and dom-repeat "_applyFullRefresh" function fixes the issue, but it's not thorough: https://github.com/Polymer/polymer/blob/master/src/standard/notify-path.html#L198
and https://github.com/Polymer/polymer/blob/master/src/lib/template/dom-repeat.html#L494
These couple changes fix the issues demonstrated in the jsfiddle, but ultimately it seems like the Collection's implementation of pmap should be changed to fix the issue generally or not be used at all. |
It sounds like this issue is related: |
#3062 has been closed and it seems that this issue has been fixed as well in Polymer 2: http://jsbin.com/tacujibola/edit?html,console,output |
When trying to create a list of input fields to directly edit the elements of an array, the incorrect elements of the array get changed. Other times, both the correct element will get set, as well as a second one.
Here's an example starting with an empty array with 10 elements, using a dom-repeat element to bind input fields to the array element values:
https://jsfiddle.net/na4cjwru/10/
Case 1
we expect to set the 7th element of the array to 10
and the change path fired to the observer watching "arr.*" is "arr.add g-selection and g-selector components #9" instead of "arr.have some good defaults for g-overlay #7"
Case 2
we expect just the value of the 3rd index to change
And here is an example where we start off with a fully initialized array filled with values:
https://jsfiddle.net/na4cjwru/9/
Case 3
Can anyone shed a little light on this? Only of the only work arounds at the moment seems to be to make an array of objects that point to the data I actually care about and convert it to a flat array later. This seems like the kind of thing that should work, though.
The text was updated successfully, but these errors were encountered: