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:
@@ -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))
|
||||
|
||||
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user