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

@@ -113,6 +113,17 @@ class TestTransitiveDeps:
deps = transitive_deps("~card", env)
assert "~unknown" in deps
def test_island_deps_scanned(self):
"""Island bodies must be scanned for component dependencies."""
env = make_env(
'(defcomp ~leaf (&key) (span "leaf"))',
'(defcomp ~branch (&key) (div (~leaf)))',
'(defisland ~my-island () (div (~branch) "island"))',
)
deps = transitive_deps("~my-island", env)
assert "~branch" in deps
assert "~leaf" in deps
def test_without_tilde_prefix(self):
env = make_env(
'(defcomp ~card (&key) (div (~shared:misc/badge)))',

View File

@@ -705,6 +705,21 @@ class TestParityDeps:
ref_d = ref_env[key].deps
assert set(hw_d) == set(ref_d), f"Deps mismatch for {key}"
def test_transitive_deps_island(self):
"""Island bodies must be scanned for component deps."""
from shared.sx.deps import _transitive_deps_fallback
from shared.sx.ref.sx_ref import transitive_deps as ref_td
hw_env, ref_env = self._make_envs(
'(defcomp ~leaf (&key) (span "leaf"))',
'(defcomp ~branch (&key) (div (~leaf)))',
'(defisland ~my-island () (div (~branch) "island content"))',
)
hw_deps = _transitive_deps_fallback("~my-island", hw_env)
ref_deps = set(ref_td("~my-island", ref_env))
assert hw_deps == ref_deps
assert "~branch" in ref_deps
assert "~leaf" in ref_deps
def test_scan_components_from_sx(self):
from shared.sx.deps import _scan_components_from_sx_fallback
from shared.sx.ref.sx_ref import scan_components_from_source as ref_sc