ue3
Version:
ue3 build your own vue for learning.
16 lines (14 loc) • 390 B
text/typescript
import { Fragment } from "../types";
import { VNode } from "../types/vnode";
export function unmount(vnode: VNode | null) {
if (!vnode) {
return;
}
vnode.type === Fragment &&
(vnode.children as VNode[]).forEach(child => {
unmount(child);
});
const el = vnode.el;
const parent = el.parentNode;
parent && parent.removeChild(el);
}