HS: take attr semantics fix, +6 tests (509→515/831)
- Parser: take @attr=value with replacement restored (was reverted) - Runtime: take @attr bare doesn't remove from scope (hyperscript keeps source attr, only sets on target). Only take @attr=val with replacement modifies scope elements. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1315,12 +1315,23 @@
|
|||||||
(list (quote take!) "class" cls from-sel for-tgt)))))
|
(list (quote take!) "class" cls from-sel for-tgt)))))
|
||||||
((= (tp-type) "attr")
|
((= (tp-type) "attr")
|
||||||
(let
|
(let
|
||||||
((attr-name (do (let ((v (tp-val))) (adv!) v))))
|
((attr-name (get (adv!) "value")))
|
||||||
(let
|
(let
|
||||||
((from-sel (if (match-kw "from") (parse-expr) nil)))
|
((attr-val (if (and (= (tp-type) "op") (= (tp-val) "=")) (do (adv!) (get (adv!) "value")) nil)))
|
||||||
(let
|
(let
|
||||||
((for-tgt (if (match-kw "for") (parse-expr) nil)))
|
((with-val (if (match-kw "with") (parse-expr) nil)))
|
||||||
(list (quote take!) "attr" attr-name from-sel for-tgt)))))
|
(let
|
||||||
|
((from-sel (if (match-kw "from") (parse-expr) nil)))
|
||||||
|
(let
|
||||||
|
((for-tgt (if (match-kw "for") (parse-expr) nil)))
|
||||||
|
(list
|
||||||
|
(quote take!)
|
||||||
|
"attr"
|
||||||
|
attr-name
|
||||||
|
from-sel
|
||||||
|
for-tgt
|
||||||
|
attr-val
|
||||||
|
with-val)))))))
|
||||||
(true nil))))
|
(true nil))))
|
||||||
(define
|
(define
|
||||||
parse-go-cmd
|
parse-go-cmd
|
||||||
|
|||||||
@@ -114,14 +114,9 @@
|
|||||||
((attr-val (if (> (len extra) 0) (first extra) nil))
|
((attr-val (if (> (len extra) 0) (first extra) nil))
|
||||||
(with-val (if (> (len extra) 1) (nth extra 1) nil)))
|
(with-val (if (> (len extra) 1) (nth extra 1) nil)))
|
||||||
(do
|
(do
|
||||||
(for-each
|
(when
|
||||||
(fn
|
with-val
|
||||||
(el)
|
(for-each (fn (el) (dom-set-attr el name with-val)) els))
|
||||||
(if
|
|
||||||
with-val
|
|
||||||
(dom-set-attr el name with-val)
|
|
||||||
(dom-remove-attr el name)))
|
|
||||||
els)
|
|
||||||
(if
|
(if
|
||||||
attr-val
|
attr-val
|
||||||
(dom-set-attr target name attr-val)
|
(dom-set-attr target name attr-val)
|
||||||
|
|||||||
@@ -1315,12 +1315,23 @@
|
|||||||
(list (quote take!) "class" cls from-sel for-tgt)))))
|
(list (quote take!) "class" cls from-sel for-tgt)))))
|
||||||
((= (tp-type) "attr")
|
((= (tp-type) "attr")
|
||||||
(let
|
(let
|
||||||
((attr-name (do (let ((v (tp-val))) (adv!) v))))
|
((attr-name (get (adv!) "value")))
|
||||||
(let
|
(let
|
||||||
((from-sel (if (match-kw "from") (parse-expr) nil)))
|
((attr-val (if (and (= (tp-type) "op") (= (tp-val) "=")) (do (adv!) (get (adv!) "value")) nil)))
|
||||||
(let
|
(let
|
||||||
((for-tgt (if (match-kw "for") (parse-expr) nil)))
|
((with-val (if (match-kw "with") (parse-expr) nil)))
|
||||||
(list (quote take!) "attr" attr-name from-sel for-tgt)))))
|
(let
|
||||||
|
((from-sel (if (match-kw "from") (parse-expr) nil)))
|
||||||
|
(let
|
||||||
|
((for-tgt (if (match-kw "for") (parse-expr) nil)))
|
||||||
|
(list
|
||||||
|
(quote take!)
|
||||||
|
"attr"
|
||||||
|
attr-name
|
||||||
|
from-sel
|
||||||
|
for-tgt
|
||||||
|
attr-val
|
||||||
|
with-val)))))))
|
||||||
(true nil))))
|
(true nil))))
|
||||||
(define
|
(define
|
||||||
parse-go-cmd
|
parse-go-cmd
|
||||||
|
|||||||
@@ -114,14 +114,9 @@
|
|||||||
((attr-val (if (> (len extra) 0) (first extra) nil))
|
((attr-val (if (> (len extra) 0) (first extra) nil))
|
||||||
(with-val (if (> (len extra) 1) (nth extra 1) nil)))
|
(with-val (if (> (len extra) 1) (nth extra 1) nil)))
|
||||||
(do
|
(do
|
||||||
(for-each
|
(when
|
||||||
(fn
|
with-val
|
||||||
(el)
|
(for-each (fn (el) (dom-set-attr el name with-val)) els))
|
||||||
(if
|
|
||||||
with-val
|
|
||||||
(dom-set-attr el name with-val)
|
|
||||||
(dom-remove-attr el name)))
|
|
||||||
els)
|
|
||||||
(if
|
(if
|
||||||
attr-val
|
attr-val
|
||||||
(dom-set-attr target name attr-val)
|
(dom-set-attr target name attr-val)
|
||||||
|
|||||||
Reference in New Issue
Block a user