From b7da7a19e98b80fdf044d3e910d866e464653b85 Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 28 Jun 2024 23:00:16 -0700 Subject: reorg --- src/hypnotisml.lisp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/hypnotisml.lisp') 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 (&rest content-specs) `(
($ :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" -- cgit v1.2.3