From 2b41aaa6ce44a3e3e5df8a41f651b3880e07a401 Mon Sep 17 00:00:00 2001 From: giles Date: Sun, 1 Mar 2026 13:40:50 +0000 Subject: [PATCH] Fix renderComponentDOM evaluating kwarg expressions in wrong scope MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit renderComponentDOM was deferring evaluation of complex expressions (arrays) passed as component kwargs, storing raw AST instead. When the component body later used these values as attributes, the caller's env (with lambda params like t, a) was no longer available, producing stringified arrays like "get,t,src" as attribute values — which browsers interpreted as relative URLs. Evaluate all non-literal kwarg values eagerly in the caller's env, matching the behavior of callComponent and the Python-side renderer. Co-Authored-By: Claude Opus 4.6 --- shared/static/scripts/sx.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/shared/static/scripts/sx.js b/shared/static/scripts/sx.js index a8825f0..6b77fd6 100644 --- a/shared/static/scripts/sx.js +++ b/shared/static/scripts/sx.js @@ -813,13 +813,12 @@ var i = 0; while (i < args.length) { if (isKw(args[i]) && i + 1 < args.length) { - // Keep kwarg values as AST — renderDOM will handle them when the - // component body references the param symbol. Simple literals are - // eval'd so strings/numbers resolve immediately. + // Evaluate kwarg values eagerly so expressions like (get t "src") + // resolve in the caller's env (where lambda params are bound). var v = args[i + 1]; kwargs[args[i].name] = (typeof v === "string" || typeof v === "number" || - typeof v === "boolean" || isNil(v) || isKw(v)) - ? v : (isSym(v) ? sxEval(v, env) : v); + typeof v === "boolean" || isNil(v)) + ? v : sxEval(v, env); i += 2; } else { children.push(args[i]);