diff --git a/lib/hyperscript/parser.sx b/lib/hyperscript/parser.sx index d00235dc..eba498cd 100644 --- a/lib/hyperscript/parser.sx +++ b/lib/hyperscript/parser.sx @@ -1315,12 +1315,23 @@ (list (quote take!) "class" cls from-sel for-tgt))))) ((= (tp-type) "attr") (let - ((attr-name (do (let ((v (tp-val))) (adv!) v)))) + ((attr-name (get (adv!) "value"))) (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 - ((for-tgt (if (match-kw "for") (parse-expr) nil))) - (list (quote take!) "attr" attr-name from-sel for-tgt))))) + ((with-val (if (match-kw "with") (parse-expr) nil))) + (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)))) (define parse-go-cmd diff --git a/lib/hyperscript/runtime.sx b/lib/hyperscript/runtime.sx index 7687e6df..b913f913 100644 --- a/lib/hyperscript/runtime.sx +++ b/lib/hyperscript/runtime.sx @@ -114,14 +114,9 @@ ((attr-val (if (> (len extra) 0) (first extra) nil)) (with-val (if (> (len extra) 1) (nth extra 1) nil))) (do - (for-each - (fn - (el) - (if - with-val - (dom-set-attr el name with-val) - (dom-remove-attr el name))) - els) + (when + with-val + (for-each (fn (el) (dom-set-attr el name with-val)) els)) (if attr-val (dom-set-attr target name attr-val) diff --git a/shared/static/wasm/sx/hs-parser.sx b/shared/static/wasm/sx/hs-parser.sx index d00235dc..eba498cd 100644 --- a/shared/static/wasm/sx/hs-parser.sx +++ b/shared/static/wasm/sx/hs-parser.sx @@ -1315,12 +1315,23 @@ (list (quote take!) "class" cls from-sel for-tgt))))) ((= (tp-type) "attr") (let - ((attr-name (do (let ((v (tp-val))) (adv!) v)))) + ((attr-name (get (adv!) "value"))) (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 - ((for-tgt (if (match-kw "for") (parse-expr) nil))) - (list (quote take!) "attr" attr-name from-sel for-tgt))))) + ((with-val (if (match-kw "with") (parse-expr) nil))) + (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)))) (define parse-go-cmd diff --git a/shared/static/wasm/sx/hs-runtime.sx b/shared/static/wasm/sx/hs-runtime.sx index 7687e6df..b913f913 100644 --- a/shared/static/wasm/sx/hs-runtime.sx +++ b/shared/static/wasm/sx/hs-runtime.sx @@ -114,14 +114,9 @@ ((attr-val (if (> (len extra) 0) (first extra) nil)) (with-val (if (> (len extra) 1) (nth extra 1) nil))) (do - (for-each - (fn - (el) - (if - with-val - (dom-set-attr el name with-val) - (dom-remove-attr el name))) - els) + (when + with-val + (for-each (fn (el) (dom-set-attr el name with-val)) els)) (if attr-val (dom-set-attr target name attr-val)