diff options
author | Lars Magne Ingebrigtsen <larsi@gnus.org> | 2016-06-27 22:20:29 +0200 |
---|---|---|
committer | Lars Magne Ingebrigtsen <larsi@gnus.org> | 2016-06-27 22:20:29 +0200 |
commit | 54fe3b6ec0557941c5759523b36bfdec21003f77 (patch) | |
tree | 38ff9783ea0ff9894e627871c7b627fefaa2be51 /lisp/dom.el | |
parent | 44caa96dc5c16cbc4ee1bb26ec880af2e2ecf9f8 (diff) | |
download | emacs-54fe3b6ec0557941c5759523b36bfdec21003f77.tar.gz emacs-54fe3b6ec0557941c5759523b36bfdec21003f77.tar.bz2 emacs-54fe3b6ec0557941c5759523b36bfdec21003f77.zip |
Add new function dom-remove-node
* doc/lispref/text.texi (Document Object Model): Document
dom-remove-node.
* lisp/dom.el (dom-remove-node): New function.
Diffstat (limited to 'lisp/dom.el')
-rw-r--r-- | lisp/dom.el | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lisp/dom.el b/lisp/dom.el index 03fe75975a4..cf3a02a51db 100644 --- a/lisp/dom.el +++ b/lisp/dom.el @@ -139,6 +139,16 @@ ATTRIBUTE would typically be `class', `id' or the like." (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)) @@ -151,6 +161,7 @@ ATTRIBUTE would typically be `class', `id' or the like." 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)) |