1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-02 14:29:55 +00:00

adds depth first destroy

This commit is contained in:
buggyj 2023-01-24 22:43:43 +01:00
parent 3faadd69c0
commit b3bbf9f0a9

View File

@ -596,6 +596,24 @@ Widget.prototype.findFirstDomNode = function() {
return null;
};
/*
Depth first destroy
*/
Widget.prototype.desendDestroy = function() {
this.waitDestroy = true; //for blocking repeat calls to this method from removeChildDomNodes
$tw.utils.each(this.children,function(childWidget) {
childWidget.desendDestroy();
});
if (this.destroy) {
this.destroy();
}
this.waitDestroy = false;
};
Widget.prototype.waitDestroy = false;
/*
Remove any DOM nodes created by this widget or its children
*/
@ -612,6 +630,7 @@ Widget.prototype.removeChildDomNodes = function() {
childWidget.removeChildDomNodes();
});
}
if (!this.waitDestroy) this.desendDestroy();
};
/*