scratch

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 124  →  ?path2? @ 125
/bower_components/jquery/src/traversing.js
@@ -1,18 +1,13 @@
define( [
define([
"./core",
"./var/indexOf",
"./traversing/var/dir",
"./traversing/var/siblings",
"./traversing/var/rneedsContext",
"./core/init",
"./traversing/findFilter",
"./selector"
], function( jQuery, indexOf, dir, siblings, rneedsContext ) {
], function( jQuery, indexOf, rneedsContext ) {
 
"use strict";
 
var rparentsprev = /^(?:parents|prev(?:Until|All))/,
 
// Methods guaranteed to produce a unique set when starting from a unique set
guaranteedUnique = {
children: true,
@@ -21,19 +16,48 @@
prev: true
};
 
jQuery.fn.extend( {
jQuery.extend({
dir: function( elem, dir, until ) {
var matched = [],
truncate = until !== undefined;
 
while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
if ( elem.nodeType === 1 ) {
if ( truncate && jQuery( elem ).is( until ) ) {
break;
}
matched.push( elem );
}
}
return matched;
},
 
sibling: function( n, elem ) {
var matched = [];
 
for ( ; n; n = n.nextSibling ) {
if ( n.nodeType === 1 && n !== elem ) {
matched.push( n );
}
}
 
return matched;
}
});
 
jQuery.fn.extend({
has: function( target ) {
var targets = jQuery( target, this ),
l = targets.length;
 
return this.filter( function() {
return this.filter(function() {
var i = 0;
for ( ; i < l; i++ ) {
if ( jQuery.contains( this, targets[ i ] ) ) {
if ( jQuery.contains( this, targets[i] ) ) {
return true;
}
}
} );
});
},
 
closest: function( selectors, context ) {
@@ -41,29 +65,27 @@
i = 0,
l = this.length,
matched = [],
targets = typeof selectors !== "string" && jQuery( selectors );
pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
jQuery( selectors, context || this.context ) :
0;
 
// Positional selectors never match, since there's no _selection_ context
if ( !rneedsContext.test( selectors ) ) {
for ( ; i < l; i++ ) {
for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
for ( ; i < l; i++ ) {
for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
// Always skip document fragments
if ( cur.nodeType < 11 && (pos ?
pos.index(cur) > -1 :
 
// Always skip document fragments
if ( cur.nodeType < 11 && ( targets ?
targets.index( cur ) > -1 :
// Don't pass non-elements to Sizzle
cur.nodeType === 1 &&
jQuery.find.matchesSelector(cur, selectors)) ) {
 
// Don't pass non-elements to Sizzle
cur.nodeType === 1 &&
jQuery.find.matchesSelector( cur, selectors ) ) ) {
 
matched.push( cur );
break;
}
matched.push( cur );
break;
}
}
}
 
return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
},
 
// Determine the position of an element within the set
@@ -89,7 +111,7 @@
 
add: function( selector, context ) {
return this.pushStack(
jQuery.uniqueSort(
jQuery.unique(
jQuery.merge( this.get(), jQuery( selector, context ) )
)
);
@@ -97,26 +119,26 @@
 
addBack: function( selector ) {
return this.add( selector == null ?
this.prevObject : this.prevObject.filter( selector )
this.prevObject : this.prevObject.filter(selector)
);
}
} );
});
 
function sibling( cur, dir ) {
while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {}
return cur;
}
 
jQuery.each( {
jQuery.each({
parent: function( elem ) {
var parent = elem.parentNode;
return parent && parent.nodeType !== 11 ? parent : null;
},
parents: function( elem ) {
return dir( elem, "parentNode" );
return jQuery.dir( elem, "parentNode" );
},
parentsUntil: function( elem, i, until ) {
return dir( elem, "parentNode", until );
return jQuery.dir( elem, "parentNode", until );
},
next: function( elem ) {
return sibling( elem, "nextSibling" );
@@ -125,22 +147,22 @@
return sibling( elem, "previousSibling" );
},
nextAll: function( elem ) {
return dir( elem, "nextSibling" );
return jQuery.dir( elem, "nextSibling" );
},
prevAll: function( elem ) {
return dir( elem, "previousSibling" );
return jQuery.dir( elem, "previousSibling" );
},
nextUntil: function( elem, i, until ) {
return dir( elem, "nextSibling", until );
return jQuery.dir( elem, "nextSibling", until );
},
prevUntil: function( elem, i, until ) {
return dir( elem, "previousSibling", until );
return jQuery.dir( elem, "previousSibling", until );
},
siblings: function( elem ) {
return siblings( ( elem.parentNode || {} ).firstChild, elem );
return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
},
children: function( elem ) {
return siblings( elem.firstChild );
return jQuery.sibling( elem.firstChild );
},
contents: function( elem ) {
return elem.contentDocument || jQuery.merge( [], elem.childNodes );
@@ -158,10 +180,9 @@
}
 
if ( this.length > 1 ) {
 
// Remove duplicates
if ( !guaranteedUnique[ name ] ) {
jQuery.uniqueSort( matched );
jQuery.unique( matched );
}
 
// Reverse order for parents* and prev-derivatives
@@ -172,7 +193,7 @@
 
return this.pushStack( matched );
};
} );
});
 
return jQuery;
} );
});