Skip to content
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

set() has no effect after splice() #4196

Closed
2 tasks done
trading-peter opened this issue Dec 4, 2016 · 4 comments
Closed
2 tasks done

set() has no effect after splice() #4196

trading-peter opened this issue Dec 4, 2016 · 4 comments

Comments

@trading-peter
Copy link
Contributor

It seems polymer looses sync when using splice on arrays.

Live Demo

http://jsbin.com/qobivafuvo/edit?html,output

Steps to Reproduce in the jsbin

  1. List of countries shows up; click "Edit third item"-Button
  2. The third item in the list changes to '---------'
  3. Click the "Splice..."-Button; The third item is removed
  4. Click the "Edit third item"-Button again; Nothing happens
    -->

Expected Results

At the second time clicking "Edit third item", the "new" third item should now read "----------".

Actual Results

Nothing happens.

Browsers Affected

  • Chrome
  • Firefox

Versions

Master

@tony19
Copy link

tony19 commented Dec 4, 2016

I don't have an explanation, but the problem seems related to the key in your data path. It works correctly if you change:

demo.set('input.#2.name', '------------');

to:

demo.set('input.2.name', '------------');

@trading-peter
Copy link
Contributor Author

Awesome @tony19,
such an easy workaround! Why didn't I think of this myself...
And this should greatly narrow the problem down for the folks that know the internals of the data binding system.

@arthurevans
Copy link

Keys are stable: so #2 isn't the third item, it's a stable key to a particular item. If you remove that item and then try to edit it, it's not going to do anything.

Accessing the items by index does what you want here. (In general, as the success say, you don't need to mess with keys unless you're doing something fancy like making your own dom-repeat or iron-list equivalent.)

So I think this is WAI here.

@trading-peter
Copy link
Contributor Author

Got you, @arthurevans! Now the whole # thing in the path of observer change records finally makes sense to me. I always wondered why it's not just the number.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants