Skip to content

Commit

Permalink
Cleanup _parent, _dom and __hooks after unmount (#3709)
Browse files Browse the repository at this point in the history
* cleanup _parent, __hooks and _dom when unmounting

* set listeners

* try out perf impact

* Update index.js

* fix test

* add _component removal

* Update index.js

* Update suspense.js
  • Loading branch information
JoviDeCroock committed Sep 11, 2022
1 parent a5258a9 commit 7469051
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
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._parent = vnode._dom = vnode._nextDom = undefined;
}

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

0 comments on commit 7469051

Please sign in to comment.