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:
@@ -308,42 +308,54 @@
|
||||
(fn
|
||||
(el)
|
||||
"Return child nodes as an SX list."
|
||||
(if
|
||||
el
|
||||
(let
|
||||
((nl (host-get el "childNodes"))
|
||||
(n (host-get nl "length"))
|
||||
(result (list)))
|
||||
(cond
|
||||
((nil? el) (list))
|
||||
(true
|
||||
(let
|
||||
loop
|
||||
((i 0))
|
||||
(when
|
||||
(< i n)
|
||||
(append! result (host-call nl "item" i))
|
||||
(loop (+ i 1))))
|
||||
result)
|
||||
(list))))
|
||||
((nl (host-get el "childNodes")))
|
||||
(cond
|
||||
((nil? nl) (list))
|
||||
((list? nl) nl)
|
||||
(true
|
||||
(let
|
||||
((n (host-get nl "length")) (result (list)))
|
||||
(when
|
||||
(not (nil? n))
|
||||
(let
|
||||
loop
|
||||
((i 0))
|
||||
(when
|
||||
(< i n)
|
||||
(append! result (host-call nl "item" i))
|
||||
(loop (+ i 1)))))
|
||||
result))))))))
|
||||
(define dom-is-fragment? (fn (el) (= (host-get el "nodeType") 11)))
|
||||
(define
|
||||
dom-child-nodes
|
||||
(fn
|
||||
(el)
|
||||
"Return child nodes as an SX list."
|
||||
(if
|
||||
el
|
||||
(let
|
||||
((nl (host-get el "childNodes"))
|
||||
(n (host-get nl "length"))
|
||||
(result (list)))
|
||||
(cond
|
||||
((nil? el) (list))
|
||||
(true
|
||||
(let
|
||||
loop
|
||||
((i 0))
|
||||
(when
|
||||
(< i n)
|
||||
(append! result (host-call nl "item" i))
|
||||
(loop (+ i 1))))
|
||||
result)
|
||||
(list))))
|
||||
((nl (host-get el "childNodes")))
|
||||
(cond
|
||||
((nil? nl) (list))
|
||||
((list? nl) nl)
|
||||
(true
|
||||
(let
|
||||
((n (host-get nl "length")) (result (list)))
|
||||
(when
|
||||
(not (nil? n))
|
||||
(let
|
||||
loop
|
||||
((i 0))
|
||||
(when
|
||||
(< i n)
|
||||
(append! result (host-call nl "item" i))
|
||||
(loop (+ i 1)))))
|
||||
result))))))))
|
||||
(define
|
||||
dom-remove-children-after
|
||||
(fn
|
||||
|
||||
Reference in New Issue
Block a user