summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hypnotisml.asd2
-rw-r--r--src/hypnotisml.lisp8
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> (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 <replace-elem> (elem innerhtml)
(let ((template (ps:ps-gensym)))