diff options
author | Lars Magne Ingebrigtsen <larsi@gnus.org> | 2015-02-22 13:09:30 +0100 |
---|---|---|
committer | Lars Magne Ingebrigtsen <larsi@gnus.org> | 2015-02-22 13:09:54 +0100 |
commit | f113707a071b5b35224861ddba3db881d74a164e (patch) | |
tree | a5fe8fcd9ede2ba4096042b91bb24bcd36a4a00a /lisp/dom.el | |
parent | 4a5190ff48f0ec376b014f00bf3171e08ed55a25 (diff) | |
download | emacs-f113707a071b5b35224861ddba3db881d74a164e.tar.gz |
* lisp/dom.el (dom-previous-sibling): New function.
Diffstat (limited to 'lisp/dom.el')
-rw-r--r-- | lisp/dom.el | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lisp/dom.el b/lisp/dom.el index 11357e88804..42131073a04 100644 --- a/lisp/dom.el +++ b/lisp/dom.el @@ -149,6 +149,16 @@ ATTRIBUTE would typically be `class', `id' or the like." (setq result (dom-parent elem node)))) result))) +(defun dom-previous-sibling (dom node) + (when-let (parent (dom-parent dom node)) + (let ((siblings (dom-children parent)) + (previous nil)) + (while siblings + (when (eq (cadr siblings) node) + (setq previous (car siblings))) + (pop siblings)) + previous))) + (defun dom-node (tag &optional attributes &rest children) "Return a DOM node with TAG and ATTRIBUTES." (if children |