X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/294127e7d59a5d23a32561716a1b192db410e12f..3ef311678b1467d6e6852cbc509fb92917f6f449:/lisp/dom.el diff --git a/lisp/dom.el b/lisp/dom.el index 11357e8880..091197a8f9 100644 --- a/lisp/dom.el +++ b/lisp/dom.el @@ -25,6 +25,7 @@ ;;; Code: (require 'cl-lib) +(eval-when-compile (require 'subr-x)) (defsubst dom-tag (node) "Return the NODE tag." @@ -149,6 +150,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