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

Component is destroyed and then mounted #8293

Closed
gamperl opened this issue Jun 4, 2018 · 3 comments
Closed

Component is destroyed and then mounted #8293

gamperl opened this issue Jun 4, 2018 · 3 comments
Assignees

Comments

@gamperl
Copy link

gamperl commented Jun 4, 2018

Version

2.5.16

Reproduction link

https://codepen.io/gamperl/pen/JZGMWK

Steps to reproduce

Run the provided JSFiddle

What is expected?

The component in the slot should be moved from the table to the div element. Or a new one is created and the old one is destoryed.

What is actually happening?

If a slot is moved from a table to a div using a v-if directive, the slot ist recreated. But before the new component is mounted, vuejs picks the wrong component to destroy: it destoyes the new component instead of the old one.

@haoqunjiang haoqunjiang added the bug label Jun 4, 2018
@haoqunjiang haoqunjiang self-assigned this Jun 20, 2018
@haoqunjiang
Copy link
Member

This bug seems to be caused by slot caching mechanism in the VDOM algorithm.
The new VNode tree and the old one, despite having different roots, share a same reference to the named slot, thus leading to the confusion in the patching process.

@haoqunjiang
Copy link
Member

A workaround is to attach the slot attribute to a template element instead of div.

<cmp-panel>
  <template slot="menu">
    <cmp-body></cmp-body>
  </template>
</cmp-panel>

@haoqunjiang
Copy link
Member

Marking this as duplicate of #7975 as both reflect the same underlying issue

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

No branches or pull requests

2 participants