: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Lengthen the array for every element, matched or not
// `i` is now the count of elements visited above, and adding it to `matchedCount`
// makes the latter nonnegative.
// Apply set filters to unmatched elements
// NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
// equals `i`), unless we didn't visit _any_ elements in the above loop because we have
// no element matchers and no seed.
// Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
// case, which will result in a "00" `matchedCount` that differs from `i` but is also
if ( bySet && i !== matchedCount ) {
while ( ( matcher = setMatchers[ j++ ] ) ) {
matcher( unmatched, setMatched, context, xml );
// Reintegrate element matches to eliminate the need for sorting
if ( matchedCount > 0 ) {
if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
setMatched[ i ] = pop.call( results );
// Discard index placeholder values to get only actual matches
setMatched = condense( setMatched );
// Add matches to results
push.apply( results, setMatched );
// Seedless set matches succeeding multiple successful matchers stipulate sorting
if ( outermost && !seed && setMatched.length > 0 &&
( matchedCount + setMatchers.length ) > 1 ) {
jQuery.uniqueSort( results );
// Override manipulation of globals by nested matchers
outermostContext = contextBackup;
markFunction( superMatcher ) :
function compile( selector, match /* Internal Use Only */ ) {
cached = compilerCache[ selector + " " ];
// Generate a function of recursive functions that can be used to check each element
match = tokenize( selector );
cached = matcherFromTokens( match[ i ] );
if ( cached[ expando ] ) {
setMatchers.push( cached );
elementMatchers.push( cached );
// Cache the compiled function
cached = compilerCache( selector,
matcherFromGroupMatchers( elementMatchers, setMatchers ) );
// Save selector and tokenization
cached.selector = selector;
* A low-level selection function that works with jQuery's compiled
* @param {String|Function} selector A selector or a pre-compiled
* selector function built with jQuery selector compile
* @param {Element} context
* @param {Array} [results]
* @param {Array} [seed] A set of elements to match against
function select( selector, context, results, seed ) {
var i, tokens, token, type, find,
compiled = typeof selector === "function" && selector,
match = !seed && tokenize( ( selector = compiled.selector || selector ) );
// Try to minimize operations if there is only one selector in the list and no seed
// (the latter of which guarantees us context)
if ( match.length === 1 ) {
// Reduce context if the leading compound selector is an ID
tokens = match[ 0 ] = match[ 0 ].slice( 0 );
if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
context = ( Expr.find.ID(
token.matches[ 0 ].replace( runescape, funescape ),
// Precompiled matchers will still verify ancestry, so step up a level
context = context.parentNode;
selector = selector.slice( tokens.shift().value.length );
// Fetch a seed set for right-to-left matching
i = matchExpr.needsContext.test( selector ) ? 0 : tokens.length;
// Abort if we hit a combinator
if ( Expr.relative[ ( type = token.type ) ] ) {
if ( ( find = Expr.find[ type ] ) ) {
// Search, expanding context for leading sibling combinators
token.matches[ 0 ].replace( runescape, funescape ),
rsibling.test( tokens[ 0 ].type ) &&
testContext( context.parentNode ) || context
// If seed is empty or no tokens remain, we can return early
selector = seed.length && toSelector( tokens );
push.apply( results, seed );
// Compile and execute a filtering function if one is not provided
// Provide `match` to avoid retokenization if we modified the selector above
( compiled || compile( selector, match ) )(
!context || rsibling.test( selector ) && testContext( context.parentNode ) || context
// Support: Android <=4.0 - 4.1+
support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
// Initialize against the default document
// Support: Android <=4.0 - 4.1+
// Detached nodes confoundingly follow *each other*
support.sortDetached = assert( function( el ) {
// Should return 1, but returns 4 (following)
return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
jQuery.expr[ ":" ] = jQuery.expr.pseudos;
jQuery.unique = jQuery.uniqueSort;
// These have always been private, but they used to be documented as part of
// Sizzle so let's maintain them for now for backwards compatibility purposes.
find.setDocument = setDocument;
find.tokenize = tokenize;
find.escape = jQuery.escapeSelector;
find.getText = jQuery.text;
find.isXML = jQuery.isXMLDoc;
find.selectors = jQuery.expr;
find.support = jQuery.support;
find.uniqueSort = jQuery.uniqueSort;
var dir = function( elem, dir, until ) {
truncate = until !== undefined;
while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
if ( elem.nodeType === 1 ) {
if ( truncate && jQuery( elem ).is( until ) ) {
var siblings = function( n, elem ) {
for ( ; n; n = n.nextSibling ) {
if ( n.nodeType === 1 && n !== elem ) {
var rneedsContext = jQuery.expr.match.needsContext;
var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
// Implement the identical functionality for filter and not
function winnow( elements, qualifier, not ) {
if ( isFunction( qualifier ) ) {
return jQuery.grep( elements, function( elem, i ) {
return !!qualifier.call( elem, i, elem ) !== not;
if ( qualifier.nodeType ) {
return jQuery.grep( elements, function( elem ) {
return ( elem === qualifier ) !== not;
// Arraylike of elements (jQuery, arguments, Array)
if ( typeof qualifier !== "string" ) {
return jQuery.grep( elements, function( elem ) {
return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
// Filtered directly for both simple and complex selectors
return jQuery.filter( qualifier, elements, not );
jQuery.filter = function( expr, elems, not ) {
expr = ":not(" + expr + ")";
if ( elems.length === 1 && elem.nodeType === 1 ) {
return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
return elem.nodeType === 1;
find: function( selector ) {
if ( typeof selector !== "string" ) {
return this.pushStack( jQuery( selector ).filter( function() {
for ( i = 0; i < len; i++ ) {
if ( jQuery.contains( self[ i ], this ) ) {
ret = this.pushStack( [] );
for ( i = 0; i < len; i++ ) {
jQuery.find( selector, self[ i ], ret );
return len > 1 ? jQuery.uniqueSort( ret ) : ret;
filter: function( selector ) {
return this.pushStack( winnow( this, selector || [], false ) );
not: function( selector ) {
return this.pushStack( winnow( this, selector || [], true ) );
is: function( selector ) {
// If this is a positional/relative selector, check membership in the returned set
// so $("p:first").is("p:last") won't return true for a doc with two "p".
typeof selector === "string" && rneedsContext.test( selector ) ?
// Initialize a jQuery object
// A central reference to the root jQuery(document)
// A simple way to check for HTML strings
// Prioritize #id over <tag> to avoid XSS via location.hash (trac-9521)
// Strict HTML recognition (trac-11290: must start with <)
// Shortcut simple #id case for speed
rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
init = jQuery.fn.init = function( selector, context, root ) {
// HANDLE: $(""), $(null), $(undefined), $(false)
// Method init() accepts an alternate rootjQuery
// so migrate can support jQuery.sub (gh-2101)
root = root || rootjQuery;
if ( typeof selector === "string" ) {
if ( selector[ 0 ] === "<" &&
selector[ selector.length - 1 ] === ">" &&
// Assume that strings that start and end with <> are HTML and skip the regex check
match = [ null, selector, null ];
match = rquickExpr.exec( selector );
// Match html or make sure no context is specified for #id
if ( match && ( match[ 1 ] || !context ) ) {
// HANDLE: $(html) -> $(array)
context = context instanceof jQuery ? context[ 0 ] : context;
// Option to run scripts is true for back-compat
// Intentionally let the error be thrown if parseHTML is not present
jQuery.merge( this, jQuery.parseHTML(
context && context.nodeType ? context.ownerDocument || context : document,
// HANDLE: $(html, props)
if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
for ( match in context ) {
// Properties of context are called as methods if possible
if ( isFunction( this[ match ] ) ) {
this[ match ]( context[ match ] );
// ...and otherwise set as attributes
this.attr( match, context[ match ] );
elem = document.getElementById( match[ 2 ] );
// Inject the element directly into the jQuery object
// HANDLE: $(expr, $(...))
} else if ( !context || context.jquery ) {
return ( context || root ).find( selector );
// HANDLE: $(expr, context)
// (which is just equivalent to: $(context).find(expr)
return this.constructor( context ).find( selector );
} else if ( selector.nodeType ) {
// Shortcut for document ready
} else if ( isFunction( selector ) ) {
return root.ready !== undefined ?
// Execute immediately if ready is not present
return jQuery.makeArray( selector, this );
// Give the init function the jQuery prototype for later instantiation
init.prototype = jQuery.fn;
// Initialize central reference
rootjQuery = jQuery( document );
var rparentsprev = /^(?:parents|prev(?:Until|All))/,
// Methods guaranteed to produce a unique set when starting from a unique set
has: function( target ) {
var targets = jQuery( target, this ),
return this.filter( function() {
if ( jQuery.contains( this, targets[ i ] ) ) {
closest: function( selectors, context ) {
targets = typeof selectors !== "string" && jQuery( selectors );
// Positional selectors never match, since there's no _selection_ context
if ( !rneedsContext.test( selectors ) ) {