[FIX] component: correctly create a new node when previous is destroyed

Previously, when a component node had been created and destroyed, and
the corresponding component was then recreated, the destroyed node was
reused. This commit fixes that
This commit is contained in:
Samuel Degueldre
2021-10-22 09:53:36 +02:00
committed by Aaron Bohy
parent ced5d0f69f
commit 15e4c856da
3 changed files with 87 additions and 3 deletions
+7 -3
View File
@@ -21,9 +21,13 @@ export function component(
let node: any = ctx.children[key];
let isDynamic = typeof name !== "string";
if (node && node.status < STATUS.MOUNTED) {
node.destroy();
node = undefined;
if (node) {
if (node.status < STATUS.MOUNTED) {
node.destroy();
node = undefined;
} else if (node.status === STATUS.DESTROYED) {
node = undefined;
}
}
if (isDynamic && node && node.component.constructor !== name) {
node = undefined;