mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] component, fiber: subchildren should also patch and destroy their children
Have a GrandParent which controls whether one of its GrandChildren is displayed or not. First, the GrandChild is displayed. Then, change the state of the GrandParent in order to kill the GrandChild. Before this commit the GrandChild is only removed from the DOM, as bdom correctly works. But it is not destroyed. After this commit, the GrandChild is correctly destroyed.
This commit is contained in:
committed by
Aaron Bohy
parent
a6bdca082a
commit
4a03a60084
@@ -275,8 +275,11 @@ export class ComponentNode<T extends typeof Component = typeof Component>
|
||||
}
|
||||
|
||||
patch() {
|
||||
this.bdom!.patch(this!.fiber!.bdom!, false);
|
||||
this.cleanOutdatedChildren();
|
||||
const hasChildren = Object.keys(this.children).length > 0;
|
||||
this.bdom!.patch(this!.fiber!.bdom!, hasChildren);
|
||||
if (hasChildren) {
|
||||
this.cleanOutdatedChildren();
|
||||
}
|
||||
this.fiber!.appliedToDom = true;
|
||||
this.fiber = null;
|
||||
}
|
||||
@@ -290,12 +293,9 @@ export class ComponentNode<T extends typeof Component = typeof Component>
|
||||
}
|
||||
|
||||
cleanOutdatedChildren() {
|
||||
const childrenEntries = Object.entries(this.children);
|
||||
if (!childrenEntries.length) {
|
||||
return;
|
||||
}
|
||||
const children = this.children;
|
||||
for (const [key, node] of childrenEntries) {
|
||||
for (const key in children) {
|
||||
const node = children[key];
|
||||
const status = node.status;
|
||||
if (status !== STATUS.MOUNTED) {
|
||||
delete children[key];
|
||||
|
||||
Reference in New Issue
Block a user