Not sure if it is the intended behavior or not, but I wouldn't find it hard
to believe that the change observer fires since the index of each element
changes as you unshift into the list array...

essentially: list[0] becomes list[1] meaning previous[1] != list[1]
effectively causing a series of changes for each list item...

Again, cant attest to it being expected or not, but I would not be
surprised by your log output at all right this second.

-Karl Tiedt

On Sat, Mar 4, 2017 at 8:34 PM, Santanu Basu <[email protected]> wrote:

> I have posted this in another form on SO (http://stackoverflow.com/
> questions/42565640/how-to-distinguish-between-structural-changes-to-array-
> made-in-parent-element-vs) and in the 2.0-preview branch slack channel,
> but I know they are heads down with the upcoming release, so hopefully
> somewhere in the broader group here will have insight to share.
>
> The TL;DR question: how many times should the observer, defined in
> editor-element.html log to console for the following sample code:
> https://plnkr.co/edit/iTZqM4GwpASEqQgtRGEk?  I would have expected 4, but
> it actually happens 6 times.
>
> More details: the elements are a list element which, using dom-repeat,
> renders a list of todos, and each todo is rendered by an instance of an
> editor element.  The data is a list of todo objects, each of which has a
> primitive property called description.  First, two todo objects are pushed
> onto the list.  Then the first todo object's description property is
> edited.  Then a third todo object is unshifted (not pushed) onto the list.
> The data binding is defined two way between the items inside the dom-repeat
> of the list element and the todo property of the editor element.  In other
> words, the binding is made at the object, not the property.  The editor
> element defines an observer on "todo.description", printing a message to
> the console each time an observation is made.
>
> thanks in advance for any help
>
> 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 [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/polymer-dev/94aba116-6925-4ea6-880d-b2e6ca7b5e7d%40googlegroups.com
> <https://groups.google.com/d/msgid/polymer-dev/94aba116-6925-4ea6-880d-b2e6ca7b5e7d%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/CADNgbTHHUnuwBDReO%2BqHwUZwS_FqmZitfBVSZRMmeupAx-zhew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to