1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-02-08 23:20:03 +00:00

Widget.getVariableInfo() shouldn't return srcVariable if variable is missing

Fixes #7566
This commit is contained in:
jeremy@jermolene.com 2023-06-28 11:31:12 +01:00
parent 16ef1d84cd
commit a02d99a4c1
2 changed files with 5 additions and 6 deletions

View File

@ -177,7 +177,7 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}), var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()}),
srcVariable = variableInfo && variableInfo.srcVariable; srcVariable = variableInfo && variableInfo.srcVariable;
if(variableInfo.text) { if(variableInfo.text) {
if(srcVariable.isFunctionDefinition) { if(srcVariable && srcVariable.isFunctionDefinition) {
var result = (variableInfo.resultList ? variableInfo.resultList[0] : variableInfo.text) || ""; var result = (variableInfo.resultList ? variableInfo.resultList[0] : variableInfo.text) || "";
parser = { parser = {
tree: [{ tree: [{
@ -207,7 +207,7 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
if(variableInfo.isCacheable && srcVariable[cacheKey]) { if(variableInfo.isCacheable && srcVariable[cacheKey]) {
parser = srcVariable[cacheKey]; parser = srcVariable[cacheKey];
} else { } else {
parser = this.wiki.parseText(this.transcludeType,variableInfo.text || "",{parseAsInline: parseAsInline, configTrimWhiteSpace: srcVariable.configTrimWhiteSpace}); parser = this.wiki.parseText(this.transcludeType,variableInfo.text || "",{parseAsInline: parseAsInline, configTrimWhiteSpace: srcVariable && srcVariable.configTrimWhiteSpace});
if(variableInfo.isCacheable) { if(variableInfo.isCacheable) {
srcVariable[cacheKey] = parser; srcVariable[cacheKey] = parser;
} }
@ -215,7 +215,7 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
} }
if(parser) { if(parser) {
// Add parameters widget for procedures and custom widgets // Add parameters widget for procedures and custom widgets
if(srcVariable.isProcedureDefinition || srcVariable.isWidgetDefinition) { if(srcVariable && (srcVariable.isProcedureDefinition || srcVariable.isWidgetDefinition)) {
parser = { parser = {
tree: [ tree: [
{ {
@ -234,7 +234,7 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
} }
$tw.utils.addAttributeToParseTreeNode(parser.tree[0],name,param["default"]) $tw.utils.addAttributeToParseTreeNode(parser.tree[0],name,param["default"])
}); });
} else if(srcVariable.isMacroDefinition || !srcVariable.isFunctionDefinition) { } else if(srcVariable && (srcVariable.isMacroDefinition || !srcVariable.isFunctionDefinition)) {
// For macros and ordinary variables, wrap the parse tree in a vars widget assigning the parameters to variables named "__paramname__" // For macros and ordinary variables, wrap the parse tree in a vars widget assigning the parameters to variables named "__paramname__"
parser = { parser = {
tree: [ tree: [

View File

@ -182,8 +182,7 @@ Widget.prototype.getVariableInfo = function(name,options) {
} }
return { return {
text: text, text: text,
resultList: [text], resultList: [text]
srcVariable: {}
}; };
}; };