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

fix(teleport): targetAnchor should also be removed when unmounted #2870

Merged
merged 2 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ describe('renderer: teleport', () => {

render(null, root)
expect(serializeInner(target)).toBe('')
expect(target.children.length).toBe(0)
})

test('multiple teleport with same target', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime-core/src/components/Teleport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,9 @@ export const TeleportImpl = {
vnode: VNode,
{ r: remove, o: { remove: hostRemove } }: RendererInternals
) {
const { shapeFlag, children, anchor } = vnode
const { shapeFlag, children, anchor, targetAnchor } = vnode
hostRemove(anchor!)
hostRemove(targetAnchor!)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here should check the target existence, because it only insert when has vaild target.

if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
for (let i = 0; i < (children as VNode[]).length; i++) {
remove((children as VNode[])[i])
Expand Down