From ff8ecada916d5b369ee224ce17e8a3ef62410d84 Mon Sep 17 00:00:00 2001 From: paku Date: Sun, 4 Feb 2024 19:50:23 +0900 Subject: [PATCH] Remove unnecessary codes --- src/element-belongs-to.lisp | 167 ------------------------------------ src/piccolo.lisp | 4 +- src/util.lisp | 11 +-- t/piccolo.lisp | 18 +--- 4 files changed, 4 insertions(+), 196 deletions(-) delete mode 100644 src/element-belongs-to.lisp diff --git a/src/element-belongs-to.lisp b/src/element-belongs-to.lisp deleted file mode 100644 index b8a4969..0000000 --- a/src/element-belongs-to.lisp +++ /dev/null @@ -1,167 +0,0 @@ -(in-package :piccolo) - -(defparameter *attribute-belongs-to* - '((accept input) - (accept-charset form) - (accesskey *) - (action form) - (alt area img input) - (async script) - (autocomplete form input) - (autofocus button input select textarea) - (autoplay audio video) - (charset meta script) - (checked input) - (cite blockquote del ins q) - (class *) - (cols textarea) - (colspan td th) - (content meta) - (contenteditable *) - (controls audio video) - (coords area) - (data object) - (data-* *) - (datetime del ins time) - (default track) - (defer script) - (dir *) - (dirname input textarea) - (disabled button fieldset input optgroup option select textarea) - (download a area) - (draggable *) - (dropzone *) - (enctype form) - (for label output) - (form button fieldset input label meter object output select textarea) - (formaction button input) - (headers td th) - (height canvas embed iframe img input object video) - (hidden *) - (high meter) - (href a area base link) - (hreflang a area link) - (http-equiv meta) - (id *) - (ismap img) - (kind track) - (label track option optgroup) - (lang *) - (list input) - (loop audio video) - (low meter) - (max input meter progress) - (maxlength input textarea) - (media a area link source style) - (method form) - (min input meter) - (multiple input select) - (muted video audio) - (name button fieldset form iframe input map meta object output param select textarea) - (novalidate form) - (onabort audio embed img object video) - (onafterprint body) - (onbeforeprint body) - (onbeforeunload body) - (onblur All visible elements.) - (oncanplay audio embed object video) - (oncanplaythrough audio video) - (onchange All visible elements.) - (onclick All visible elements.) - (oncontextmenu All visible elements.) - (oncopy All visible elements.) - (oncuechange track) - (oncut +) - (ondblclick +) - (ondrag +) - (ondragend +) - (ondragenter +) - (ondragleave +) - (ondragover +) - (ondragstart +) - (ondrop +) - (ondurationchange audio video) - (onemptied audio video) - (onended audio video) - (onerror audio body embed img object script style video) - (onfocus +) - (onhashchange body) - (oninput +) - (oninvalid +) - (onkeydown +) - (onkeypress +) - (onkeyup +) - (onload body iframe img input link script style) - (onloadeddata audio video) - (onloadedmetadata audio video) - (onloadstart audio video) - (onmousedown +) - (onmousemove +) - (onmouseout +) - (onmouseover +) - (onmouseup +) - (onmousewheel +) - (onoffline body) - (ononline body) - (onpagehide body) - (onpageshow body) - (onpaste +) - (onpause audio video) - (onplay audio video) - (onplaying audio video) - (onpopstate body) - (onprogress audio video) - (onratechange audio video) - (onreset form) - (onresize body) - (onscroll +) - (onsearch input) - (onseeked audio video) - (onseeking audio video) - (onselect +) - (onstalled audio video) - (onstorage body) - h(onsubmit form) - (onsuspend audio video) - (ontimeupdate audio video) - (ontoggle details) - (onunload body) - (onvolumechange audio video) - (onwaiting audio video) - (onwheel +) - (open details) - (optimum meter) - (pattern input) - (placeholder input textarea) - (poster video) - (preload audio video) - (readonly input textarea) - (rel a area link) - (required input select textarea) - (reversed ol) - (rows textarea) - (rowspan td th) - (sandbox iframe) - (scope th) - (selected option) - (shape area) - (size input select) - (sizes img link source) - (span col colgroup) - (spellcheck *) - (src audio embed iframe img input script source track video) - (srcdoc iframe) - (srclang track) - (srcset img source) - (start ol) - (step input) - (style *) - (tabindex *) - (target a area base form) - (title *) - (translate *) - (type button embed input link menu object script source style) - (usemap img object) - (value button input li option meter progress param) - (width canvas embed iframe img input object video) - (wrap textarea))) diff --git a/src/piccolo.lisp b/src/piccolo.lisp index e50c0eb..bcbdd4f 100644 --- a/src/piccolo.lisp +++ b/src/piccolo.lisp @@ -119,7 +119,7 @@ When given :ASCII and :ATTR, it's possible to insert html text as a children, e. (defmethod print-object ((attrs attrs) stream) (if (attrs-alist attrs) - (format stream " ~{~a=~s~^ ~}" (alist-plist* (attrs-alist attrs))) + (format stream " ~{~a=~s~^ ~}" (alist-plist (attrs-alist attrs))) (format stream ""))) (defun self-closing-p (element) @@ -180,7 +180,7 @@ When given :ASCII and :ATTR, it's possible to insert html text as a children, e. (call-next-method))) (defun html-element-p (x) - (and (symbolp x) (not (keywordp x)) (gethash (collect-name-as-keyword x) *builtin-elements*))) + (and (symbolp x) (not (keywordp x)) (gethash (make-keyword x) *builtin-elements*))) (defmacro h (&body body) `(progn diff --git a/src/util.lisp b/src/util.lisp index d85aef0..f47cd4f 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -4,7 +4,7 @@ (loop for (k v) on plist by #'cddr collect (cons k v))) -(defun alist-plist* (alist) +(defun alist-plist (alist) (mapcan (lambda (kv) (list (string-downcase (car kv)) (cdr kv))) @@ -117,12 +117,3 @@ (setf (attr attrs :class) (format nil "~a ~a" class other-class)) (setf (attr attrs :class) class))) (values attrs children)))) - -(defun collect-until-dot-or-sharp (string) - (let ((pos (position-if (lambda (c) (or (char= c #\.) (char= c #\#))) string))) - (if pos - (cons (subseq string 0 pos) (subseq string pos)) - (cons string "")))) - -(defun collect-name-as-keyword (symbol) - (make-keyword (car (collect-until-dot-or-sharp (string symbol))))) diff --git a/t/piccolo.lisp b/t/piccolo.lisp index 5812102..80a268e 100644 --- a/t/piccolo.lisp +++ b/t/piccolo.lisp @@ -371,22 +371,6 @@ " (element-string (h (duck :id 5 :color "blue" - (img :href "duck.png")))))) - (is (string= - "
child
" - (element-string - (h (div#has-id.class1.class2 "child"))))) - (is (string= - "
child
" - (element-string - (h (div#has-id.class1.class2 :onclick "func()" "child"))))) - (is (string= - "
child
" - (element-string - (h (div#has-id.class1.class2 '(:onclick "func()") "child"))))) - (is (string= - "
child
" - (element-string - (h (div.class1#has-id.class2 ':class "additional-class" "child"))))))) + (img :href "duck.png")))))))) (run-all-tests)