Rename ...props to props

This commit is contained in:
paku 2024-04-15 22:08:57 +09:00
parent a92d3e9ea2
commit 346fc7cb6c
2 changed files with 6 additions and 6 deletions

View file

@ -17,7 +17,7 @@ It's
- `nil`: Nothing is rendered. - `nil`: Nothing is rendered.
- `t`: Only the key is rendered. - `t`: Only the key is rendered.
- non-boolean: The key/value pair is rendered. - non-boolean: The key/value pair is rendered.
- `...props`: If the properties given to a component are not declared with `define-element` macro, they are gathered into `...props` property list. This allows flexible props passing to components. - `props`: If the properties given to a component are not declared with `define-element` macro, they are gathered into `props` property list. This allows flexible props passing to components.
```lisp ```lisp
(<> (<>
@ -28,7 +28,7 @@ It's
; <div></div> ; <div></div>
(define-element view-more () (define-element view-more ()
(a ...props (a props
"View More")) "View More"))
(view-more :href "/detail" :class "m-1") (view-more :href "/detail" :class "m-1")
@ -36,7 +36,7 @@ It's
; <a href="/detail" class="m-1">View More</a> ; <a href="/detail" class="m-1">View More</a>
(define-element custom-button (variant) (define-element custom-button (variant)
(button `(:class ,variant ,@...props) (button `(:class ,variant ,@props)
children)) children))
(custom-button :type "submit" :variant "big" :onclick "doSomething()" (custom-button :type "submit" :variant "big" :onclick "doSomething()"

View file

@ -19,7 +19,7 @@
#:tag #:tag
#:children #:children
#:attrs #:attrs
#:...props #:props
#:attrs-alist #:attrs-alist
#:make-attrs #:make-attrs
#:copy-attrs #:copy-attrs
@ -223,13 +223,13 @@
(let ,(mapcar (lambda (prop) (let ,(mapcar (lambda (prop)
(list prop `(attr attrs (make-keyword ',prop)))) (list prop `(attr attrs (make-keyword ',prop))))
props) props)
(let ((...props (let ((props
(loop :for (key . value) in (attrs-alist attrs) (loop :for (key . value) in (attrs-alist attrs)
:unless (member key :unless (member key
',(mapcar #'make-keyword ',(mapcar #'make-keyword
props)) props))
:append (list key value)))) :append (list key value))))
(declare (ignorable ...props)) (declare (ignorable props))
(progn ,@body)))))))) (progn ,@body))))))))
(defmacro ,name (&body attrs-and-children) (defmacro ,name (&body attrs-and-children)
`(,',%name ,@attrs-and-children))))) `(,',%name ,@attrs-and-children)))))