dir.js 371 B

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