Created
November 30, 2016 17:19
-
-
Save SvetlozarKalchev/c4c62fe9a66c19a114e4e18060b293fb to your computer and use it in GitHub Desktop.
Revisions
-
SvetlozarKalchev created this gist
Nov 30, 2016 .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,23 @@ define( [ "../../core" ], function( jQuery ) { "use strict"; return function( elem, dir, until ) { var matched = [], truncate = until !== undefined; // elem[dir] is DOMElement.parentNodes in this case. // This code goes through all parent Nodes and only pushed the node in the collection if it's a DOM node. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { if ( elem.nodeType === 1 ) { if ( truncate && jQuery( elem ).is( until ) ) { break; } matched.push( elem ); } } return matched; }; } );