fix(portal): portal should always remove its children when unmounted

This commit is contained in:
Evan You
2020-03-25 17:27:55 -04:00
parent cb31eb4d0a
commit 16cd8eee78
5 changed files with 48 additions and 3 deletions

View File

@@ -113,6 +113,20 @@ export const PortalImpl = {
}
}
}
},
remove(
vnode: VNode,
{ r: remove, o: { setElementText } }: RendererInternals
) {
const { target, shapeFlag, children } = vnode
if (shapeFlag & ShapeFlags.TEXT_CHILDREN) {
setElementText(target!, '')
} else if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
for (let i = 0; i < (children as VNode[]).length; i++) {
remove((children as VNode[])[i])
}
}
}
}