HS: remove .class from .coll when it matches .filter
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 19s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 19s
Parser produces remove-class-when AST node; compiler emits filter + for-each pattern matching add-class-when. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1571,6 +1571,35 @@
|
||||
(quote dom-remove-class)
|
||||
(if (nil? raw-tgt) (quote me) (hs-to-sx raw-tgt))
|
||||
(nth ast 1)))))
|
||||
((= head (quote remove-class-when))
|
||||
(let
|
||||
((cls (nth ast 1))
|
||||
(raw-tgt (nth ast 2))
|
||||
(when-cond (nth ast 3)))
|
||||
(let
|
||||
((tgt-expr (cond
|
||||
((and (list? raw-tgt) (= (first raw-tgt) (quote query)))
|
||||
(list (quote hs-query-all) (nth raw-tgt 1)))
|
||||
(true (hs-to-sx raw-tgt)))))
|
||||
(list
|
||||
(quote let)
|
||||
(list
|
||||
(list
|
||||
(quote __hs-matched)
|
||||
(list
|
||||
(quote filter)
|
||||
(list
|
||||
(quote fn)
|
||||
(list (quote it))
|
||||
(hs-to-sx when-cond))
|
||||
tgt-expr)))
|
||||
(list
|
||||
(quote for-each)
|
||||
(list
|
||||
(quote fn)
|
||||
(list (quote it))
|
||||
(list (quote dom-remove-class) (quote it) cls))
|
||||
(quote __hs-matched))))))
|
||||
((= head (quote remove-element))
|
||||
(let
|
||||
((tgt (nth ast 1)))
|
||||
|
||||
@@ -1133,12 +1133,17 @@
|
||||
(collect-classes!)
|
||||
(let
|
||||
((tgt (if (match-kw "from") (parse-expr) (list (quote beingTold)))))
|
||||
(if
|
||||
(empty? extra-classes)
|
||||
(list (quote remove-class) cls tgt)
|
||||
(cons
|
||||
(quote multi-remove-class)
|
||||
(cons tgt (cons cls extra-classes)))))))
|
||||
(let
|
||||
((when-clause (if (match-kw "when") (parse-expr) nil)))
|
||||
(if
|
||||
(empty? extra-classes)
|
||||
(if
|
||||
when-clause
|
||||
(list (quote remove-class-when) cls tgt when-clause)
|
||||
(list (quote remove-class) cls tgt))
|
||||
(cons
|
||||
(quote multi-remove-class)
|
||||
(cons tgt (cons cls extra-classes))))))))
|
||||
((= (tp-type) "attr")
|
||||
(let
|
||||
((attr-name (get (adv!) "value")))
|
||||
|
||||
@@ -1571,6 +1571,35 @@
|
||||
(quote dom-remove-class)
|
||||
(if (nil? raw-tgt) (quote me) (hs-to-sx raw-tgt))
|
||||
(nth ast 1)))))
|
||||
((= head (quote remove-class-when))
|
||||
(let
|
||||
((cls (nth ast 1))
|
||||
(raw-tgt (nth ast 2))
|
||||
(when-cond (nth ast 3)))
|
||||
(let
|
||||
((tgt-expr (cond
|
||||
((and (list? raw-tgt) (= (first raw-tgt) (quote query)))
|
||||
(list (quote hs-query-all) (nth raw-tgt 1)))
|
||||
(true (hs-to-sx raw-tgt)))))
|
||||
(list
|
||||
(quote let)
|
||||
(list
|
||||
(list
|
||||
(quote __hs-matched)
|
||||
(list
|
||||
(quote filter)
|
||||
(list
|
||||
(quote fn)
|
||||
(list (quote it))
|
||||
(hs-to-sx when-cond))
|
||||
tgt-expr)))
|
||||
(list
|
||||
(quote for-each)
|
||||
(list
|
||||
(quote fn)
|
||||
(list (quote it))
|
||||
(list (quote dom-remove-class) (quote it) cls))
|
||||
(quote __hs-matched))))))
|
||||
((= head (quote remove-element))
|
||||
(let
|
||||
((tgt (nth ast 1)))
|
||||
|
||||
@@ -1133,12 +1133,17 @@
|
||||
(collect-classes!)
|
||||
(let
|
||||
((tgt (if (match-kw "from") (parse-expr) (list (quote beingTold)))))
|
||||
(if
|
||||
(empty? extra-classes)
|
||||
(list (quote remove-class) cls tgt)
|
||||
(cons
|
||||
(quote multi-remove-class)
|
||||
(cons tgt (cons cls extra-classes)))))))
|
||||
(let
|
||||
((when-clause (if (match-kw "when") (parse-expr) nil)))
|
||||
(if
|
||||
(empty? extra-classes)
|
||||
(if
|
||||
when-clause
|
||||
(list (quote remove-class-when) cls tgt when-clause)
|
||||
(list (quote remove-class) cls tgt))
|
||||
(cons
|
||||
(quote multi-remove-class)
|
||||
(cons tgt (cons cls extra-classes))))))))
|
||||
((= (tp-type) "attr")
|
||||
(let
|
||||
((attr-name (get (adv!) "value")))
|
||||
|
||||
Reference in New Issue
Block a user