Enable boolean behavior of any attribute

This commit is contained in:
paku 2024-03-13 16:15:51 +09:00
parent 4dfde01ac1
commit 0d51c5ec63

View file

@ -23,11 +23,6 @@
(defun ,(alx:symbolicate name '-p) (symbol) (defun ,(alx:symbolicate name '-p) (symbol)
(gethash (alx:make-keyword (string-upcase symbol)) ,ht)))))) (gethash (alx:make-keyword (string-upcase symbol)) ,ht))))))
(define-group boolean-attr-key
allowfullscreen async autofocus autoplay checked controls default defer
disabled formnovalidate inert ismap itemscope loop multiple muted nomodule
novalidate open playsinline readonly required reversed selected)
(define-group self-closing-tag (define-group self-closing-tag
area base br col embed hr img input keygen area base br col embed hr img input keygen
link meta param source track wbr) link meta param source track wbr)
@ -39,8 +34,7 @@
(defmethod print-object ((attrs elm:attrs) stream) (defmethod print-object ((attrs elm:attrs) stream)
(loop (loop
:for (key . value) :in (elm:attrs-alist attrs) :for (key . value) :in (elm:attrs-alist attrs)
:do (format stream (if (and (boolean-attr-key-p key) :do (format stream (if (typep value 'boolean)
(typep value 'boolean))
"~@[ ~a~]" "~@[ ~a~]"
" ~a=~s") " ~a=~s")
(string-downcase key) (string-downcase key)