From 3d5657e8a2cf4baad92635a9f50783de4a2d9f0e Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 26 Jun 2024 22:31:17 -0700 Subject: Change: dom-nodes have a parent slot; update dom var --- src/hypnotisml.lisp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/hypnotisml.lisp') diff --git a/src/hypnotisml.lisp b/src/hypnotisml.lisp index b209fc9..b5d8823 100644 --- a/src/hypnotisml.lisp +++ b/src/hypnotisml.lisp @@ -61,6 +61,7 @@ (format stream "~{~a=~s~^ ~}" (attribs-list ob))) (def:class dom-node () + (parent :type (or null elem)) :documentation "Root class for all dom-nodes") (defun dom-node-p (x) (typep x 'dom-node)) @@ -88,6 +89,12 @@ (children :type node-list) :documentation "The base class for all UI elements.") +(defmethod initialize-instance :around ((elem elem) &key) + (call-next-method) + (loop :for child :in (children elem) + :do (setf (parent child) elem)) + elem) + (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()" -- cgit v1.2.3