2010-09-08 19:54:33 +02:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2009-12-04 18:28:47 +01:00
|
|
|
var runtil = /Until$/,
|
|
|
|
rparentsprev = /^(?:parents|prevUntil|prevAll)/,
|
|
|
|
// Note: This RegExp should be improved, or likely pulled from Sizzle
|
2010-03-23 17:12:16 +01:00
|
|
|
rmultiselector = /,/,
|
|
|
|
isSimple = /^.[^:#\[\.,]*$/,
|
2010-10-10 21:36:02 +02:00
|
|
|
slice = Array.prototype.slice,
|
2011-01-14 15:55:40 +01:00
|
|
|
POS = jQuery.expr.match.POS,
|
|
|
|
// methods guaranteed to produce a unique set when starting from a unique set
|
|
|
|
guaranteedUnique = {
|
|
|
|
children: true,
|
|
|
|
contents: true,
|
|
|
|
next: true,
|
|
|
|
prev: true
|
|
|
|
};
|
2010-10-10 06:33:02 +02:00
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
jQuery.fn.extend({
|
|
|
|
find: function( selector ) {
|
2011-03-16 06:16:32 +01:00
|
|
|
var self = this,
|
2011-03-16 19:41:26 +01:00
|
|
|
i, l;
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2011-03-16 06:16:32 +01:00
|
|
|
if ( typeof selector !== "string" ) {
|
|
|
|
return jQuery( selector ).filter(function() {
|
|
|
|
for ( i = 0, l = self.length; i < l; i++ ) {
|
|
|
|
if ( jQuery.contains( self[ i ], this ) ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2010-11-09 17:09:07 +01:00
|
|
|
var ret = this.pushStack( "", "find", selector ),
|
2011-03-16 19:41:26 +01:00
|
|
|
length, n, r;
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2011-03-16 06:16:32 +01:00
|
|
|
for ( i = 0, l = this.length; i < l; i++ ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
length = ret.length;
|
|
|
|
jQuery.find( selector, this[i], ret );
|
|
|
|
|
|
|
|
if ( i > 0 ) {
|
|
|
|
// Make sure that the results are unique
|
2011-03-16 06:16:32 +01:00
|
|
|
for ( n = length; n < ret.length; n++ ) {
|
|
|
|
for ( r = 0; r < length; r++ ) {
|
2009-03-18 22:15:38 +01:00
|
|
|
if ( ret[r] === ret[n] ) {
|
|
|
|
ret.splice(n--, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
|
2009-12-09 21:43:13 +01:00
|
|
|
has: function( target ) {
|
|
|
|
var targets = jQuery( target );
|
|
|
|
return this.filter(function() {
|
|
|
|
for ( var i = 0, l = targets.length; i < l; i++ ) {
|
|
|
|
if ( jQuery.contains( this, targets[i] ) ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2009-07-16 09:32:11 +02:00
|
|
|
not: function( selector ) {
|
2009-09-15 02:35:35 +02:00
|
|
|
return this.pushStack( winnow(this, selector, false), "not", selector);
|
2009-07-16 09:32:11 +02:00
|
|
|
},
|
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
filter: function( selector ) {
|
2009-09-15 02:35:35 +02:00
|
|
|
return this.pushStack( winnow(this, selector, true), "filter", selector );
|
2009-03-18 22:15:38 +01:00
|
|
|
},
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-10 18:25:25 +01:00
|
|
|
is: function( selector ) {
|
2011-04-11 18:24:31 +02:00
|
|
|
return !!selector && ( typeof selector === "string" ?
|
2011-04-10 22:32:40 +02:00
|
|
|
jQuery.filter( selector, this ).length > 0 :
|
2011-04-11 18:24:31 +02:00
|
|
|
this.filter( selector ).length > 0 );
|
2009-12-10 18:25:25 +01:00
|
|
|
},
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-12-03 01:05:51 +01:00
|
|
|
closest: function( selectors, context ) {
|
2010-10-10 21:42:56 +02:00
|
|
|
var ret = [], i, l, cur = this[0];
|
2011-03-22 01:59:20 +01:00
|
|
|
|
|
|
|
// Array
|
2009-12-03 01:05:51 +01:00
|
|
|
if ( jQuery.isArray( selectors ) ) {
|
2010-11-09 17:09:07 +01:00
|
|
|
var match, selector,
|
|
|
|
matches = {},
|
|
|
|
level = 1;
|
2010-09-28 02:59:42 +02:00
|
|
|
|
2009-12-03 16:51:04 +01:00
|
|
|
if ( cur && selectors.length ) {
|
2010-10-10 21:42:56 +02:00
|
|
|
for ( i = 0, l = selectors.length; i < l; i++ ) {
|
2009-12-03 17:14:10 +01:00
|
|
|
selector = selectors[i];
|
|
|
|
|
2011-03-22 01:59:20 +01:00
|
|
|
if ( !matches[ selector ] ) {
|
|
|
|
matches[ selector ] = POS.test( selector ) ?
|
2009-12-03 17:14:10 +01:00
|
|
|
jQuery( selector, context || this.context ) :
|
|
|
|
selector;
|
|
|
|
}
|
2009-12-03 01:05:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
while ( cur && cur.ownerDocument && cur !== context ) {
|
2009-12-03 17:14:10 +01:00
|
|
|
for ( selector in matches ) {
|
2011-03-22 01:59:20 +01:00
|
|
|
match = matches[ selector ];
|
2009-12-03 17:05:12 +01:00
|
|
|
|
2011-03-22 01:59:20 +01:00
|
|
|
if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) {
|
2010-02-26 15:26:14 +01:00
|
|
|
ret.push({ selector: selector, elem: cur, level: level });
|
2009-12-03 01:05:51 +01:00
|
|
|
}
|
|
|
|
}
|
2010-09-28 02:59:42 +02:00
|
|
|
|
2009-12-03 01:05:51 +01:00
|
|
|
cur = cur.parentNode;
|
2010-02-26 15:26:14 +01:00
|
|
|
level++;
|
2009-12-03 01:05:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-28 02:59:42 +02:00
|
|
|
return ret;
|
2009-12-03 01:05:51 +01:00
|
|
|
}
|
|
|
|
|
2011-03-22 01:59:20 +01:00
|
|
|
// String
|
|
|
|
var pos = POS.test( selectors ) || typeof selectors !== "string" ?
|
|
|
|
jQuery( selectors, context || this.context ) :
|
|
|
|
0;
|
2010-09-28 02:59:42 +02:00
|
|
|
|
2010-10-10 21:42:56 +02:00
|
|
|
for ( i = 0, l = this.length; i < l; i++ ) {
|
|
|
|
cur = this[i];
|
2010-10-10 06:33:02 +02:00
|
|
|
|
2010-10-10 19:37:36 +02:00
|
|
|
while ( cur ) {
|
2010-10-10 21:36:02 +02:00
|
|
|
if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
|
2010-10-10 06:33:02 +02:00
|
|
|
ret.push( cur );
|
2010-10-10 19:37:36 +02:00
|
|
|
break;
|
|
|
|
|
2010-10-10 06:33:02 +02:00
|
|
|
} else {
|
2010-10-10 19:37:36 +02:00
|
|
|
cur = cur.parentNode;
|
2011-03-31 05:39:19 +02:00
|
|
|
if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
|
2010-10-10 19:37:36 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-28 02:59:42 +02:00
|
|
|
|
2011-03-31 05:23:38 +02:00
|
|
|
ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2010-06-21 19:50:02 +02:00
|
|
|
return this.pushStack( ret, "closest", selectors );
|
2009-03-18 22:15:38 +01:00
|
|
|
},
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-10 18:25:25 +01:00
|
|
|
// Determine the position of an element within
|
|
|
|
// the matched set of elements
|
|
|
|
index: function( elem ) {
|
|
|
|
if ( !elem || typeof elem === "string" ) {
|
|
|
|
return jQuery.inArray( this[0],
|
|
|
|
// If it receives a string, the selector is used
|
|
|
|
// If it receives nothing, the siblings are used
|
|
|
|
elem ? jQuery( elem ) : this.parent().children() );
|
|
|
|
}
|
|
|
|
// Locate the position of the desired element
|
|
|
|
return jQuery.inArray(
|
|
|
|
// If it receives a jQuery object, the first element is used
|
|
|
|
elem.jquery ? elem[0] : elem, this );
|
|
|
|
},
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2009-11-07 16:43:31 +01:00
|
|
|
add: function( selector, context ) {
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 19:55:20 +02:00
|
|
|
var set = typeof selector === "string" ?
|
2010-12-29 03:07:04 +01:00
|
|
|
jQuery( selector, context ) :
|
2011-04-17 19:51:24 +02:00
|
|
|
jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 19:55:20 +02:00
|
|
|
all = jQuery.merge( this.get(), set );
|
|
|
|
|
2010-01-13 06:12:18 +01:00
|
|
|
return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
|
|
|
|
all :
|
|
|
|
jQuery.unique( all ) );
|
2009-03-18 22:15:38 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
andSelf: function() {
|
|
|
|
return this.add( this.prevObject );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-01-13 06:12:18 +01:00
|
|
|
// A painfully simple check to see if an element is disconnected
|
|
|
|
// from a document (should be improved, where feasible).
|
|
|
|
function isDisconnected( node ) {
|
|
|
|
return !node || !node.parentNode || node.parentNode.nodeType === 11;
|
|
|
|
}
|
|
|
|
|
2009-03-18 22:15:38 +01:00
|
|
|
jQuery.each({
|
2009-12-22 01:58:13 +01:00
|
|
|
parent: function( elem ) {
|
|
|
|
var parent = elem.parentNode;
|
|
|
|
return parent && parent.nodeType !== 11 ? parent : null;
|
|
|
|
},
|
|
|
|
parents: function( elem ) {
|
|
|
|
return jQuery.dir( elem, "parentNode" );
|
|
|
|
},
|
|
|
|
parentsUntil: function( elem, i, until ) {
|
|
|
|
return jQuery.dir( elem, "parentNode", until );
|
|
|
|
},
|
|
|
|
next: function( elem ) {
|
|
|
|
return jQuery.nth( elem, 2, "nextSibling" );
|
|
|
|
},
|
|
|
|
prev: function( elem ) {
|
|
|
|
return jQuery.nth( elem, 2, "previousSibling" );
|
|
|
|
},
|
|
|
|
nextAll: function( elem ) {
|
|
|
|
return jQuery.dir( elem, "nextSibling" );
|
|
|
|
},
|
|
|
|
prevAll: function( elem ) {
|
|
|
|
return jQuery.dir( elem, "previousSibling" );
|
|
|
|
},
|
|
|
|
nextUntil: function( elem, i, until ) {
|
|
|
|
return jQuery.dir( elem, "nextSibling", until );
|
|
|
|
},
|
|
|
|
prevUntil: function( elem, i, until ) {
|
|
|
|
return jQuery.dir( elem, "previousSibling", until );
|
|
|
|
},
|
|
|
|
siblings: function( elem ) {
|
|
|
|
return jQuery.sibling( elem.parentNode.firstChild, elem );
|
|
|
|
},
|
|
|
|
children: function( elem ) {
|
|
|
|
return jQuery.sibling( elem.firstChild );
|
|
|
|
},
|
|
|
|
contents: function( elem ) {
|
|
|
|
return jQuery.nodeName( elem, "iframe" ) ?
|
|
|
|
elem.contentDocument || elem.contentWindow.document :
|
|
|
|
jQuery.makeArray( elem.childNodes );
|
|
|
|
}
|
|
|
|
}, function( name, fn ) {
|
2009-12-04 18:28:47 +01:00
|
|
|
jQuery.fn[ name ] = function( until, selector ) {
|
2011-01-14 17:21:45 +01:00
|
|
|
var ret = jQuery.map( this, fn, until ),
|
2011-02-15 22:03:23 +01:00
|
|
|
// The variable 'args' was introduced in
|
|
|
|
// https://github.com/jquery/jquery/commit/52a0238
|
|
|
|
// to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
|
|
|
|
// http://code.google.com/p/v8/issues/detail?id=1050
|
|
|
|
args = slice.call(arguments);
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-04 18:28:47 +01:00
|
|
|
if ( !runtil.test( name ) ) {
|
|
|
|
selector = until;
|
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 19:55:20 +02:00
|
|
|
if ( selector && typeof selector === "string" ) {
|
2009-10-26 23:07:57 +01:00
|
|
|
ret = jQuery.filter( selector, ret );
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 19:55:20 +02:00
|
|
|
}
|
|
|
|
|
2011-01-14 15:55:40 +01:00
|
|
|
ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 19:55:20 +02:00
|
|
|
|
2009-12-04 18:28:47 +01:00
|
|
|
if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
|
A follow-up to [6578] (which stopped adding expandos to elements that didn't have data). That broke jQuery.unique() (so we're now using the unique from Sizzle). Using Sizzle's unique (which also sorts in document order) changed how add, andSelf, parents, nextAll, prevAll, and siblings work. after and before were changed to not use .add() (in order to guarantee their position in the jQuery set). Also, jQuery.data(elem) was updated to return that element's data object (instead of its ID).
$("<div/>").after("<span/>")
=> [ div, span ]
(calling after on a disconnected DOM node adds the nodes to the end of the jQuery set)
$("<div/>").before("<span/>")
=> [ span, div ]
(calling before on a disconnected DOM node adds the nodes to the beginning of the jQuery set)
$("div").add("span")
=> [ div, span, span, div, span ]
(results now come out in document order)
$("div").find("code").andSelf();
=> [ div, code, code ]
(results now come out in document order)
Same goes for .parents(), .nextAll(), .prevAll(), and .siblings().
Exception: .parents() will still return the results in reverse document order.
jQuery.data(elem)
=> { object of data }
(no longer returns the unique ID assigned to the node)
2009-09-25 19:55:20 +02:00
|
|
|
ret = ret.reverse();
|
|
|
|
}
|
2009-03-18 22:15:38 +01:00
|
|
|
|
2011-01-14 17:21:45 +01:00
|
|
|
return this.pushStack( ret, name, args.join(",") );
|
2009-03-18 22:15:38 +01:00
|
|
|
};
|
2009-07-25 23:31:59 +02:00
|
|
|
});
|
2009-10-26 23:07:57 +01:00
|
|
|
|
|
|
|
jQuery.extend({
|
|
|
|
filter: function( expr, elems, not ) {
|
|
|
|
if ( not ) {
|
|
|
|
expr = ":not(" + expr + ")";
|
|
|
|
}
|
|
|
|
|
2010-10-10 21:36:02 +02:00
|
|
|
return elems.length === 1 ?
|
|
|
|
jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
|
|
|
|
jQuery.find.matches(expr, elems);
|
2009-10-26 23:07:57 +01:00
|
|
|
},
|
2010-12-30 07:34:48 +01:00
|
|
|
|
2009-12-04 18:28:47 +01:00
|
|
|
dir: function( elem, dir, until ) {
|
2010-11-09 17:09:07 +01:00
|
|
|
var matched = [],
|
|
|
|
cur = elem[ dir ];
|
|
|
|
|
2010-01-21 02:10:34 +01:00
|
|
|
while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
|
2009-10-26 23:07:57 +01:00
|
|
|
if ( cur.nodeType === 1 ) {
|
|
|
|
matched.push( cur );
|
|
|
|
}
|
|
|
|
cur = cur[dir];
|
|
|
|
}
|
|
|
|
return matched;
|
|
|
|
},
|
|
|
|
|
|
|
|
nth: function( cur, result, dir, elem ) {
|
|
|
|
result = result || 1;
|
|
|
|
var num = 0;
|
|
|
|
|
|
|
|
for ( ; cur; cur = cur[dir] ) {
|
|
|
|
if ( cur.nodeType === 1 && ++num === result ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cur;
|
|
|
|
},
|
|
|
|
|
|
|
|
sibling: function( n, elem ) {
|
|
|
|
var r = [];
|
|
|
|
|
|
|
|
for ( ; n; n = n.nextSibling ) {
|
|
|
|
if ( n.nodeType === 1 && n !== elem ) {
|
|
|
|
r.push( n );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
2009-11-07 16:43:31 +01:00
|
|
|
});
|
2010-03-23 17:12:16 +01:00
|
|
|
|
|
|
|
// Implement the identical functionality for filter and not
|
|
|
|
function winnow( elements, qualifier, keep ) {
|
2011-04-11 17:54:55 +02:00
|
|
|
|
|
|
|
// Can't pass null or undefined to indexOf in Firefox 4
|
|
|
|
// Set to 0 to skip string check
|
|
|
|
qualifier = qualifier || 0;
|
|
|
|
|
2010-03-23 17:12:16 +01:00
|
|
|
if ( jQuery.isFunction( qualifier ) ) {
|
|
|
|
return jQuery.grep(elements, function( elem, i ) {
|
|
|
|
var retVal = !!qualifier.call( elem, i, elem );
|
|
|
|
return retVal === keep;
|
|
|
|
});
|
|
|
|
|
2011-04-11 17:54:55 +02:00
|
|
|
} else if ( qualifier.nodeType ) {
|
2010-03-23 17:12:16 +01:00
|
|
|
return jQuery.grep(elements, function( elem, i ) {
|
|
|
|
return (elem === qualifier) === keep;
|
|
|
|
});
|
|
|
|
|
|
|
|
} else if ( typeof qualifier === "string" ) {
|
|
|
|
var filtered = jQuery.grep(elements, function( elem ) {
|
|
|
|
return elem.nodeType === 1;
|
|
|
|
});
|
|
|
|
|
|
|
|
if ( isSimple.test( qualifier ) ) {
|
|
|
|
return jQuery.filter(qualifier, filtered, !keep);
|
|
|
|
} else {
|
|
|
|
qualifier = jQuery.filter( qualifier, filtered );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return jQuery.grep(elements, function( elem, i ) {
|
|
|
|
return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
|
|
|
|
});
|
2010-03-31 20:36:24 +02:00
|
|
|
}
|
2010-09-08 19:54:33 +02:00
|
|
|
|
|
|
|
})( jQuery );
|