Advertisement
Shinmera

Cream Lisp: Find All Parents

Jun 15th, 2013
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.32 KB | None | 0 0
  1. (defnodefun parents (&optional selector)
  2.   "Get the ancestors of each element, optionally filtered by a selector."
  3.     (loop for parent = (dom:parent-node node) then (dom:parent-node parent)
  4.        while (not (dom:document-p parent))
  5.        if (or (not selector) (css:node-matches? parent selector))
  6.        collect parent))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement