Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libs/bower_components/jquery/src/traversing.js')
-rw-r--r--libs/bower_components/jquery/src/traversing.js127
1 files changed, 51 insertions, 76 deletions
diff --git a/libs/bower_components/jquery/src/traversing.js b/libs/bower_components/jquery/src/traversing.js
index ee3676963a..0d4c1c4c36 100644
--- a/libs/bower_components/jquery/src/traversing.js
+++ b/libs/bower_components/jquery/src/traversing.js
@@ -1,13 +1,17 @@
-define([
+define( [
"./core",
+ "./var/indexOf",
+ "./traversing/var/dir",
+ "./traversing/var/siblings",
"./traversing/var/rneedsContext",
"./core/init",
"./traversing/findFilter",
"./selector"
-], function( jQuery, rneedsContext ) {
+], function( jQuery, indexOf, dir, siblings, rneedsContext ) {
var rparentsprev = /^(?:parents|prev(?:Until|All))/,
- // methods guaranteed to produce a unique set when starting from a unique set
+
+ // Methods guaranteed to produce a unique set when starting from a unique set
guaranteedUnique = {
children: true,
contents: true,
@@ -15,46 +19,19 @@ var rparentsprev = /^(?:parents|prev(?:Until|All))/,
prev: true
};
-jQuery.extend({
- dir: function( elem, dir, until ) {
- var matched = [],
- cur = elem[ dir ];
-
- while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
- if ( cur.nodeType === 1 ) {
- matched.push( cur );
- }
- cur = cur[dir];
- }
- return matched;
- },
-
- sibling: function( n, elem ) {
- var r = [];
-
- for ( ; n; n = n.nextSibling ) {
- if ( n.nodeType === 1 && n !== elem ) {
- r.push( n );
- }
- }
-
- return r;
- }
-});
-
-jQuery.fn.extend({
+jQuery.fn.extend( {
has: function( target ) {
- var i,
- targets = jQuery( target, this ),
- len = targets.length;
+ var targets = jQuery( target, this ),
+ l = targets.length;
- return this.filter(function() {
- for ( i = 0; i < len; i++ ) {
- if ( jQuery.contains( this, targets[i] ) ) {
+ return this.filter( function() {
+ var i = 0;
+ for ( ; i < l; i++ ) {
+ if ( jQuery.contains( this, targets[ i ] ) ) {
return true;
}
}
- });
+ } );
},
closest: function( selectors, context ) {
@@ -67,14 +44,15 @@ jQuery.fn.extend({
0;
for ( ; i < l; i++ ) {
- for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
+ for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
+
// Always skip document fragments
- if ( cur.nodeType < 11 && (pos ?
- pos.index(cur) > -1 :
+ if ( cur.nodeType < 11 && ( pos ?
+ pos.index( cur ) > -1 :
// Don't pass non-elements to Sizzle
cur.nodeType === 1 &&
- jQuery.find.matchesSelector(cur, selectors)) ) {
+ jQuery.find.matchesSelector( cur, selectors ) ) ) {
matched.push( cur );
break;
@@ -82,32 +60,33 @@ jQuery.fn.extend({
}
}
- return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
+ return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
},
- // Determine the position of an element within
- // the matched set of elements
+ // Determine the position of an element within the set
index: function( elem ) {
// No argument, return index in parent
if ( !elem ) {
- return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
+ return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
}
- // index in selector
+ // Index in selector
if ( typeof elem === "string" ) {
- return jQuery.inArray( this[0], jQuery( elem ) );
+ return indexOf.call( jQuery( elem ), this[ 0 ] );
}
// Locate the position of the desired element
- return jQuery.inArray(
+ return indexOf.call( this,
+
// If it receives a jQuery object, the first element is used
- elem.jquery ? elem[0] : elem, this );
+ elem.jquery ? elem[ 0 ] : elem
+ );
},
add: function( selector, context ) {
return this.pushStack(
- jQuery.unique(
+ jQuery.uniqueSort(
jQuery.merge( this.get(), jQuery( selector, context ) )
)
);
@@ -115,29 +94,26 @@ jQuery.fn.extend({
addBack: function( selector ) {
return this.add( selector == null ?
- this.prevObject : this.prevObject.filter(selector)
+ this.prevObject : this.prevObject.filter( selector )
);
}
-});
+} );
function sibling( cur, dir ) {
- do {
- cur = cur[ dir ];
- } while ( cur && 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 jQuery.dir( elem, "parentNode" );
+ return dir( elem, "parentNode" );
},
parentsUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "parentNode", until );
+ return dir( elem, "parentNode", until );
},
next: function( elem ) {
return sibling( elem, "nextSibling" );
@@ -146,55 +122,54 @@ jQuery.each({
return sibling( elem, "previousSibling" );
},
nextAll: function( elem ) {
- return jQuery.dir( elem, "nextSibling" );
+ return dir( elem, "nextSibling" );
},
prevAll: function( elem ) {
- return jQuery.dir( elem, "previousSibling" );
+ return dir( elem, "previousSibling" );
},
nextUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "nextSibling", until );
+ return dir( elem, "nextSibling", until );
},
prevUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "previousSibling", until );
+ return dir( elem, "previousSibling", until );
},
siblings: function( elem ) {
- return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
+ return siblings( ( elem.parentNode || {} ).firstChild, elem );
},
children: function( elem ) {
- return jQuery.sibling( elem.firstChild );
+ return siblings( elem.firstChild );
},
contents: function( elem ) {
- return jQuery.nodeName( elem, "iframe" ) ?
- elem.contentDocument || elem.contentWindow.document :
- jQuery.merge( [], elem.childNodes );
+ return elem.contentDocument || jQuery.merge( [], elem.childNodes );
}
}, function( name, fn ) {
jQuery.fn[ name ] = function( until, selector ) {
- var ret = jQuery.map( this, fn, until );
+ var matched = jQuery.map( this, fn, until );
if ( name.slice( -5 ) !== "Until" ) {
selector = until;
}
if ( selector && typeof selector === "string" ) {
- ret = jQuery.filter( selector, ret );
+ matched = jQuery.filter( selector, matched );
}
if ( this.length > 1 ) {
+
// Remove duplicates
if ( !guaranteedUnique[ name ] ) {
- ret = jQuery.unique( ret );
+ jQuery.uniqueSort( matched );
}
// Reverse order for parents* and prev-derivatives
if ( rparentsprev.test( name ) ) {
- ret = ret.reverse();
+ matched.reverse();
}
}
- return this.pushStack( ret );
+ return this.pushStack( matched );
};
-});
+} );
return jQuery;
-});
+} );