dom-add-class/remove-class: handle list-of-elements targets
'add .foo to my children' compiles to (dom-add-class (host-get me 'children') 'foo') where children is a list. Fanned out via for-each inside dom-add-class/dom-remove-class rather than calling .classList.add on the list itself. Net: add 10→13.
This commit is contained in:
@@ -261,12 +261,28 @@
|
||||
dom-add-class
|
||||
(fn
|
||||
(el cls)
|
||||
(when el (host-call (host-get el "classList") "add" cls))))
|
||||
(cond
|
||||
((nil? el) nil)
|
||||
((list? el)
|
||||
(for-each
|
||||
(fn
|
||||
(x)
|
||||
(when x (host-call (host-get x "classList") "add" cls)))
|
||||
el))
|
||||
(true (host-call (host-get el "classList") "add" cls)))))
|
||||
(define
|
||||
dom-remove-class
|
||||
(fn
|
||||
(el cls)
|
||||
(when el (host-call (host-get el "classList") "remove" cls))))
|
||||
(cond
|
||||
((nil? el) nil)
|
||||
((list? el)
|
||||
(for-each
|
||||
(fn
|
||||
(x)
|
||||
(when x (host-call (host-get x "classList") "remove" cls)))
|
||||
el))
|
||||
(true (host-call (host-get el "classList") "remove" cls)))))
|
||||
(define
|
||||
dom-has-class?
|
||||
(fn
|
||||
|
||||
Reference in New Issue
Block a user