From 3f4067ef7bdef0553cb7030784e439a8f1a00766 Mon Sep 17 00:00:00 2001 From: Saq Imtiaz Date: Mon, 30 Sep 2024 15:26:36 +0200 Subject: [PATCH] Fix: variables in functions should not pollute upstream widgets (#8641) --- core/modules/widgets/widget.js | 2 +- .../functions/FunctionFilterrunVariables4.tid | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 editions/test/tiddlers/tests/data/functions/FunctionFilterrunVariables4.tid diff --git a/core/modules/widgets/widget.js b/core/modules/widgets/widget.js index eb84fab4a..b73294654 100755 --- a/core/modules/widgets/widget.js +++ b/core/modules/widgets/widget.js @@ -335,7 +335,7 @@ Widget.prototype.makeFakeWidgetWithVariables = function(variables) { }; } else { opts = opts || {}; - opts.variables = $tw.utils.extend(variables,opts.variables); + opts.variables = $tw.utils.extend({},variables,opts.variables); return self.getVariableInfo(name,opts); }; }, diff --git a/editions/test/tiddlers/tests/data/functions/FunctionFilterrunVariables4.tid b/editions/test/tiddlers/tests/data/functions/FunctionFilterrunVariables4.tid new file mode 100644 index 000000000..d78b211ad --- /dev/null +++ b/editions/test/tiddlers/tests/data/functions/FunctionFilterrunVariables4.tid @@ -0,0 +1,20 @@ +title: Functions/FunctionFilterrunVariables4 +description: Nested functions in filter runs that set variables should not pollute upstream widget tree +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Output + +\function .a() [.b[]] +\function .b() [all[]] :map[subtract[1].c[]] +\function .c() [all[]] :map[subtract[1].d[]] +\function .d() [all[]] :map[subtract[1].e[]] +\function .e() [all[]] :map[subtract[1]] + + +<$text text={{{ [[10]] :map:flat[.a[]then] }}}/> + ++ +title: ExpectedResult + +10 \ No newline at end of file