Created
May 1, 2014 18:42
-
-
Save thure/bfba98957269cf38817a to your computer and use it in GitHub Desktop.
Finds the first parent of an element that satisfies an iterator.
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 characters
define(function(){ | |
return function(el, iterator){ | |
var cur = el; | |
while(cur.parentNode !== document.body){ | |
if(iterator.call(null, cur)){ | |
return cur | |
}else{ | |
cur = cur.parentNode; | |
} | |
} | |
return null; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment