HS generator+runtime: nth() dispatch+expect, dom-query-all SX-list passthrough, nth-of-type selector

- generate-sx-tests.py: add_action/add_assertion accept .nth(N) in PW-body
  tests so 'find(sel).nth(1).dispatchEvent(...)' lands as a dispatch on
  the Nth matching element, and assertions target that same element.
- shared/static/wasm/sx/dom.sx: dom-query-all hands through an already-SX
  list unchanged — the bridge often pre-converts NodeLists/arrays to SX
  lists, so the host-get 'length' / host-call 'item' loop was returning
  empty. Guards node-list=nil and non-list types too.
- tests/hs-run-filtered.js (mock DOM): fnd() understands
  ':nth-of-type(N)', ':first-of-type', ':last-of-type' by matching the
  stripped base selector and returning the correct-indexed sibling.
  Covers upstream tests that write 'find("div:nth-of-type(2)")' to
  pick the HS-owning element.
- Runtime runtime.sx: hs-sorted-by, hs-fetch format normalizer (JSON/
  Object/etc.), nil-safe hs-joined-by/hs-split-by, emit-fetch chain sets
  the-result when wrapped in let((it …)).

Net: take 0→6, hide 11→12, show 15→16, fetch 11→15,
collectionExpressions 13→15 (remaining are a WASM JIT bug on
{…} literals inside arrays).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-23 16:41:47 +00:00
parent 5b100cac17
commit 3528cef35a
6 changed files with 150 additions and 30 deletions

View File

@@ -1803,9 +1803,35 @@
(fn (p) (nth p 1))
(sort (fn (a b) (if (> (first a) (first b)) true false)) pairs)))))
(define hs-split-by (fn (s sep) (split s sep)))
(define hs-split-by (fn (s sep) (if (nil? s) nil (split s sep))))
(define hs-joined-by (fn (col sep) (join sep col)))
(define
hs-joined-by
(fn
(col sep)
(cond
((nil? col) nil)
((list? col)
(join sep (map (fn (x) (if (nil? x) "" (str x))) col)))
(true col))))
(define
hs-sorted-by
(fn
(coll key-fn)
(if
(not (list? coll))
coll
(sort
(fn
(a b)
(let
((ka (key-fn a)) (kb (key-fn b)))
(cond
((nil? ka) (not (nil? kb)))
((nil? kb) false)
(true (< ka kb)))))
coll))))
(define
hs-sorted-by