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

Elements unnecessarily re-created when an above v-for changes. #5618

Closed
gazugafan opened this issue May 5, 2017 · 5 comments
Closed

Elements unnecessarily re-created when an above v-for changes. #5618

gazugafan opened this issue May 5, 2017 · 5 comments
Labels

Comments

@gazugafan
Copy link

Version

2.3.2

Reproduction link

https://jsfiddle.net/gazugafan/a8kverza/2/

Steps to reproduce

Change the inputs marked "Change Me", then add a row. Any inputs following the v-for rows get re-created (and lose their value), while inputs above remain as they are. This only seems to happen when the inputs and v-for element are contained in a parent component's slot.

What is expected?

All inputs remain unchanged--regardless of what happens to the sibling v-for element.

What is actually happening?

Any input elements following the v-for are re-created--resetting their value.

@simplesmiler
Copy link
Member

simplesmiler commented May 6, 2017

I'm not entirely sure, but this looks like a bug to me, because this only happens with the slot content.
In the mean time, key-ing the element in question helps: https://jsfiddle.net/a8kverza/3/

@nerdcave
Copy link

nerdcave commented May 6, 2017

I just ran into something similar. Although in my example, a v-if on a nested slot causes a sibling component to be recreated: https://jsfiddle.net/y0vgrwjy/1/

Probably related?

pengchongfu added a commit to pengchongfu/vue that referenced this issue May 7, 2017
@pengchongfu
Copy link
Contributor

@nerdcave , I think it is related. the reason is what I describe in PR.

you will find it works well if you change slot content position like this

@nerdcave
Copy link

nerdcave commented May 7, 2017

@pengchongfu, Also works if you add a key to <my-data>. Thanks for looking into it.

@pengchongfu
Copy link
Contributor

@nerdcave ,you can also add a wrapper like this, the wrapper would be a placeholder so that the default key of input will not changed.

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

No branches or pull requests

4 participants