Skip to content

Instantly share code, notes, and snippets.

@thure
Created May 1, 2014 18:42
Show Gist options
  • Save thure/bfba98957269cf38817a to your computer and use it in GitHub Desktop.
Save thure/bfba98957269cf38817a to your computer and use it in GitHub Desktop.
Finds the first parent of an element that satisfies an iterator.
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