Array splicing and dom-repeat lead to wrong path in deep property observers

61 views
Skip to first unread message

Simona Butnaru

unread,
Jan 21, 2016, 8:42:53 AM1/21/16
to Polymer

When adding an element in array, using splice method, and then change a subproperty from the added item, the path from array observation is not the correct one. 
Let's say we have a persons array with 11 objects, each object having name and age as properties. When adding a person {name: Sim, age: 24} on position 2, and after change the property name of person Sim, the observer method returns the path "data.#11.name".
I expected the path to be "data.#2.name" because I added the item on the second position.


Here is a jsfiddle that reproduces the error. https://jsfiddle.net/simona_butnaru/zfwewthr/5/


I made a little research and I've seen that the issue is from polymer, at the add function from Polymer.Collection. This line (var key = this.store.push(item) - 1;) sets the key to be the length of array, and I think the key shoud be the position where the item was added in array.
array-issue.png

Rob Dodson

unread,
Jan 21, 2016, 1:37:07 PM1/21/16
to Simona Butnaru, Polymer

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/b2f90593-46d6-4572-816e-af2df076f627%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kayce Basques

unread,
Jan 22, 2016, 5:12:19 PM1/22/16
to Polymer
I think I documented this recently, but the update is not live yet...

I think what you're seeing is intended behavior, see:

Reply all
Reply to author
Forward
0 new messages