dir.js (371B)
1 define( [ 2 "../../core" 3 ], function( jQuery ) { 4 5 "use strict"; 6 7 return function( elem, dir, until ) { 8 var matched = [], 9 truncate = until !== undefined; 10 11 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { 12 if ( elem.nodeType === 1 ) { 13 if ( truncate && jQuery( elem ).is( until ) ) { 14 break; 15 } 16 matched.push( elem ); 17 } 18 } 19 return matched; 20 }; 21 22 } );