Fix rendering of child elements

This commit is contained in:
paku 2024-04-15 14:13:54 +09:00
parent 4fd887fc1b
commit cde71666ee

View file

@ -129,7 +129,8 @@
((asu:alistp (first attrs-and-children)) ((asu:alistp (first attrs-and-children))
(values (make-attrs :alist (first attrs-and-children)) (values (make-attrs :alist (first attrs-and-children))
(flatten (rest attrs-and-children)))) (flatten (rest attrs-and-children))))
((listp (first attrs-and-children)) ;plist ((and (listp (first attrs-and-children))
(keywordp (first (first attrs-and-children)))) ;plist
(values (make-attrs :alist (alx:plist-alist (first attrs-and-children))) (values (make-attrs :alist (alx:plist-alist (first attrs-and-children)))
(flatten (rest attrs-and-children)))) (flatten (rest attrs-and-children))))
((hash-table-p (first attrs-and-children)) ((hash-table-p (first attrs-and-children))
@ -195,7 +196,7 @@
(let ((%name (alx:symbolicate '% name)) (let ((%name (alx:symbolicate '% name))
(attrs (gensym "attrs")) (attrs (gensym "attrs"))
(children (gensym "children")) (children (gensym "children"))
(exp-children (gensym "exp-children"))) (raw-children (gensym "raw-children")))
`(eval-when (:compile-toplevel :load-toplevel :execute) `(eval-when (:compile-toplevel :load-toplevel :execute)
(defun ,%name (&rest attrs-and-children) (defun ,%name (&rest attrs-and-children)
(multiple-value-bind (,attrs ,children) (multiple-value-bind (,attrs ,children)
@ -204,10 +205,9 @@
:tag (string-downcase ',name) :tag (string-downcase ',name)
:attrs ,attrs :attrs ,attrs
:children ,children :children ,children
:expander (lambda (tag attrs ,exp-children) :expander (lambda (tag attrs ,raw-children)
(declare (ignorable tag attrs)) (declare (ignorable tag attrs))
(let ((children (and ,exp-children (let ((children (and ,raw-children (apply #'%<> ,raw-children))))
(make-fragment :children ,exp-children))))
(declare (ignorable children)) (declare (ignorable children))
(let ,(mapcar (lambda (arg) (let ,(mapcar (lambda (arg)
(list arg `(attr attrs (alx:make-keyword ',arg)))) (list arg `(attr attrs (alx:make-keyword ',arg))))