From 42a0828f896945865809920b1d5ed691571dfb47 Mon Sep 17 00:00:00 2001 From: paku Date: Sun, 26 May 2024 01:29:58 +0900 Subject: [PATCH] Rename kind to type --- src/element.lisp | 18 +++++++++--------- tests/element.lisp | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/element.lisp b/src/element.lisp index 8fab306..7a74346 100644 --- a/src/element.lisp +++ b/src/element.lisp @@ -1,6 +1,6 @@ (defpackage #:hsx/element (:use #:cl) - (:export #:element-kind + (:export #:element-type #:element-props #:element-children #:create-element @@ -8,9 +8,9 @@ (in-package #:hsx/element) (defclass element () - ((kind - :reader element-kind - :initarg :kind) + ((type + :reader element-type + :initarg :type) (props :reader element-props :initarg :props) @@ -18,18 +18,18 @@ :reader element-children :initarg :children))) -(defun create-element (kind props &rest children) +(defun create-element (type props &rest children) (make-instance 'element - :kind kind + :type type :props props :children (flatten children))) (defmethod expand ((elm element)) - (with-accessors ((kind element-kind) + (with-accessors ((type element-type) (props element-props) (children element-children)) elm - (if (functionp kind) - (apply kind (append props + (if (functionp type) + (apply type (append props (and children (list :children children)))) elm))) diff --git a/tests/element.lisp b/tests/element.lisp index b73b944..a7d9666 100644 --- a/tests/element.lisp +++ b/tests/element.lisp @@ -16,10 +16,10 @@ nil "Hello," inner))) - (is (string= (element-kind inner) "span")) + (is (string= (element-type inner) "span")) (is (equal (element-props inner) `(:class "red"))) (is (equal (element-children inner) (list "World!"))) - (is (string= (element-kind outer) "p")) + (is (string= (element-type outer) "p")) (is (null (element-props outer))) (is (equal (element-children outer) (list "Hello," inner))))) @@ -44,10 +44,10 @@ (outer (create-element #'comp '(:variant "red") inner))) - (is (eql (element-kind outer) #'comp)) + (is (eql (element-type outer) #'comp)) (is (equal (element-props outer) `(:variant "red"))) (is (equal (element-children outer) (list inner))) (let ((expanded-elm (expand outer))) - (is (string= (element-kind expanded-elm) "p")) + (is (string= (element-type expanded-elm) "p")) (is (equal (element-props expanded-elm) `(:class "red"))) (is (equal (element-children expanded-elm) (list "Hello," inner)))))))