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

@@ -89,6 +89,8 @@
(let
((typ (tp-type)) (val (tp-val)))
(cond
((and (= kind (quote closest)) (= typ "ident") (= val "parent"))
(do (adv!) (parse-trav (quote closest-parent))))
((= typ "selector")
(do (adv!) (list kind val (list (quote me)))))
((= typ "class")
@@ -2507,8 +2509,13 @@
((acc2 (append acc (list cmd))))
(cond
((match-kw "unless")
(let ((cnd (parse-expr)))
(cl-collect (append acc (list (list (quote if) (list (quote no) cnd) cmd))))))
(let
((cnd (parse-expr)))
(cl-collect
(append
acc
(list
(list (quote if) (list (quote no) cnd) cmd))))))
((match-kw "then")
(cl-collect (append acc2 (list (quote __then__)))))
((and (not (at-end?)) (= (tp-type) "keyword") (cmd-kw? (tp-val)))