HS take command: class/attr with+giving, attr removal from scope, giving keyword
- tokenizer: add 'giving' as keyword so parse-take-cmd can detect it.
- parser.sx parse-take-cmd: loop over 'with <class>' / 'giving <class>' /
'from <sel>' / 'for <tgt>' clauses in any order for both the class and
attribute cases. Emits uniform (take! kind name from-sel for-tgt
attr-val with-val) 7-slot AST.
- compiler emit-take: pass with-cls for the class case through to runtime.
- runtime hs-take!: with a class 'with' replacement, toggle both classes
across scope + target. For attribute take, always strip the attr from
the scope 'others' (setting to with-val if given, otherwise removing).
- generator pw-body: translate evaluate(() => document.querySelector(s).
click()) and .dispatchEvent(new Event('name', …)) into dom-dispatch ops
so bubbling-click assertions in 'parent takes…' tests work.
- generator toHaveClass: strip JS regex word-boundaries (\\b) from the
expected class name.
- shared/static/wasm/sx/dom.sx: dom-child-list / dom-child-nodes mirror
the dom-query-all SX-list passthrough — childNodes arrives pre-SXified.
Net: take 6→15 (100%), remove 16→17, fetch 11→15.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -146,16 +146,32 @@
|
||||
((els (if scope (if (list? scope) scope (list scope)) (let ((parent (dom-parent target))) (if parent (dom-child-list parent) (list))))))
|
||||
(if
|
||||
(= kind "class")
|
||||
(do
|
||||
(for-each (fn (el) (dom-remove-class el name)) els)
|
||||
(dom-add-class target name))
|
||||
(let
|
||||
((with-cls (if (> (len extra) 1) (nth extra 1) nil)))
|
||||
(do
|
||||
(for-each
|
||||
(fn
|
||||
(el)
|
||||
(do
|
||||
(dom-remove-class el name)
|
||||
(when with-cls (dom-add-class el with-cls))))
|
||||
els)
|
||||
(dom-add-class target name)
|
||||
(when with-cls (dom-remove-class target with-cls))))
|
||||
(let
|
||||
((attr-val (if (> (len extra) 0) (first extra) nil))
|
||||
(with-val (if (> (len extra) 1) (nth extra 1) nil)))
|
||||
(do
|
||||
(when
|
||||
with-val
|
||||
(for-each (fn (el) (dom-set-attr el name with-val)) els))
|
||||
(for-each
|
||||
(fn
|
||||
(el)
|
||||
(when
|
||||
(not (= el target))
|
||||
(if
|
||||
with-val
|
||||
(dom-set-attr el name with-val)
|
||||
(dom-remove-attr el name))))
|
||||
els)
|
||||
(if
|
||||
attr-val
|
||||
(dom-set-attr target name attr-val)
|
||||
|
||||
Reference in New Issue
Block a user