@item dom-parent @var{dom} @var{node}
Return the parent of @var{node} in @var{dom}.
+
+@item dom-remove @var{dom} @var{node}
+Remove @var{node} from @var{dom}.
@end table
The following are functions for altering the @acronym{DOM}.
(cons dom matches)
matches)))
+(defun dom-remove-node (dom node)
+ "Remove NODE from DOM."
+ ;; If we're removing the top level node, just return nil.
+ (dolist (child (dom-children dom))
+ (cond
+ ((eq node child)
+ (delq node dom))
+ ((not (stringp child))
+ (dom-remove-node child node)))))
+
(defun dom-parent (dom node)
"Return the parent of NODE in DOM."
(if (memq node (dom-children dom))
result)))
(defun dom-previous-sibling (dom node)
+ "Return the previous sibling of NODE in DOM."
(when-let (parent (dom-parent dom node))
(let ((siblings (dom-children parent))
(previous nil))