HS: DOM ref-eq + compound selector + DOM tree fixes

- hs-id= uses JS === for DOM elements (hs-ref-eq), = for scalars
- != operator now uses hs-id= for structural correctness
- compound tag[attr=val] selector matching in test runner
- dom-query-all replaces host-call querySelectorAll
- DOM tree structure corrected in 4 generated tests (elements were
  appended to wrong parents)
This commit is contained in:
2026-04-26 17:49:51 +00:00
parent f2993f0582
commit a48110417b
9 changed files with 95 additions and 61 deletions

View File

@@ -1148,6 +1148,11 @@
(quote =)
(hs-to-sx (nth ast 1))
(hs-to-sx (nth ast 2))))
((= head (quote hs-id=))
(list
(quote hs-id=)
(hs-to-sx (nth ast 1))
(hs-to-sx (nth ast 2))))
((= head (quote +))
(list
(quote hs-add)

View File

@@ -550,7 +550,9 @@
(list
(quote not)
(list (quote eq-ignore-case) left right)))
(list (quote not) (list (quote =) left right)))))))
(list
(quote not)
(list (quote hs-id=) left right)))))))
((match-kw "empty") (list (quote empty?) left))
((match-kw "less")
(do

View File

@@ -650,9 +650,7 @@
(true (find-prev (dom-get-prop el "previousElementSibling"))))))
(find-prev sibling)))))
(define
hs-query-all
(fn (sel) (host-call (dom-body) "querySelectorAll" sel)))
(define hs-query-all (fn (sel) (dom-query-all (dom-body) sel)))
@@ -662,10 +660,7 @@
hs-query-all-in
(fn
(sel target)
(if
(nil? target)
(hs-query-all sel)
(host-call target "querySelectorAll" sel))))
(if (nil? target) (hs-query-all sel) (dom-query-all target sel))))
(define
hs-list-set
@@ -1418,6 +1413,15 @@
hs-strict-eq
(fn (a b) (and (= (type-of a) (type-of b)) (= a b))))
(define
hs-id=
(fn
(a b)
(if
(and (= (host-typeof a) "element") (= (host-typeof b) "element"))
(hs-ref-eq a b)
(= a b))))
(define
hs-eq-ignore-case
(fn (a b) (= (downcase (str a)) (downcase (str b)))))
@@ -2511,14 +2515,14 @@
((= a b) true)
(true (hs-dom-is-ancestor? a (dom-parent b))))))
;; ── SourceInfo API ────────────────────────────────────────────────
(define
hs-win-call
(fn
(fn-name args)
(let ((fn (host-global fn-name))) (if fn (host-call-fn fn args) nil))))
;; ── SourceInfo API ────────────────────────────────────────────────
(define
hs-source-for
(fn
@@ -2534,16 +2538,9 @@
(line-idx (- (get node :line) 1)))
(if (< line-idx (len lines)) (nth lines line-idx) ""))))
(define
hs-node-get
(fn
(node key)
(get (get node :fields) key)))
(define hs-node-get (fn (node key) (get (get node :fields) key)))
(define
hs-src
(fn (src-str)
(hs-source-for (hs-parse-ast src-str))))
(define hs-src (fn (src-str) (hs-source-for (hs-parse-ast src-str))))
(define
hs-src-at
@@ -2553,7 +2550,8 @@
walk
(fn
(node keys)
(if (or (nil? keys) (= (len keys) 0))
(if
(or (nil? keys) (= (len keys) 0))
node
(walk (hs-node-get node (first keys)) (rest keys)))))
(hs-source-for (walk (hs-parse-ast src-str) path))))
@@ -2566,7 +2564,8 @@
walk
(fn
(node keys)
(if (or (nil? keys) (= (len keys) 0))
(if
(or (nil? keys) (= (len keys) 0))
node
(walk (hs-node-get node (first keys)) (rest keys)))))
(hs-line-for (walk (hs-parse-ast src-str) path))))