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

children not update #1587

Closed
tangjinzhou opened this issue Jul 15, 2020 · 6 comments · Fixed by #1589
Closed

children not update #1587

tangjinzhou opened this issue Jul 15, 2020 · 6 comments · Fixed by #1589

Comments

@tangjinzhou
Copy link
Contributor

Version

3.0.0-beta.21

Reproduction link

https://jsbin.com/kazolagosa/edit?html,output

Steps to reproduce

slot not update when use two v-if.
we can use v-else-if or key to slove it. but bring mental burden to users. hahah

What is expected?

slot update

What is actually happening?

slot not update

@tangjinzhou
Copy link
Contributor Author

tangjinzhou commented Jul 15, 2020

@yyx990803 @HcySunYang
This is not just a key issue, even if the same key, the child node should be updated.
Like:

<span v-if="value%2 === 0" key="1">world</span>
<span v-if="value%2 !== 0" key="1">hello</span>

@HcySunYang
Copy link
Member

HcySunYang commented Jul 15, 2020

To be honest, this is a wrong usage.
if the users specify the key manually, it is possible to break the block-tree assumption, should we prevent users from doing that? Or give a warning? 🤔

@tangjinzhou
Copy link
Contributor Author

tangjinzhou commented Jul 16, 2020

This is a very conventional way of use. If using v-if v-if is not common, but v-if v-else is a common way of using it.
Like:
https://jsbin.com/lotusikiru/edit?html,output

<span v-if="value%2 === 0" key="1">world</span>
<span v-else key="1">hello</span>

If let users understand patchFlag, this is a big mental burden(心智负担😓).

@underfin
Copy link
Member

Look like we need do some static analysis for same keys element and add corresponding patchFlag to it.

@yyx990803
Copy link
Member

yyx990803 commented Jul 16, 2020

In Vue 3 you should never do this. There's no convincing reason to force the same key on two branches. We should throw warnings if the user tries to do this.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants