summaryrefslogtreecommitdiff
path: root/src/hypnotisml.lisp
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2024-06-26 22:31:17 -0700
committercolin <colin@cicadas.surf>2024-06-26 22:31:17 -0700
commit3d5657e8a2cf4baad92635a9f50783de4a2d9f0e (patch)
tree2e24ba96e4f207f886cb388a6ef63cf02973715f /src/hypnotisml.lisp
parente9f01caf33a9306d4e44cf0f601ce1736fbc2423 (diff)
Change: dom-nodes have a parent slot; update dom var
Diffstat (limited to 'src/hypnotisml.lisp')
-rw-r--r--src/hypnotisml.lisp7
1 files changed, 7 insertions, 0 deletions
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()"