mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Revert "Add widget.destroy() function (#7468)"
See discussion at https://github.com/Jermolene/TiddlyWiki5/pull/7468#issuecomment-1645753857
This commit is contained in:
parent
fd8b8f62da
commit
160cc0e9a9
@ -719,46 +719,23 @@ Widget.prototype.findFirstDomNode = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Entry into destroy procedure
|
Remove any DOM nodes created by this widget or its children
|
||||||
*/
|
|
||||||
Widget.prototype.destroyChildren = function() {
|
|
||||||
$tw.utils.each(this.children,function(childWidget) {
|
|
||||||
childWidget.destroy();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
/*
|
|
||||||
Legacy entry into destroy procedure
|
|
||||||
*/
|
*/
|
||||||
Widget.prototype.removeChildDomNodes = function() {
|
Widget.prototype.removeChildDomNodes = function() {
|
||||||
this.destroy();
|
// If this widget has directly created DOM nodes, delete them and exit. This assumes that any child widgets are contained within the created DOM nodes, which would normally be the case
|
||||||
};
|
|
||||||
/*
|
|
||||||
Default destroy
|
|
||||||
*/
|
|
||||||
Widget.prototype.destroy = function() {
|
|
||||||
// call children to remove their resources
|
|
||||||
this.destroyChildren();
|
|
||||||
// remove our resources
|
|
||||||
this.children = [];
|
|
||||||
this.removeLocalDomNodes();
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
Remove any DOM nodes created by this widget
|
|
||||||
*/
|
|
||||||
Widget.prototype.removeLocalDomNodes = function() {
|
|
||||||
// If this widget has directly created DOM nodes, delete them and exit.
|
|
||||||
if(this.domNodes.length > 0) {
|
if(this.domNodes.length > 0) {
|
||||||
$tw.utils.each(this.domNodes,function(domNode) {
|
$tw.utils.each(this.domNodes,function(domNode) {
|
||||||
if(domNode.parentNode) {
|
domNode.parentNode.removeChild(domNode);
|
||||||
domNode.parentNode.removeChild(domNode);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
this.domNodes = [];
|
this.domNodes = [];
|
||||||
|
} else {
|
||||||
|
// Otherwise, ask the child widgets to delete their DOM nodes
|
||||||
|
$tw.utils.each(this.children,function(childWidget) {
|
||||||
|
childWidget.removeChildDomNodes();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Invoke the action widgets that are descendents of the current widget.
|
Invoke the action widgets that are descendents of the current widget.
|
||||||
*/
|
*/
|
||||||
|
@ -9,6 +9,9 @@ type: text/vnd.tiddlywiki
|
|||||||
|
|
||||||
! Overview of v5.3.1
|
! Overview of v5.3.1
|
||||||
|
|
||||||
|
! Reversions of v5.3.0 Changes
|
||||||
|
|
||||||
|
* Reverted adding the `widget.destroy()` method because of performance concerns (see https://github.com/Jermolene/TiddlyWiki5/pull/7468)
|
||||||
|
|
||||||
! Plugin Improvements
|
! Plugin Improvements
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user