From b54a88ce83fd4d5410d08310074dbfc10d20802a Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sun, 16 Jul 2023 14:04:09 +0100 Subject: [PATCH] Clean up transclude widget 1. Update comments 2. Refactor use of parseTreeNodes so that they are not referenced unnecessarily 3. getTransclusionTarget doesn't need to return the parser object --- core/modules/widgets/transclude.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/modules/widgets/transclude.js b/core/modules/widgets/transclude.js index 7e63ff156..7b4b9581d 100755 --- a/core/modules/widgets/transclude.js +++ b/core/modules/widgets/transclude.js @@ -41,16 +41,17 @@ TranscludeWidget.prototype.execute = function() { this.collectAttributes(); this.collectStringParameters(); this.collectSlotFillParameters(); - // Get the parse tree nodes that we are transcluding + // Get the target text and parse tree nodes that we are transcluding var target = this.getTransclusionTarget(), - parseTreeNodes = target.parseTreeNodes; + parseTreeNodes; this.sourceText = target.text; this.parserType = target.type; this.parseAsInline = target.parseAsInline; // Process the transclusion according to the output type switch(this.transcludeOutput || "text/html") { case "text/html": - // No further processing required + // Return the parse tree nodes + parseTreeNodes = target.parseTreeNodes; break; case "text/raw": // Just return the raw text @@ -158,7 +159,7 @@ TranscludeWidget.prototype.collectSlotFillParameters = function() { }; /* -Get transcluded parse tree nodes as an object {parser:,text:,type:} +Get transcluded parse tree nodes as an object {text:,type:,parseTreeNodes:,parseAsInline:} */ TranscludeWidget.prototype.getTransclusionTarget = function() { var self = this; @@ -270,7 +271,6 @@ TranscludeWidget.prototype.getTransclusionTarget = function() { // Return the parse tree if(parser) { return { - parser: parser, parseTreeNodes: parser.tree, parseAsInline: parseAsInline, text: parser.source, @@ -279,7 +279,6 @@ TranscludeWidget.prototype.getTransclusionTarget = function() { } else { // If there's no parse tree then return the missing slot value return { - parser: null, parseTreeNodes: (this.slotFillParseTrees["ts-missing"] || []), parseAsInline: parseAsInline, text: null,