Rename to expand component
This commit is contained in:
parent
7a697a1c05
commit
56c51ee0f8
2 changed files with 21 additions and 21 deletions
|
@ -4,7 +4,7 @@
|
|||
#:element-props
|
||||
#:element-children
|
||||
#:create-element
|
||||
#:expand))
|
||||
#:expand-component))
|
||||
(in-package #:hsx/element)
|
||||
|
||||
;;;; class definitions
|
||||
|
@ -61,22 +61,11 @@
|
|||
|
||||
(defmethod create-element-hook ((elm component-element))
|
||||
;dry-run to validate props
|
||||
(expand elm))
|
||||
(expand-component elm))
|
||||
|
||||
|
||||
;;;; methods
|
||||
|
||||
(defmethod expand ((elm component-element))
|
||||
(with-accessors ((type element-type)
|
||||
(props element-props)
|
||||
(children element-children)) elm
|
||||
(apply type (merge-children-into-props props children))))
|
||||
|
||||
(defun merge-children-into-props (props children)
|
||||
(append props
|
||||
(and children
|
||||
(list :children children))))
|
||||
|
||||
(defmethod print-object ((elm tag-element) stream)
|
||||
(with-accessors ((type element-type)
|
||||
(props element-props)
|
||||
|
@ -117,4 +106,15 @@
|
|||
children))))
|
||||
|
||||
(defmethod print-object ((elm component-element) stream)
|
||||
(print-object (expand elm) stream))
|
||||
(print-object (expand-component elm) stream))
|
||||
|
||||
(defmethod expand-component ((elm component-element))
|
||||
(with-accessors ((type element-type)
|
||||
(props element-props)
|
||||
(children element-children)) elm
|
||||
(apply type (merge-children-into-props props children))))
|
||||
|
||||
(defun merge-children-into-props (props children)
|
||||
(append props
|
||||
(and children
|
||||
(list :children children))))
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
(let* ((elm (create-element #'comp1
|
||||
'(:title "foo")
|
||||
"bar"))
|
||||
(expanded (expand elm)))
|
||||
(expanded (expand-component elm)))
|
||||
(is (eql (element-type elm) #'comp1))
|
||||
(is (equal (element-props elm) '(:title "foo")))
|
||||
(is (equal (element-children elm) (list "bar")))
|
||||
|
@ -56,7 +56,7 @@
|
|||
(let* ((elm (create-element #'comp2
|
||||
'(:title "foo")
|
||||
"bar"))
|
||||
(expanded (expand elm)))
|
||||
(expanded (expand-component elm)))
|
||||
(is (eql (element-type elm) #'comp2))
|
||||
(is (equal (element-props elm) '(:title "foo")))
|
||||
(is (equal (element-children elm) (list "bar")))
|
||||
|
@ -81,7 +81,7 @@
|
|||
(let* ((elm (create-element #'comp3
|
||||
'(:title "foo" :other-key "baz")
|
||||
"bar"))
|
||||
(expanded (expand elm)))
|
||||
(expanded (expand-component elm)))
|
||||
(is (eql (element-type elm) #'comp3))
|
||||
(is (equal (element-props elm) '(:title "foo" :other-key "baz")))
|
||||
(is (equal (element-children elm) (list "bar")))
|
||||
|
|
Loading…
Reference in a new issue