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

Swapping from functional to non-functional component using v-if does not change v-data-* attribute. #11171

Open
StefanCardnell opened this issue Mar 2, 2020 · 4 comments · May be fixed by #11247
Labels

Comments

@StefanCardnell
Copy link

Version

2.6.11

Reproduction link

https://codesandbox.io/embed/heuristic-brown-u7rvw?fontsize=14&hidenavigation=1&theme=dark

Steps to reproduce

Click the tick box.

What is expected?

It should say "BLUE BOX" with a blue background colour.

What is actually happening?

It says "BLUE BOX" with no background colour.


The issue stems from the data-v-* attribute not being re-set for the blue_block div when it is swapped to. It is still using the data-v-* attribute of the child div in the functional component. Thus the CSS class styling does not apply.

https://imgur.com/a/gukDePJ

Swapping from a functional component to something else is useful. E.g. When showing a simple loading bar component before swapping to a more complex component.

@sirlancelot
Copy link

I think this may have something to do with how Vue recycles nodes during update. As a workaround, adding a key to both the component and the div yields the expected behavior.

@posva
Copy link
Member

posva commented Mar 3, 2020

Might be related to #10416

@posva posva added the bug label Mar 3, 2020
mydaoyuan pushed a commit to mydaoyuan/vue that referenced this issue Mar 26, 2020
fix functional component update scope attribute when patch use same node

fix vuejs#11171
@mydaoyuan mydaoyuan linked a pull request Mar 26, 2020 that will close this issue
13 tasks
@yysy-fe

This comment has been minimized.

@PeterAlfredLee
Copy link

I don't think this is a problem.

According to the comment here :

functional component with scopeId will not inherit parent scopeId

The functional components should not inherit parent if the parent is scoped.

I think we have a workarounds here: we can remove the scoped attribute in the parent component. Seems it works :
https://codesandbox.io/embed/vigorous-frost-t1f84

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

Successfully merging a pull request may close this issue.

5 participants