summaryrefslogtreecommitdiff
path: root/src/hypnotisml.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hypnotisml.lisp')
-rw-r--r--src/hypnotisml.lisp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/hypnotisml.lisp b/src/hypnotisml.lisp
index ab06b6f..b70a8a8 100644
--- a/src/hypnotisml.lisp
+++ b/src/hypnotisml.lisp
@@ -89,12 +89,19 @@
(children :type node-list)
:documentation "The base class for all UI elements.")
+(defun ensure-parent (parent nodes)
+ (loop :for node :in nodes :do (setf (parent node) parent)))
+
(defmethod initialize-instance :around ((elem elem) &key)
(call-next-method)
- (loop :for child :in (children elem)
- :do (setf (parent child) elem))
+ (ensure-parent elem (children elem))
elem)
+;; WARNING... THIS'LL SLOW YA DOWN
+(defmethod (setf children) :after (new-children (elem elem))
+ (ensure-parent elem new-children))
+
+
(defun elem-query-selector (elem)
"Returns a CSS query selector string for the ELEM. ELEMs can be
uniquely quried in the dom by passing string to .querySelector()"
@@ -252,6 +259,8 @@ already present in the element."
elem)
+
+
;;; RENDERING
(defgeneric html (elem stream)
@@ -567,7 +576,7 @@ E.g. :1/2, :1, :3/4"
(defmacro <grid> (&rest content-specs)
`(<div>
($ :display "grid")
- ,@(loop :for (row col content) :in content-specs
+ ,@(loop :for ((row col) content . _) :on content-specs :by #'cddr
:unless (and (rational-name-p row)
(rational-name-p col))
:do (error "Bad thing to be a grid content spec: ~s"