Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[...ComponentTreeCache.keys()].forEach(key => {
if (NodeCache.has(key) && hasVTree(vTree, key)) {
release(NodeCache.get(key));
}
});
}
// Ensure this is a stateful component. Stateless components do not get
// lifecycle events yet.
if (instance && instance.componentWillUnmount) {
instance.componentWillUnmount();
}
// Clean up Shadow DOM (TODO what if the shadow dom is detached?).
if (Constructor && NodeCache.has(vTree)) {
release(NodeCache.get(vTree).shadowRoot);
}
// FIXME We release memory based on the DOM Node. This call is failing
// because when the component renders we are setting a new renderTree to
// associate
release(NodeCache.get(vTree));
ComponentTreeCache.delete(vTree);
InstanceCache.delete(componentTree);
}
// Ensure this is a stateful component. Stateless components do not get
// lifecycle events yet.
if (instance && instance.componentWillUnmount) {
instance.componentWillUnmount();
}
// Clean up Shadow DOM (TODO what if the shadow dom is detached?).
if (Constructor && NodeCache.has(vTree)) {
release(NodeCache.get(vTree).shadowRoot);
}
// FIXME We release memory based on the DOM Node. This call is failing
// because when the component renders we are setting a new renderTree to
// associate
release(NodeCache.get(vTree));
ComponentTreeCache.delete(vTree);
InstanceCache.delete(componentTree);
}
export function release(el) {
diffRelease(el);
document.body.removeChild(el);
elements.delete(el);
}