Last active
August 29, 2015 14:07
-
-
Save ickata/4fa4605caf4fa0eef0e4 to your computer and use it in GitHub Desktop.
(MooTools) Additional method in Element.prototype - getParentLimited - traverse DOM tree up to `limit` elements; returns null if `selector` does not match
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
Element.implement({ | |
getParentLimited : function ( selector, limit ) { | |
limit = typeOf( limit ) == 'number' ? limit : 10; | |
var element = this; | |
do { | |
element = element.getParent(); | |
} while ( element && ! element.match( selector ) && --limit > 0 ); | |
return limit ? element : null; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment