1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-23 07:19:15 +00:00

* lisp/dom.el (dom-previous-sibling): New function.

This commit is contained in:
Lars Magne Ingebrigtsen 2015-02-22 13:09:30 +01:00
parent 4a5190ff48
commit f113707a07

View File

@ -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