Skip to content

nested track-by breaks when replacing the whole object #782

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

Closed
nkovacs opened this issue Apr 15, 2015 · 3 comments · Fixed by #783
Closed

nested track-by breaks when replacing the whole object #782

nkovacs opened this issue Apr 15, 2015 · 3 comments · Fixed by #783

Comments

@nkovacs
Copy link

nkovacs commented Apr 15, 2015

I don't know if I'm doing something wrong, but this breaks if you click the button a couple times:
http://jsfiddle.net/nkovacs/c08kdyka/

The most common error is "Uncaught TypeError: Cannot read property '__vue__' of null"., but there are others too.

If I remove the v-repeat of subitems, or remove the outer track-by directive, it works.

@nkovacs
Copy link
Author

nkovacs commented Apr 15, 2015

More reproducible errors without the random:
The first item has 0 subitems, then gets 2 the second time you click the button: http://jsfiddle.net/nkovacs/c08kdyka/2/
The first item has 1 subitem, then gets 2 the second time you click the button:
http://jsfiddle.net/nkovacs/c08kdyka/3/

@nkovacs
Copy link
Author

nkovacs commented Apr 15, 2015

Ok, I figured it out: here vm._reused is true, but it should be false. The reason: it inherits _reused from the parent vm, which has it because it's also using track-by.

nkovacs added a commit to nkovacs/vue that referenced this issue Apr 15, 2015
When the parent vm is reused, newly created children will inherit
the _reused property, and they won't be inserted into the dom.

Fixes vuejs#782
nkovacs added a commit to nkovacs/vue that referenced this issue Apr 15, 2015
When the parent vm is reused, newly created children will inherit
the _reused property, and they won't be inserted into the dom.

Fixes vuejs#782
@yyx990803
Copy link
Member

Thanks for digging in and fixing this!

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

Successfully merging a pull request may close this issue.

2 participants