mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-17 11:30:02 +00:00
Refactor out the reexecuteInDom() method of macros
This commit is contained in:
parent
246fd81d39
commit
80cbe2a98f
@ -207,7 +207,20 @@ Macro.prototype.refreshInDom = function(changes) {
|
|||||||
// Check if any of the dependencies of this macro node have changed
|
// Check if any of the dependencies of this macro node have changed
|
||||||
if(this.dependencies.hasChanged(changes,this.tiddlerTitle)) {
|
if(this.dependencies.hasChanged(changes,this.tiddlerTitle)) {
|
||||||
// Re-execute the macro if so
|
// Re-execute the macro if so
|
||||||
// Macros can only auto-refresh if on of their descendent child has a DOM node
|
this.reexecuteInDom();
|
||||||
|
} else {
|
||||||
|
// Refresh any child
|
||||||
|
if(this.child) {
|
||||||
|
this.child.refreshInDom(changes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Re-execute a macro in the DOM
|
||||||
|
*/
|
||||||
|
Macro.prototype.reexecuteInDom = function() {
|
||||||
|
// Macros can only auto-refresh if one of their descendent child has a DOM node
|
||||||
var child = this.child;
|
var child = this.child;
|
||||||
while(!child.domNode && child.child) {
|
while(!child.domNode && child.child) {
|
||||||
child = child.child;
|
child = child.child;
|
||||||
@ -217,12 +230,6 @@ Macro.prototype.refreshInDom = function(changes) {
|
|||||||
parentDomNode.removeChild(child.domNode);
|
parentDomNode.removeChild(child.domNode);
|
||||||
this.execute(this.parents,this.tiddlerTitle);
|
this.execute(this.parents,this.tiddlerTitle);
|
||||||
this.renderInDom(parentDomNode,insertBefore);
|
this.renderInDom(parentDomNode,insertBefore);
|
||||||
} else {
|
|
||||||
// Refresh any child
|
|
||||||
if(this.child) {
|
|
||||||
this.child.refreshInDom(changes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Macro.prototype.addClass = function(className) {
|
Macro.prototype.addClass = function(className) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user