mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-10-04 18:00:44 +00:00
Fixed refresh handling for tiddler macro
This commit is contained in:
parent
a7b905cf88
commit
cb0c190882
@ -43,7 +43,8 @@ the `template` parameter or, if that parameter is missing, the tiddler named in
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var Renderer = require("../Renderer.js").Renderer,
|
var Renderer = require("../Renderer.js").Renderer,
|
||||||
Dependencies = require("../Dependencies.js").Dependencies;
|
Dependencies = require("../Dependencies.js").Dependencies,
|
||||||
|
utils = require("../Utils.js");
|
||||||
|
|
||||||
exports.macro = {
|
exports.macro = {
|
||||||
name: "tiddler",
|
name: "tiddler",
|
||||||
@ -122,6 +123,33 @@ exports.macro = {
|
|||||||
}
|
}
|
||||||
// Return the content
|
// Return the content
|
||||||
return [Renderer.ElementNode("div",attributes,contentClone)];
|
return [Renderer.ElementNode("div",attributes,contentClone)];
|
||||||
|
},
|
||||||
|
refreshInDom: function(changes) {
|
||||||
|
var t;
|
||||||
|
// Set the class for missing tiddlers
|
||||||
|
var renderTitle = this.params.target;
|
||||||
|
if(typeof renderTitle !== "string") {
|
||||||
|
renderTitle = this.params.template;
|
||||||
|
}
|
||||||
|
if(renderTitle) {
|
||||||
|
utils.toggleClass(this.content[0].domNode,"tw-tiddler-missing",!this.store.tiddlerExists(renderTitle));
|
||||||
|
}
|
||||||
|
// Rerender the tiddler if it is impacted by the changes
|
||||||
|
if(this.dependencies.hasChanged(changes,this.tiddlerTitle)) {
|
||||||
|
// Manually reexecute and rerender this macro
|
||||||
|
while(this.domNode.hasChildNodes()) {
|
||||||
|
this.domNode.removeChild(this.domNode.firstChild);
|
||||||
|
}
|
||||||
|
this.execute(this.parents,this.tiddlerTitle);
|
||||||
|
for(t=0; t<this.content.length; t++) {
|
||||||
|
this.content[t].renderInDom(this.domNode);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Refresh any children
|
||||||
|
for(t=0; t<this.content.length; t++) {
|
||||||
|
this.content[t].refreshInDom(changes);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user