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

Cleanup _parent, _dom and __hooks after unmount #3709

Merged
merged 10 commits into from Sep 11, 2022
2 changes: 1 addition & 1 deletion compat/src/suspense.js
Expand Up @@ -143,7 +143,7 @@ Suspense.prototype._childDidSuspend = function(promise, suspendingVNode) {
if (!--c._pendingSuspensionCount) {
// If the suspension was during hydration we don't need to restore the
// suspended children into the _children array
if (c.state._suspended) {
if (c.state._suspended && c._vnode._children) {
const suspendedVNode = c.state._suspended;
c._vnode._children[0] = removeOriginal(
suspendedVNode,
Expand Down
1 change: 1 addition & 0 deletions hooks/src/index.js
Expand Up @@ -125,6 +125,7 @@ options.unmount = vnode => {
hasErrored = e;
}
});
c.__hooks = undefined;
if (hasErrored) options._catchError(hasErrored, c._vnode);
}
};
Expand Down
1 change: 1 addition & 0 deletions mangle.json
Expand Up @@ -25,6 +25,7 @@
"props": {
"cname": 6,
"props": {
"$_listeners": "l",
"$_cleanup": "__c",
"$__hooks": "__H",
"$_list": "__",
Expand Down
7 changes: 5 additions & 2 deletions src/diff/index.js
Expand Up @@ -512,6 +512,7 @@ export function unmount(vnode, parentVNode, skipRemove) {
}

r.base = r._parentDom = null;
vnode._component = undefined;
}

if ((r = vnode._children)) {
Expand All @@ -522,11 +523,13 @@ export function unmount(vnode, parentVNode, skipRemove) {
}
}

if (!skipRemove && vnode._dom != null) removeNode(vnode._dom);
if (!skipRemove && vnode._dom != null) {
removeNode(vnode._dom);
}

// Must be set to `undefined` to properly clean up `_nextDom`
// for which `null` is a valid value. See comment in `create-element.js`
vnode._dom = vnode._nextDom = undefined;
vnode._children = vnode._parent = vnode._dom = vnode._nextDom = undefined;
}

/** The `.render()` method for a PFC backing instance. */
Expand Down