1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-24 17:10:29 +00:00

Fixed automatic refreshing for macro nodes

This commit is contained in:
Jeremy Ruston 2012-06-19 16:47:10 +01:00
parent b17a43707d
commit 8b17874db4

View File

@ -204,8 +204,20 @@ Macro.prototype.refresh = function(changes) {
Macros that need special refreshing should override this function Macros that need special refreshing should override this function
*/ */
Macro.prototype.refreshInDom = function(changes) { Macro.prototype.refreshInDom = function(changes) {
if(this.child) { // Check if any of the dependencies of this macro node have changed
this.child.refreshInDom(changes); if(this.dependencies.hasChanged(changes,this.tiddlerTitle)) {
// Re-execute the macro if so
// Macros can only auto-refresh if their immediate child is a DOM node
var parentDomNode = this.child.domNode.parentNode,
insertBefore = this.child.domNode.nextSibling;
parentDomNode.removeChild(this.child.domNode);
this.execute(this.parents,this.tiddlerTitle);
this.renderInDom(parentDomNode,insertBefore);
} else {
// Refresh any child
if(this.child) {
this.child.refreshInDom(changes);
}
} }
}; };