1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-10-20 02:07:38 +00:00

Revert "Revert "Transclude widget: refresh selectively when needed (#5736)""

This reverts commit 4f9dd50382.
This commit is contained in:
jeremy@jermolene.com
2021-06-02 21:45:06 +01:00
parent 4f9dd50382
commit 753bf8fe62
3 changed files with 167 additions and 21 deletions

View File

@@ -60,6 +60,8 @@ TranscludeWidget.prototype.execute = function() {
subTiddler: this.transcludeSubTiddler
}),
parseTreeNodes = parser ? parser.tree : this.parseTreeNode.children;
this.sourceText = parser ? parser.source : null;
this.parserType = parser? parser.type : null;
// Set context variables for recursion detection
var recursionMarker = this.makeRecursionMarker();
if(this.recursionMarker === "yes") {
@@ -98,12 +100,17 @@ TranscludeWidget.prototype.makeRecursionMarker = function() {
return output.join("");
};
TranscludeWidget.prototype.parserNeedsRefresh = function() {
var parserInfo = this.wiki.getTextReferenceParserInfo(this.transcludeTitle,this.transcludeField,this.transcludeIndex,{subTiddler:this.transcludeSubTiddler});
return (this.sourceText === undefined || parserInfo.sourceText !== this.sourceText || parserInfo.parserType !== this.parserType)
};
/*
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
*/
TranscludeWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedTiddlers[this.transcludeTitle]) {
if(($tw.utils.count(changedAttributes) > 0) || (changedTiddlers[this.transcludeTitle] && this.parserNeedsRefresh())) {
this.refreshSelf();
return true;
} else {