Fix renderComponentDOM evaluating kwarg expressions in wrong scope
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user