Created
September 4, 2014 00:02
-
-
Save GarrettS/1fb0709bb03e8d5bae25 to your computer and use it in GitHub Desktop.
Revisions
-
GarrettS created this gist
Sep 4, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ function matchesSelector(el, selectorText, ctx) { var all = (ctx||el.ownerDocument).querySelectorAll(selectorText); return indexOf(all, el) != -1; } function findAncestor(el, selectorText, container) { if(el == null || el === container) return null; var parent = el.parentNode; while(parent && parent != container) { if(matchesSelector(parent, selectorText, container)) { return parent; } parent = parent.parentNode; } return null; }