From 988aa8d67232ba9e58e42021561a4e0044b0f291 Mon Sep 17 00:00:00 2001 From: paku Date: Sat, 25 May 2024 20:09:09 +0900 Subject: [PATCH] Return itself when the html element is expanded --- src/element.lisp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/element.lisp b/src/element.lisp index 09c41e4..22b18db 100644 --- a/src/element.lisp +++ b/src/element.lisp @@ -21,6 +21,15 @@ (and children (list :children (flatten children)))))) +(defmethod expand ((elm element)) + (with-accessors ((kind element-kind) + (props element-props)) elm + (if (functionp kind) + (apply kind props) + elm))) + +;;;; utils + (defun flatten (x) (labels ((rec (x acc) (cond ((null x) acc) @@ -29,10 +38,3 @@ (car x) (rec (cdr x) acc)))))) (rec x nil))) - -(defmethod expand ((elm element)) - (with-accessors ((kind element-kind) - (props element-props)) elm - (if (functionp kind) - (apply kind props) - (error "element-kind is not a function."))))