HS: closest parent <sel> traversal (+1 test)

parse-trav recognises `parent` as an ident modifier after the
`closest` keyword — consumes it and re-invokes with kind
`closest-parent`, producing AST `(closest-parent "div" (me))` instead
of the generic trailing-ident-as-unit shape
`(string-postfix (closest "*" (me)) "parent")`.

Compiler translates `(closest-parent sel target)` to
`(dom-closest (host-get target "parentElement") sel)` so `me` is
skipped and only strict ancestors match. `closest-parent` also
joined the `put X into <trav>` inner-html shortcut alongside
next/previous/closest.

Suite hs-upstream-core/regressions: 10/16 → 11/16.
Smoke 0-195: 162/195 → 163/195.
This commit is contained in:
2026-04-24 09:33:32 +00:00
parent 99706a91d1
commit 0d38a75b21
6 changed files with 54 additions and 13 deletions

View File

@@ -109,7 +109,7 @@
(hs-to-sx (nth target 1))
(hs-to-sx (nth target 2))
value))
((or (= th (quote next)) (= th (quote previous)) (= th (quote closest)))
((or (= th (quote next)) (= th (quote previous)) (= th (quote closest)) (= th (quote closest-parent)))
(list (quote hs-set-inner-html!) (hs-to-sx target) value))
((= th (quote of))
(let
@@ -966,7 +966,11 @@
((= prop "first") (list (quote hs-first) target))
((= prop "last") (list (quote hs-last) target))
(true (list (quote host-get) target prop)))))
((= head (quote ref)) (if (= (nth ast 1) "selection") (list (quote hs-get-selection)) (make-symbol (nth ast 1))))
((= head (quote ref))
(if
(= (nth ast 1) "selection")
(list (quote hs-get-selection))
(make-symbol (nth ast 1))))
((= head (quote query))
(list (quote hs-query-first) (nth ast 1)))
((= head (quote query-scoped))
@@ -1153,6 +1157,14 @@
(quote dom-closest)
(hs-to-sx (nth ast 2))
(nth ast 1)))
((= head (quote closest-parent))
(list
(quote dom-closest)
(list
(quote host-get)
(hs-to-sx (nth ast 2))
"parentElement")
(nth ast 1)))
((= head (quote next))
(list (quote hs-next) (hs-to-sx (nth ast 2)) (nth ast 1)))
((= head (quote previous))