From b6d59c01066ab2315e84fe7eb5659e376e56de1b Mon Sep 17 00:00:00 2001 From: colin Date: Sat, 22 Jun 2024 14:53:18 -0700 Subject: Add: parenscript dep; Fix: html elem render; Fix: --- hypnotisml.asd | 2 +- src/hypnotisml.lisp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hypnotisml.asd b/hypnotisml.asd index 28fb47c..53be346 100644 --- a/hypnotisml.asd +++ b/hypnotisml.asd @@ -7,6 +7,6 @@ :version "0.0.1" :pathname "src/" :serial t - :depends-on (#:def #:alexandria) + :depends-on (#:def #:alexandria #:parenscript) :components ((:file "package") (:file "hypnotisml"))) diff --git a/src/hypnotisml.lisp b/src/hypnotisml.lisp index 5b0a7dd..d39844a 100644 --- a/src/hypnotisml.lisp +++ b/src/hypnotisml.lisp @@ -81,6 +81,9 @@ (children :type node-list) :documentation "The base class for all UI elements.") +(defun elem-query-selector (elem) + (format nil "[data-hypno-id=~s]" (elem-id elemp))) + (defmethod print-object ((object elem) stream) (indent stream) @@ -168,8 +171,7 @@ (format t " ~{~a=~s~^ ~}" (attribs-list attributes))) (when (and style (styles-list style)) - (when attributes (write-char #\space)) - (write-string "style=") + (write-string " style=") (write-char #\") (format t "~{~a:~a;~}" (styles-list style)) (write-char #\")) @@ -412,7 +414,7 @@ ;;; Parenscript (ps:defpsmacro (elem) - `(ps:@ document (get-element-by-id (ps:lisp (elem-id ,elem))))) + `(ps:chain document (query-selector (ps:lisp (elem-query-selector ,elem))))) (ps:defpsmacro (elem innerhtml) (let ((template (ps:ps-gensym))) -- cgit v1.2.3