Fix island dep scanning + spread-through-reactive-if debug

deps.sx: scan island bodies for component deps (was only scanning
"component" and "macro", missing "island" type). This ensures
~cssx/tw and its dependencies are sent to the client for islands.

cssx.sx: move if inside make-spread arg so it's evaluated by
eval-expr (no reactive wrapping) instead of render-to-dom which
applies reactive-if inside island scope, converting the spread
into a fragment and losing the class attrs.

Added island dep tests at 3 levels: test-deps.sx (spec),
test_deps.py (Python), test_parity.py (ref vs fallback).

sx-browser.js: temporary debug logging at spread detection points.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 04:37:45 +00:00
parent 1d1e7f30bb
commit 2c97542ee8
7 changed files with 69 additions and 13 deletions

View File

@@ -14,7 +14,7 @@
// =========================================================================
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } });
var SX_VERSION = "2026-03-13T04:08:59Z";
var SX_VERSION = "2026-03-13T04:16:14Z";
function isNil(x) { return x === NIL || x === null || x === undefined; }
function isSxTruthy(x) { return x !== false && !isNil(x); }
@@ -1934,6 +1934,8 @@ return (function() { var _m = typeOf(expr); if (_m == "nil") return createFragme
return assoc(state, "skip", true, "i", (get(state, "i") + 1));
})() : ((isSxTruthy(!isSxTruthy(contains(VOID_ELEMENTS, tag))) ? (function() {
var child = renderToDom(arg, env, newNs);
if (child && child._spread) console.log("[sx-debug] SPREAD detected in element child:", tag, child.attrs);
if (child && !child._spread && child.nodeType === 11 && arg && arg[0] && arg[0].name && arg[0].name.indexOf("cssx") >= 0) console.log("[sx-debug] ~cssx child NOT spread:", tag, "type:", typeof child, "nodeType:", child.nodeType, "childNodes:", child.childNodes ? child.childNodes.length : "N/A");
return (isSxTruthy(isSpread(child)) ? forEach(function(key) { return (function() {
var val = dictGet(spreadAttrs(child), key);
return (isSxTruthy((key == "class")) ? (function() {
@@ -1974,7 +1976,9 @@ return (function() { var _m = typeOf(expr); if (_m == "nil") return createFragme
return envSet(local, "children", childFrag);
})();
}
return renderToDom(componentBody(comp), local, ns);
var _compResult = renderToDom(componentBody(comp), local, ns);
if (componentName(comp).indexOf("cssx") >= 0) console.log("[sx-debug] renderDomComponent", componentName(comp), "returned:", _compResult, "isSpread:", isSpread(_compResult), "type:", typeOf(_compResult), "_spread:", _compResult && _compResult._spread);
return _compResult;
})();
})(); };
@@ -2017,8 +2021,10 @@ return (function() { var _m = typeOf(expr); if (_m == "nil") return createFragme
var condVal = trampoline(evalExpr(nth(expr, 1), env));
return (isSxTruthy(condVal) ? renderToDom(nth(expr, 2), env, ns) : (isSxTruthy((len(expr) > 3)) ? renderToDom(nth(expr, 3), env, ns) : createFragment()));
})();
if (result && result._spread) console.log("[sx-debug] reactive-if result IS a spread:", result.attrs, "— will be LOST in fragment wrapping");
return (isSxTruthy(domParent(marker)) ? (forEach(function(n) { return domRemove(n); }, currentNodes), (currentNodes = (isSxTruthy(domIsFragment(result)) ? domChildNodes(result) : [result])), domInsertAfter(marker, result)) : (initialResult = result));
})(); });
if (initialResult && initialResult._spread) console.log("[sx-debug] reactive-if initialResult IS a spread — returning frag instead of spread!");
return (function() {
var frag = createFragment();
domAppend(frag, marker);
@@ -3601,7 +3607,7 @@ callExpr.push(dictGet(kwargs, k)); } }
// transitive-deps-walk
var transitiveDepsWalk = function(n, seen, env) { return (isSxTruthy(!isSxTruthy(contains(seen, n))) ? (append_b(seen, n), (function() {
var val = envGet(env, n);
return (isSxTruthy((typeOf(val) == "component")) ? forEach(function(ref) { return transitiveDepsWalk(ref, seen, env); }, scanRefs(componentBody(val))) : (isSxTruthy((typeOf(val) == "macro")) ? forEach(function(ref) { return transitiveDepsWalk(ref, seen, env); }, scanRefs(macroBody(val))) : NIL));
return (isSxTruthy(sxOr((typeOf(val) == "component"), (typeOf(val) == "island"))) ? forEach(function(ref) { return transitiveDepsWalk(ref, seen, env); }, scanRefs(componentBody(val))) : (isSxTruthy((typeOf(val) == "macro")) ? forEach(function(ref) { return transitiveDepsWalk(ref, seen, env); }, scanRefs(macroBody(val))) : NIL));
})()) : NIL); };
// transitive-deps
@@ -3615,7 +3621,7 @@ callExpr.push(dictGet(kwargs, k)); } }
// compute-all-deps
var computeAllDeps = function(env) { return forEach(function(name) { return (function() {
var val = envGet(env, name);
return (isSxTruthy((typeOf(val) == "component")) ? componentSetDeps(val, transitiveDeps(name, env)) : NIL);
return (isSxTruthy(sxOr((typeOf(val) == "component"), (typeOf(val) == "island"))) ? componentSetDeps(val, transitiveDeps(name, env)) : NIL);
})(); }, envComponents(env)); };
// scan-components-from-source