summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReedy <reedy@wikimedia.org>2012-10-09 23:27:35 +0000
committerGerrit Code Review <gerrit@wikimedia.org>2012-10-09 23:27:35 +0000
commit097ec3057a0a5b854a8bec32d233259fdda2edd6 (patch)
treef06441ce11b5b208f686ecd02e266b429caa46f6
parente9cf0e6c48ba17471985e88a52c69d147321b115 (diff)
parent8ce1efca21914798bb4c4a9f7dbb2ab60487c72f (diff)
Merge "Update jQuery to 1.8.2" into wmf/1.20wmf12origin/wmf/1.20wmf12
-rw-r--r--RELEASE-NOTES-1.202
-rw-r--r--resources/jquery/jquery.js1091
2 files changed, 616 insertions, 477 deletions
diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20
index b28cc70c10c0..27e850c43df6 100644
--- a/RELEASE-NOTES-1.20
+++ b/RELEASE-NOTES-1.20
@@ -67,7 +67,7 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
* (bug 35685) api.php URL and other entry point URLs are now listed on
Special:Version
* Edit notices can now be translated.
-* jQuery upgraded to 1.8.1
+* jQuery upgraded to 1.8.2.
* jQuery UI upgraded to 1.8.23.
* QUnit upgraded from v1.2.0 to v1.10.0.
* (bug 37604) jquery.cookie upgraded to 2011 version.
diff --git a/resources/jquery/jquery.js b/resources/jquery/jquery.js
index 973ef3d9a469..d4f3bb38cdab 100644
--- a/resources/jquery/jquery.js
+++ b/resources/jquery/jquery.js
@@ -1,5 +1,5 @@
/*!
- * jQuery JavaScript Library v1.8.1
+ * jQuery JavaScript Library v1.8.2
* http://jquery.com/
*
* Includes Sizzle.js
@@ -9,7 +9,7 @@
* Released under the MIT license
* http://jquery.org/license
*
- * Date: Thu Aug 30 2012 17:17:22 GMT-0400 (Eastern Daylight Time)
+ * Date: Thu Sep 20 2012 21:13:05 GMT-0400 (Eastern Daylight Time)
*/
(function( window, undefined ) {
var
@@ -186,7 +186,7 @@ jQuery.fn = jQuery.prototype = {
selector: "",
// The current version of jQuery being used
- jquery: "1.8.1",
+ jquery: "1.8.2",
// The default length of a jQuery object is 0
length: 0,
@@ -573,7 +573,7 @@ jQuery.extend({
},
nodeName: function( elem, name ) {
- return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
+ return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
},
// args is for internal usage only
@@ -630,7 +630,7 @@ jQuery.extend({
function( text ) {
return text == null ?
"" :
- text.toString().replace( rtrim, "" );
+ ( text + "" ).replace( rtrim, "" );
},
// results is for internal usage only
@@ -776,7 +776,7 @@ jQuery.extend({
};
// Set the guid of unique handler to the same of original handler, so it can be removed
- proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
+ proxy.guid = fn.guid = fn.guid || jQuery.guid++;
return proxy;
},
@@ -1143,7 +1143,7 @@ jQuery.extend({
// Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object
promise: function( obj ) {
- return typeof obj === "object" ? jQuery.extend( obj, promise ) : promise;
+ return obj != null ? jQuery.extend( obj, promise ) : promise;
}
},
deferred = {};
@@ -1262,7 +1262,7 @@ jQuery.support = (function() {
a.style.cssText = "top:1px;float:left;opacity:.5";
// Can't get basic test support
- if ( !all || !all.length || !a ) {
+ if ( !all || !all.length ) {
return {};
}
@@ -1513,7 +1513,7 @@ jQuery.extend({
deletedIds: [],
- // Please use with caution
+ // Remove at next major release (1.9/2.0)
uuid: 0,
// Unique for each copy of jQuery on the page
@@ -1565,7 +1565,7 @@ jQuery.extend({
// Only DOM nodes need a new unique ID for each element since their data
// ends up in the global cache
if ( isNode ) {
- elem[ internalKey ] = id = jQuery.deletedIds.pop() || ++jQuery.uuid;
+ elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++;
} else {
id = internalKey;
}
@@ -1739,7 +1739,7 @@ jQuery.fn.extend({
for ( l = attr.length; i < l; i++ ) {
name = attr[i].name;
- if ( name.indexOf( "data-" ) === 0 ) {
+ if ( !name.indexOf( "data-" ) ) {
name = jQuery.camelCase( name.substring(5) );
dataAttr( elem, name, data[ name ] );
@@ -2049,7 +2049,7 @@ jQuery.fn.extend({
setClass = " " + elem.className + " ";
for ( c = 0, cl = classNames.length; c < cl; c++ ) {
- if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
+ if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) {
setClass += classNames[ c ] + " ";
}
}
@@ -2082,7 +2082,7 @@ jQuery.fn.extend({
// loop over each item in the removal list
for ( c = 0, cl = removes.length; c < cl; c++ ) {
// Remove until there is nothing to remove,
- while ( className.indexOf(" " + removes[ c ] + " ") > -1 ) {
+ while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) {
className = className.replace( " " + removes[ c ] + " " , " " );
}
}
@@ -2136,7 +2136,7 @@ jQuery.fn.extend({
i = 0,
l = this.length;
for ( ; i < l; i++ ) {
- if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+ if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
return true;
}
}
@@ -2314,7 +2314,7 @@ jQuery.extend({
return ret;
} else {
- elem.setAttribute( name, "" + value );
+ elem.setAttribute( name, value + "" );
return value;
}
@@ -2578,7 +2578,7 @@ if ( !jQuery.support.style ) {
return elem.style.cssText.toLowerCase() || undefined;
},
set: function( elem, value ) {
- return ( elem.style.cssText = "" + value );
+ return ( elem.style.cssText = value + "" );
}
};
}
@@ -2711,6 +2711,7 @@ jQuery.event = {
handler: handler,
guid: handler.guid,
selector: selector,
+ needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
namespace: namespaces.join(".")
}, handleObjIn );
@@ -2946,7 +2947,7 @@ jQuery.event = {
}
// Note that this is a bare JS function and not a jQuery handler
handle = ontype && cur[ ontype ];
- if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
+ if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
event.preventDefault();
}
}
@@ -2994,7 +2995,7 @@ jQuery.event = {
var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related,
handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
delegateCount = handlers.delegateCount,
- args = [].slice.call( arguments ),
+ args = core_slice.call( arguments ),
run_all = !event.exclusive && !event.namespace,
special = jQuery.event.special[ event.type ] || {},
handlerQueue = [];
@@ -3023,7 +3024,9 @@ jQuery.event = {
sel = handleObj.selector;
if ( selMatch[ sel ] === undefined ) {
- selMatch[ sel ] = jQuery( sel, this ).index( cur ) >= 0;
+ selMatch[ sel ] = handleObj.needsContext ?
+ jQuery( sel, this ).index( cur ) >= 0 :
+ jQuery.find( sel, this, null, [ cur ] ).length;
}
if ( selMatch[ sel ] ) {
matches.push( handleObj );
@@ -3593,7 +3596,7 @@ jQuery.fn.extend({
},
undelegate: function( selector, types, fn ) {
// ( namespace ) or ( selector, types [, fn] )
- return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
+ return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
},
trigger: function( type, data ) {
@@ -3664,14 +3667,13 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
});
/*!
* Sizzle CSS Selector Engine
- * Copyright 2012 jQuery Foundation and other contributors
- * Released under the MIT license
- * http://sizzlejs.com/
+ * Copyright 2012 jQuery Foundation and other contributors
+ * Released under the MIT license
+ * http://sizzlejs.com/
*/
(function( window, undefined ) {
-var dirruns,
- cachedruns,
+var cachedruns,
assertGetIdNotName,
Expr,
getText,
@@ -3680,21 +3682,36 @@ var dirruns,
compile,
sortOrder,
hasDuplicate,
+ outermostContext,
baseHasDuplicate = true,
strundefined = "undefined",
expando = ( "sizcache" + Math.random() ).replace( ".", "" ),
+ Token = String,
document = window.document,
docElem = document.documentElement,
+ dirruns = 0,
done = 0,
- slice = [].slice,
+ pop = [].pop,
push = [].push,
+ slice = [].slice,
+ // Use a stripped-down indexOf if a native one is unavailable
+ indexOf = [].indexOf || function( elem ) {
+ var i = 0,
+ len = this.length;
+ for ( ; i < len; i++ ) {
+ if ( this[i] === elem ) {
+ return i;
+ }
+ }
+ return -1;
+ },
// Augment a function for special use by Sizzle
markFunction = function( fn, value ) {
- fn[ expando ] = value || true;
+ fn[ expando ] = value == null || value;
return fn;
},
@@ -3741,7 +3758,8 @@ var dirruns,
pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)",
// For matchExpr.POS and matchExpr.needsContext
- pos = ":(nth|eq|gt|lt|first|last|even|odd)(?:\\(((?:-\\d)?\\d*)\\)|)(?=[^-]|$)",
+ pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
+ "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)",
// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
@@ -3769,10 +3787,10 @@ var dirruns,
"TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
"ATTR": new RegExp( "^" + attributes ),
"PSEUDO": new RegExp( "^" + pseudos ),
- "CHILD": new RegExp( "^:(only|nth|last|first)-child(?:\\(" + whitespace +
+ "POS": new RegExp( pos, "i" ),
+ "CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace +
"*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
"*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
- "POS": new RegExp( pos, "ig" ),
// For use in libraries implementing .is()
"needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )
},
@@ -3854,7 +3872,8 @@ try {
slice.call( docElem.childNodes, 0 )[0].nodeType;
} catch ( e ) {
slice = function( i ) {
- var elem, results = [];
+ var elem,
+ results = [];
for ( ; (elem = this[i]); i++ ) {
results.push( elem );
}
@@ -3868,14 +3887,14 @@ function Sizzle( selector, context, results, seed ) {
var match, elem, xml, m,
nodeType = context.nodeType;
- if ( nodeType !== 1 && nodeType !== 9 ) {
- return [];
- }
-
if ( !selector || typeof selector !== "string" ) {
return results;
}
+ if ( nodeType !== 1 && nodeType !== 9 ) {
+ return [];
+ }
+
xml = isXML( context );
if ( !xml && !seed ) {
@@ -3919,7 +3938,7 @@ function Sizzle( selector, context, results, seed ) {
}
// All others
- return select( selector, context, results, seed, xml );
+ return select( selector.replace( rtrim, "$1" ), context, results, seed, xml );
}
Sizzle.matches = function( expr, elements ) {
@@ -3946,6 +3965,25 @@ function createButtonPseudo( type ) {
};
}
+// Returns a function to use in pseudos for positionals
+function createPositionalPseudo( fn ) {
+ return markFunction(function( argument ) {
+ argument = +argument;
+ return markFunction(function( seed, matches ) {
+ var j,
+ matchIndexes = fn( [], seed.length, argument ),
+ i = matchIndexes.length;
+
+ // Match elements found at the specified indexes
+ while ( i-- ) {
+ if ( seed[ (j = matchIndexes[i]) ] ) {
+ seed[j] = !(matches[j] = seed[j]);
+ }
+ }
+ });
+ });
+}
+
/**
* Utility function for retrieving the text value of an array of DOM nodes
* @param {Array|Element} elem
@@ -3983,7 +4021,7 @@ getText = Sizzle.getText = function( elem ) {
return ret;
};
-isXML = Sizzle.isXML = function isXML( elem ) {
+isXML = Sizzle.isXML = function( elem ) {
// documentElement is verified for cases where it doesn't yet exist
// (such as loading iframes in IE - #4833)
var documentElement = elem && (elem.ownerDocument || elem).documentElement;
@@ -4011,23 +4049,23 @@ contains = Sizzle.contains = docElem.contains ?
};
Sizzle.attr = function( elem, name ) {
- var attr,
+ var val,
xml = isXML( elem );
if ( !xml ) {
name = name.toLowerCase();
}
- if ( Expr.attrHandle[ name ] ) {
- return Expr.attrHandle[ name ]( elem );
+ if ( (val = Expr.attrHandle[ name ]) ) {
+ return val( elem );
}
- if ( assertAttributes || xml ) {
+ if ( xml || assertAttributes ) {
return elem.getAttribute( name );
}
- attr = elem.getAttributeNode( name );
- return attr ?
+ val = elem.getAttributeNode( name );
+ return val ?
typeof elem[ name ] === "boolean" ?
elem[ name ] ? name : null :
- attr.specified ? attr.value : null :
+ val.specified ? val.value : null :
null;
};
@@ -4040,11 +4078,6 @@ Expr = Sizzle.selectors = {
match: matchExpr,
- order: new RegExp( "ID|TAG" +
- (assertUsableName ? "|NAME" : "") +
- (assertUsableClassName ? "|CLASS" : "")
- ),
-
// IE6/7 return a modified href
attrHandle: assertHrefNotNormalized ?
{} :
@@ -4105,13 +4138,13 @@ Expr = Sizzle.selectors = {
return results;
},
- "NAME": function( tag, context ) {
+ "NAME": assertUsableName && function( tag, context ) {
if ( typeof context.getElementsByName !== strundefined ) {
return context.getElementsByName( name );
}
},
- "CLASS": function( className, context, xml ) {
+ "CLASS": assertUsableClassName && function( className, context, xml ) {
if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
return context.getElementsByClassName( className );
}
@@ -4140,7 +4173,7 @@ Expr = Sizzle.selectors = {
},
"CHILD": function( match ) {
- /* matches from matchExpr.CHILD
+ /* matches from matchExpr["CHILD"]
1 type (only|nth|...)
2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
3 xn-component of xn+y argument ([+-]?\d*n|)
@@ -4170,7 +4203,7 @@ Expr = Sizzle.selectors = {
return match;
},
- "PSEUDO": function( match, context, xml ) {
+ "PSEUDO": function( match ) {
var unquoted, excess;
if ( matchExpr["CHILD"].test( match[0] ) ) {
return null;
@@ -4182,7 +4215,7 @@ Expr = Sizzle.selectors = {
// Only check arguments that contain a pseudo
if ( rpseudo.test(unquoted) &&
// Get excess from tokenize (recursively)
- (excess = tokenize( unquoted, context, xml, true )) &&
+ (excess = tokenize( unquoted, true )) &&
// advance to the next closing parenthesis
(excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
@@ -4236,76 +4269,55 @@ Expr = Sizzle.selectors = {
},
"ATTR": function( name, operator, check ) {
- if ( !operator ) {
- return function( elem ) {
- return Sizzle.attr( elem, name ) != null;
- };
- }
-
- return function( elem ) {
- var result = Sizzle.attr( elem, name ),
- value = result + "";
+ return function( elem, context ) {
+ var result = Sizzle.attr( elem, name );
if ( result == null ) {
return operator === "!=";
}
-
- switch ( operator ) {
- case "=":
- return value === check;
- case "!=":
- return value !== check;
- case "^=":
- return check && value.indexOf( check ) === 0;
- case "*=":
- return check && value.indexOf( check ) > -1;
- case "$=":
- return check && value.substr( value.length - check.length ) === check;
- case "~=":
- return ( " " + value + " " ).indexOf( check ) > -1;
- case "|=":
- return value === check || value.substr( 0, check.length + 1 ) === check + "-";
+ if ( !operator ) {
+ return true;
}
+
+ result += "";
+
+ return operator === "=" ? result === check :
+ operator === "!=" ? result !== check :
+ operator === "^=" ? check && result.indexOf( check ) === 0 :
+ operator === "*=" ? check && result.indexOf( check ) > -1 :
+ operator === "$=" ? check && result.substr( result.length - check.length ) === check :
+ operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
+ operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" :
+ false;
};
},
"CHILD": function( type, argument, first, last ) {
if ( type === "nth" ) {
- var doneName = done++;
-
return function( elem ) {
- var parent, diff,
- count = 0,
- node = elem;
+ var node, diff,
+ parent = elem.parentNode;
if ( first === 1 && last === 0 ) {
return true;
}
- parent = elem.parentNode;
-
- if ( parent && (parent[ expando ] !== doneName || !elem.sizset) ) {
+ if ( parent ) {
+ diff = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) {
- node.sizset = ++count;
- if ( node === elem ) {
+ diff++;
+ if ( elem === node ) {
break;
}
}
}
-
- parent[ expando ] = doneName;
}
- diff = elem.sizset - last;
-
- if ( first === 0 ) {
- return diff === 0;
-
- } else {
- return ( diff % first === 0 && diff / first >= 0 );
- }
+ // Incorporate the offset (or cast to NaN), then check against cycle size
+ diff -= last;
+ return diff === first || ( diff % first === 0 && diff / first >= 0 );
};
}
@@ -4340,42 +4352,82 @@ Expr = Sizzle.selectors = {
};
},
- "PSEUDO": function( pseudo, argument, context, xml ) {
+ "PSEUDO": function( pseudo, argument ) {
// pseudo-class names are case-insensitive
// http://www.w3.org/TR/selectors/#pseudo-classes
// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
+ // Remember that setFilters inherits from pseudos
var args,
- fn = Expr.pseudos[ pseudo ] || Expr.pseudos[ pseudo.toLowerCase() ];
-
- if ( !fn ) {
- Sizzle.error( "unsupported pseudo: " + pseudo );
- }
+ fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
+ Sizzle.error( "unsupported pseudo: " + pseudo );
// The user may use createPseudo to indicate that
// arguments are needed to create the filter function
// just as Sizzle does
- if ( !fn[ expando ] ) {
- if ( fn.length > 1 ) {
- args = [ pseudo, pseudo, "", argument ];
- return function( elem ) {
+ if ( fn[ expando ] ) {
+ return fn( argument );
+ }
+
+ // But maintain support for old signatures
+ if ( fn.length > 1 ) {
+ args = [ pseudo, pseudo, "", argument ];
+ return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
+ markFunction(function( seed, matches ) {
+ var idx,
+ matched = fn( seed, argument ),
+ i = matched.length;
+ while ( i-- ) {
+ idx = indexOf.call( seed, matched[i] );
+ seed[ idx ] = !( matches[ idx ] = matched[i] );
+ }
+ }) :
+ function( elem ) {
return fn( elem, 0, args );
};
- }
- return fn;
}
- return fn( argument, context, xml );
+ return fn;
}
},
pseudos: {
- "not": markFunction(function( selector, context, xml ) {
+ "not": markFunction(function( selector ) {
// Trim the selector passed to compile
// to avoid treating leading and trailing
// spaces as combinators
- var matcher = compile( selector.replace( rtrim, "$1" ), context, xml );
+ var input = [],
+ results = [],
+ matcher = compile( selector.replace( rtrim, "$1" ) );
+
+ return matcher[ expando ] ?
+ markFunction(function( seed, matches, context, xml ) {
+ var elem,
+ unmatched = matcher( seed, null, xml, [] ),
+ i = seed.length;
+
+ // Match elements unmatched by `matcher`
+ while ( i-- ) {
+ if ( (elem = unmatched[i]) ) {
+ seed[i] = !(matches[i] = elem);
+ }
+ }
+ }) :
+ function( elem, context, xml ) {
+ input[0] = elem;
+ matcher( input, null, xml, results );
+ return !results.pop();
+ };
+ }),
+
+ "has": markFunction(function( selector ) {
return function( elem ) {
- return !matcher( elem );
+ return Sizzle( selector, elem ).length > 0;
+ };
+ }),
+
+ "contains": markFunction(function( text ) {
+ return function( elem ) {
+ return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
};
}),
@@ -4425,18 +4477,6 @@ Expr = Sizzle.selectors = {
return true;
},
- "contains": markFunction(function( text ) {
- return function( elem ) {
- return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
- };
- }),
-
- "has": markFunction(function( selector ) {
- return function( elem ) {
- return Sizzle( selector, elem ).length > 0;
- };
- }),
-
"header": function( elem ) {
return rheader.test( elem.nodeName );
},
@@ -4476,51 +4516,48 @@ Expr = Sizzle.selectors = {
"active": function( elem ) {
return elem === elem.ownerDocument.activeElement;
- }
- },
-
- setFilters: {
- "first": function( elements, argument, not ) {
- return not ? elements.slice( 1 ) : [ elements[0] ];
},
- "last": function( elements, argument, not ) {
- var elem = elements.pop();
- return not ? elements : [ elem ];
- },
+ // Positional types
+ "first": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ return [ 0 ];
+ }),
- "even": function( elements, argument, not ) {
- var results = [],
- i = not ? 1 : 0,
- len = elements.length;
- for ( ; i < len; i = i + 2 ) {
- results.push( elements[i] );
- }
- return results;
- },
+ "last": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ return [ length - 1 ];
+ }),
- "odd": function( elements, argument, not ) {
- var results = [],
- i = not ? 0 : 1,
- len = elements.length;
- for ( ; i < len; i = i + 2 ) {
- results.push( elements[i] );
+ "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ return [ argument < 0 ? argument + length : argument ];
+ }),
+
+ "even": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ for ( var i = 0; i < length; i += 2 ) {
+ matchIndexes.push( i );
}
- return results;
- },
+ return matchIndexes;
+ }),
- "lt": function( elements, argument, not ) {
- return not ? elements.slice( +argument ) : elements.slice( 0, +argument );
- },
+ "odd": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ for ( var i = 1; i < length; i += 2 ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
- "gt": function( elements, argument, not ) {
- return not ? elements.slice( 0, +argument + 1 ) : elements.slice( +argument + 1 );
- },
+ "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
- "eq": function( elements, argument, not ) {
- var elem = elements.splice( +argument, 1 );
- return not ? elements : elem;
- }
+ "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ })
}
};
@@ -4642,24 +4679,17 @@ Sizzle.error = function( msg ) {
throw new Error( "Syntax error, unrecognized expression: " + msg );
};
-function tokenize( selector, context, xml, parseOnly ) {
- var matched, match, tokens, type,
- soFar, groups, group, i,
- preFilters, filters,
- checkContext = !xml && context !== document,
- // Token cache should maintain spaces
- key = ( checkContext ? "<s>" : "" ) + selector.replace( rtrim, "$1<s>" ),
- cached = tokenCache[ expando ][ key ];
+function tokenize( selector, parseOnly ) {
+ var matched, match, tokens, type, soFar, groups, preFilters,
+ cached = tokenCache[ expando ][ selector ];
if ( cached ) {
- return parseOnly ? 0 : slice.call( cached, 0 );
+ return parseOnly ? 0 : cached.slice( 0 );
}
soFar = selector;
groups = [];
- i = 0;
preFilters = Expr.preFilter;
- filters = Expr.filter;
while ( soFar ) {
@@ -4667,45 +4697,31 @@ function tokenize( selector, context, xml, parseOnly ) {
if ( !matched || (match = rcomma.exec( soFar )) ) {
if ( match ) {
soFar = soFar.slice( match[0].length );
- tokens.selector = group;
}
groups.push( tokens = [] );
- group = "";
-
- // Need to make sure we're within a narrower context if necessary
- // Adding a descendant combinator will generate what is needed
- if ( checkContext ) {
- soFar = " " + soFar;
- }
}
matched = false;
// Combinators
if ( (match = rcombinators.exec( soFar )) ) {
- group += match[0];
- soFar = soFar.slice( match[0].length );
+ tokens.push( matched = new Token( match.shift() ) );
+ soFar = soFar.slice( matched.length );
// Cast descendant combinators to space
- matched = tokens.push({
- part: match.pop().replace( rtrim, " " ),
- string: match[0],
- captures: match
- });
+ matched.type = match[0].replace( rtrim, " " );
}
// Filters
- for ( type in filters ) {
+ for ( type in Expr.filter ) {
if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
- ( match = preFilters[ type ](match, context, xml) )) ) {
+ // The last two arguments here are (context, xml) for backCompat
+ (match = preFilters[ type ]( match, document, true ))) ) {
- group += match[0];
- soFar = soFar.slice( match[0].length );
- matched = tokens.push({
- part: type,
- string: match.shift(),
- captures: match
- });
+ tokens.push( matched = new Token( match.shift() ) );
+ soFar = soFar.slice( matched.length );
+ matched.type = type;
+ matched.matches = match;
}
}
@@ -4714,11 +4730,6 @@ function tokenize( selector, context, xml, parseOnly ) {
}
}
- // Attach the full group as a selector
- if ( group ) {
- tokens.selector = group;
- }
-
// Return the length of the invalid excess
// if we're just parsing
// Otherwise, throw an error or return tokens
@@ -4727,43 +4738,33 @@ function tokenize( selector, context, xml, parseOnly ) {
soFar ?
Sizzle.error( selector ) :
// Cache the tokens
- slice.call( tokenCache(key, groups), 0 );
+ tokenCache( selector, groups ).slice( 0 );
}
-function addCombinator( matcher, combinator, context, xml ) {
+function addCombinator( matcher, combinator, base ) {
var dir = combinator.dir,
+ checkNonElements = base && combinator.dir === "parentNode",
doneName = done++;
- if ( !matcher ) {
- // If there is no matcher to check, check against the context
- matcher = function( elem ) {
- return elem === context;
- };
- }
return combinator.first ?
- function( elem ) {
+ // Check against closest ancestor/preceding element
+ function( elem, context, xml ) {
while ( (elem = elem[ dir ]) ) {
- if ( elem.nodeType === 1 ) {
- return matcher( elem ) && elem;
+ if ( checkNonElements || elem.nodeType === 1 ) {
+ return matcher( elem, context, xml );
}
}
} :
- xml ?
- function( elem ) {
- while ( (elem = elem[ dir ]) ) {
- if ( elem.nodeType === 1 ) {
- if ( matcher( elem ) ) {
- return elem;
- }
- }
- }
- } :
- function( elem ) {
+
+ // Check against all ancestor/preceding elements
+ function( elem, context, xml ) {
+ // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
+ if ( !xml ) {
var cache,
- dirkey = doneName + "." + dirruns,
- cachedkey = dirkey + "." + cachedruns;
+ dirkey = dirruns + " " + doneName + " ",
+ cachedkey = dirkey + cachedruns;
while ( (elem = elem[ dir ]) ) {
- if ( elem.nodeType === 1 ) {
+ if ( checkNonElements || elem.nodeType === 1 ) {
if ( (cache = elem[ expando ]) === cachedkey ) {
return elem.sizset;
} else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
@@ -4772,7 +4773,7 @@ function addCombinator( matcher, combinator, context, xml ) {
}
} else {
elem[ expando ] = cachedkey;
- if ( matcher( elem ) ) {
+ if ( matcher( elem, context, xml ) ) {
elem.sizset = true;
return elem;
}
@@ -4780,254 +4781,382 @@ function addCombinator( matcher, combinator, context, xml ) {
}
}
}
- };
+ } else {
+ while ( (elem = elem[ dir ]) ) {
+ if ( checkNonElements || elem.nodeType === 1 ) {
+ if ( matcher( elem, context, xml ) ) {
+ return elem;
+ }
+ }
+ }
+ }
+ };
}
-function addMatcher( higher, deeper ) {
- return higher ?
- function( elem ) {
- var result = deeper( elem );
- return result && higher( result === true ? elem : result );
+function elementMatcher( matchers ) {
+ return matchers.length > 1 ?
+ function( elem, context, xml ) {
+ var i = matchers.length;
+ while ( i-- ) {
+ if ( !matchers[i]( elem, context, xml ) ) {
+ return false;
+ }
+ }
+ return true;
} :
- deeper;
+ matchers[0];
}
-// ["TAG", ">", "ID", " ", "CLASS"]
-function matcherFromTokens( tokens, context, xml ) {
- var token, matcher,
- i = 0;
+function condense( unmatched, map, filter, context, xml ) {
+ var elem,
+ newUnmatched = [],
+ i = 0,
+ len = unmatched.length,
+ mapped = map != null;
- for ( ; (token = tokens[i]); i++ ) {
- if ( Expr.relative[ token.part ] ) {
- matcher = addCombinator( matcher, Expr.relative[ token.part ], context, xml );
- } else {
- matcher = addMatcher( matcher, Expr.filter[ token.part ].apply(null, token.captures.concat( context, xml )) );
+ for ( ; i < len; i++ ) {
+ if ( (elem = unmatched[i]) ) {
+ if ( !filter || filter( elem, context, xml ) ) {
+ newUnmatched.push( elem );
+ if ( mapped ) {
+ map.push( i );
+ }
+ }
}
}
- return matcher;
+ return newUnmatched;
}
-function matcherFromGroupMatchers( matchers ) {
- return function( elem ) {
- var matcher,
- j = 0;
- for ( ; (matcher = matchers[j]); j++ ) {
- if ( matcher(elem) ) {
- return true;
- }
+function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
+ if ( postFilter && !postFilter[ expando ] ) {
+ postFilter = setMatcher( postFilter );
+ }
+ if ( postFinder && !postFinder[ expando ] ) {
+ postFinder = setMatcher( postFinder, postSelector );
+ }
+ return markFunction(function( seed, results, context, xml ) {
+ // Positional selectors apply to seed elements, so it is invalid to follow them with relative ones
+ if ( seed && postFinder ) {
+ return;
}
- return false;
- };
-}
-compile = Sizzle.compile = function( selector, context, xml ) {
- var group, i, len,
- cached = compilerCache[ expando ][ selector ];
+ var i, elem, postFilterIn,
+ preMap = [],
+ postMap = [],
+ preexisting = results.length,
- // Return a cached group function if already generated (context dependent)
- if ( cached && cached.context === context ) {
- return cached;
- }
+ // Get initial elements from seed or context
+ elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [], seed ),
- // Generate a function of recursive functions that can be used to check each element
- group = tokenize( selector, context, xml );
- for ( i = 0, len = group.length; i < len; i++ ) {
- group[i] = matcherFromTokens(group[i], context, xml);
- }
+ // Prefilter to get matcher input, preserving a map for seed-results synchronization
+ matcherIn = preFilter && ( seed || !selector ) ?
+ condense( elems, preMap, preFilter, context, xml ) :
+ elems,
- // Cache the compiled function
- cached = compilerCache( selector, matcherFromGroupMatchers(group) );
- cached.context = context;
- cached.runs = cached.dirruns = 0;
- return cached;
-};
+ matcherOut = matcher ?
+ // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
+ postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
-function multipleContexts( selector, contexts, results, seed ) {
- var i = 0,
- len = contexts.length;
- for ( ; i < len; i++ ) {
- Sizzle( selector, contexts[i], results, seed );
- }
-}
+ // ...intermediate processing is necessary
+ [] :
-function handlePOSGroup( selector, posfilter, argument, contexts, seed, not ) {
- var results,
- fn = Expr.setFilters[ posfilter.toLowerCase() ];
+ // ...otherwise use results directly
+ results :
+ matcherIn;
- if ( !fn ) {
- Sizzle.error( posfilter );
- }
+ // Find primary matches
+ if ( matcher ) {
+ matcher( matcherIn, matcherOut, context, xml );
+ }
- if ( selector || !(results = seed) ) {
- multipleContexts( selector || "*", contexts, (results = []), seed );
- }
+ // Apply postFilter
+ if ( postFilter ) {
+ postFilterIn = condense( matcherOut, postMap );
+ postFilter( postFilterIn, [], context, xml );
- return results.length > 0 ? fn( results, argument, not ) : [];
-}
+ // Un-match failing elements by moving them back to matcherIn
+ i = postFilterIn.length;
+ while ( i-- ) {
+ if ( (elem = postFilterIn[i]) ) {
+ matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
+ }
+ }
+ }
-function handlePOS( groups, context, results, seed ) {
- var group, part, j, groupLen, token, selector,
- anchor, elements, match, matched,
- lastIndex, currentContexts, not,
- i = 0,
- len = groups.length,
- rpos = matchExpr["POS"],
- // This is generated here in case matchExpr["POS"] is extended
- rposgroups = new RegExp( "^" + rpos.source + "(?!" + whitespace + ")", "i" ),
- // This is for making sure non-participating
- // matching groups are represented cross-browser (IE6-8)
- setUndefined = function() {
- var i = 1,
- len = arguments.length - 2;
- for ( ; i < len; i++ ) {
- if ( arguments[i] === undefined ) {
- match[i] = undefined;
+ // Keep seed and results synchronized
+ if ( seed ) {
+ // Ignore postFinder because it can't coexist with seed
+ i = preFilter && matcherOut.length;
+ while ( i-- ) {
+ if ( (elem = matcherOut[i]) ) {
+ seed[ preMap[i] ] = !(results[ preMap[i] ] = elem);
}
}
- };
+ } else {
+ matcherOut = condense(
+ matcherOut === results ?
+ matcherOut.splice( preexisting, matcherOut.length ) :
+ matcherOut
+ );
+ if ( postFinder ) {
+ postFinder( null, results, matcherOut, xml );
+ } else {
+ push.apply( results, matcherOut );
+ }
+ }
+ });
+}
+
+function matcherFromTokens( tokens ) {
+ var checkContext, matcher, j,
+ len = tokens.length,
+ leadingRelative = Expr.relative[ tokens[0].type ],
+ implicitRelative = leadingRelative || Expr.relative[" "],
+ i = leadingRelative ? 1 : 0,
+
+ // The foundational matcher ensures that elements are reachable from top-level context(s)
+ matchContext = addCombinator( function( elem ) {
+ return elem === checkContext;
+ }, implicitRelative, true ),
+ matchAnyContext = addCombinator( function( elem ) {
+ return indexOf.call( checkContext, elem ) > -1;
+ }, implicitRelative, true ),
+ matchers = [ function( elem, context, xml ) {
+ return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
+ (checkContext = context).nodeType ?
+ matchContext( elem, context, xml ) :
+ matchAnyContext( elem, context, xml ) );
+ } ];
for ( ; i < len; i++ ) {
- group = groups[i];
- part = "";
- elements = seed;
- for ( j = 0, groupLen = group.length; j < groupLen; j++ ) {
- token = group[j];
- selector = token.string;
- if ( token.part === "PSEUDO" ) {
- // Reset regex index to 0
- rpos.exec("");
- anchor = 0;
- while ( (match = rpos.exec( selector )) ) {
- matched = true;
- lastIndex = rpos.lastIndex = match.index + match[0].length;
- if ( lastIndex > anchor ) {
- part += selector.slice( anchor, match.index );
- anchor = lastIndex;
- currentContexts = [ context ];
-
- if ( rcombinators.test(part) ) {
- if ( elements ) {
- currentContexts = elements;
- }
- elements = seed;
- }
+ if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
+ matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
+ } else {
+ // The concatenated values are (context, xml) for backCompat
+ matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
+
+ // Return special upon seeing a positional matcher
+ if ( matcher[ expando ] ) {
+ // Find the next relative operator (if any) for proper handling
+ j = ++i;
+ for ( ; j < len; j++ ) {
+ if ( Expr.relative[ tokens[j].type ] ) {
+ break;
+ }
+ }
+ return setMatcher(
+ i > 1 && elementMatcher( matchers ),
+ i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ),
+ matcher,
+ i < j && matcherFromTokens( tokens.slice( i, j ) ),
+ j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
+ j < len && tokens.join("")
+ );
+ }
+ matchers.push( matcher );
+ }
+ }
- if ( (not = rendsWithNot.test( part )) ) {
- part = part.slice( 0, -5 ).replace( rcombinators, "$&*" );
- anchor++;
- }
+ return elementMatcher( matchers );
+}
- if ( match.length > 1 ) {
- match[0].replace( rposgroups, setUndefined );
+function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
+ var bySet = setMatchers.length > 0,
+ byElement = elementMatchers.length > 0,
+ superMatcher = function( seed, context, xml, results, expandContext ) {
+ var elem, j, matcher,
+ setMatched = [],
+ matchedCount = 0,
+ i = "0",
+ unmatched = seed && [],
+ outermost = expandContext != null,
+ contextBackup = outermostContext,
+ // We must always have either seed elements or context
+ elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
+ // Nested matchers should use non-integer dirruns
+ dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E);
+
+ if ( outermost ) {
+ outermostContext = context !== document && context;
+ cachedruns = superMatcher.el;
+ }
+
+ // Add elements passing elementMatchers directly to results
+ for ( ; (elem = elems[i]) != null; i++ ) {
+ if ( byElement && elem ) {
+ for ( j = 0; (matcher = elementMatchers[j]); j++ ) {
+ if ( matcher( elem, context, xml ) ) {
+ results.push( elem );
+ break;
}
- elements = handlePOSGroup( part, match[1], match[2], currentContexts, elements, not );
}
- part = "";
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ cachedruns = ++superMatcher.el;
+ }
}
- }
+ // Track unmatched elements for set filters
+ if ( bySet ) {
+ // They will have gone through all possible matchers
+ if ( (elem = !matcher && elem) ) {
+ matchedCount--;
+ }
- if ( !matched ) {
- part += selector;
+ // Lengthen the array for every element, matched or not
+ if ( seed ) {
+ unmatched.push( elem );
+ }
+ }
}
- matched = false;
- }
- if ( part ) {
- if ( rcombinators.test(part) ) {
- multipleContexts( part, elements || [ context ], results, seed );
- } else {
- Sizzle( part, context, results, seed ? seed.concat(elements) : elements );
- }
- } else {
- push.apply( results, elements );
- }
- }
+ // Apply set filters to unmatched elements
+ matchedCount += i;
+ if ( bySet && i !== matchedCount ) {
+ for ( j = 0; (matcher = setMatchers[j]); j++ ) {
+ matcher( unmatched, setMatched, context, xml );
+ }
- // Do not sort if this is a single filter
- return len === 1 ? results : Sizzle.uniqueSort( results );
-}
+ if ( seed ) {
+ // Reintegrate element matches to eliminate the need for sorting
+ if ( matchedCount > 0 ) {
+ while ( i-- ) {
+ if ( !(unmatched[i] || setMatched[i]) ) {
+ setMatched[i] = pop.call( results );
+ }
+ }
+ }
-function select( selector, context, results, seed, xml ) {
- // Remove excessive whitespace
- selector = selector.replace( rtrim, "$1" );
- var elements, matcher, cached, elem,
- i, tokens, token, lastToken, findContext, type,
- match = tokenize( selector, context, xml ),
- contextNodeType = context.nodeType;
-
- // POS handling
- if ( matchExpr["POS"].test(selector) ) {
- return handlePOS( match, context, results, seed );
- }
+ // Discard index placeholder values to get only actual matches
+ setMatched = condense( setMatched );
+ }
- if ( seed ) {
- elements = slice.call( seed, 0 );
+ // Add matches to results
+ push.apply( results, setMatched );
- // To maintain document order, only narrow the
- // set if there is one group
- } else if ( match.length === 1 ) {
+ // Seedless set matches succeeding multiple successful matchers stipulate sorting
+ if ( outermost && !seed && setMatched.length > 0 &&
+ ( matchedCount + setMatchers.length ) > 1 ) {
- // Take a shortcut and set the context if the root selector is an ID
- if ( (tokens = slice.call( match[0], 0 )).length > 2 &&
- (token = tokens[0]).part === "ID" &&
- contextNodeType === 9 && !xml &&
- Expr.relative[ tokens[1].part ] ) {
+ Sizzle.uniqueSort( results );
+ }
+ }
- context = Expr.find["ID"]( token.captures[0].replace( rbackslash, "" ), context, xml )[0];
- if ( !context ) {
- return results;
+ // Override manipulation of globals by nested matchers
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ outermostContext = contextBackup;
}
- selector = selector.slice( tokens.shift().string.length );
- }
+ return unmatched;
+ };
+
+ superMatcher.el = 0;
+ return bySet ?
+ markFunction( superMatcher ) :
+ superMatcher;
+}
- findContext = ( (match = rsibling.exec( tokens[0].string )) && !match.index && context.parentNode ) || context;
+compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
+ var i,
+ setMatchers = [],
+ elementMatchers = [],
+ cached = compilerCache[ expando ][ selector ];
- // Reduce the set if possible
- lastToken = "";
- for ( i = tokens.length - 1; i >= 0; i-- ) {
- token = tokens[i];
- type = token.part;
- lastToken = token.string + lastToken;
- if ( Expr.relative[ type ] ) {
- break;
+ if ( !cached ) {
+ // Generate a function of recursive functions that can be used to check each element
+ if ( !group ) {
+ group = tokenize( selector );
+ }
+ i = group.length;
+ while ( i-- ) {
+ cached = matcherFromTokens( group[i] );
+ if ( cached[ expando ] ) {
+ setMatchers.push( cached );
+ } else {
+ elementMatchers.push( cached );
}
- if ( Expr.order.test(type) ) {
- elements = Expr.find[ type ]( token.captures[0].replace( rbackslash, "" ), findContext, xml );
- if ( elements == null ) {
- continue;
- } else {
- selector = selector.slice( 0, selector.length - lastToken.length ) +
- lastToken.replace( matchExpr[ type ], "" );
+ }
- if ( !selector ) {
- push.apply( results, slice.call(elements, 0) );
- }
+ // Cache the compiled function
+ cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
+ }
+ return cached;
+};
- break;
+function multipleContexts( selector, contexts, results, seed ) {
+ var i = 0,
+ len = contexts.length;
+ for ( ; i < len; i++ ) {
+ Sizzle( selector, contexts[i], results, seed );
+ }
+ return results;
+}
+
+function select( selector, context, results, seed, xml ) {
+ var i, tokens, token, type, find,
+ match = tokenize( selector ),
+ j = match.length;
+
+ if ( !seed ) {
+ // Try to minimize operations if there is only one group
+ if ( match.length === 1 ) {
+
+ // Take a shortcut and set the context if the root selector is an ID
+ tokens = match[0] = match[0].slice( 0 );
+ if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
+ context.nodeType === 9 && !xml &&
+ Expr.relative[ tokens[1].type ] ) {
+
+ context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0];
+ if ( !context ) {
+ return results;
}
+
+ selector = selector.slice( tokens.shift().length );
}
- }
- }
- // Only loop over the given elements once
- if ( selector ) {
- matcher = compile( selector, context, xml );
- dirruns = matcher.dirruns++;
- if ( elements == null ) {
- elements = Expr.find["TAG"]( "*", (rsibling.test( selector ) && context.parentNode) || context );
- }
+ // Fetch a seed set for right-to-left matching
+ for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) {
+ token = tokens[i];
+
+ // Abort if we hit a combinator
+ if ( Expr.relative[ (type = token.type) ] ) {
+ break;
+ }
+ if ( (find = Expr.find[ type ]) ) {
+ // Search, expanding context for leading sibling combinators
+ if ( (seed = find(
+ token.matches[0].replace( rbackslash, "" ),
+ rsibling.test( tokens[0].type ) && context.parentNode || context,
+ xml
+ )) ) {
+
+ // If seed is empty or no tokens remain, we can return early
+ tokens.splice( i, 1 );
+ selector = seed.length && tokens.join("");
+ if ( !selector ) {
+ push.apply( results, slice.call( seed, 0 ) );
+ return results;
+ }
- for ( i = 0; (elem = elements[i]); i++ ) {
- cachedruns = matcher.runs++;
- if ( matcher(elem) ) {
- results.push( elem );
+ break;
+ }
+ }
}
}
}
+ // Compile and execute a filtering function
+ // Provide `match` to avoid retokenization if we modified the selector above
+ compile( selector, match )(
+ seed,
+ context,
+ xml,
+ results,
+ rsibling.test( selector )
+ );
return results;
}
@@ -5037,11 +5166,16 @@ if ( document.querySelectorAll ) {
oldSelect = select,
rescape = /'|\\/g,
rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
- rbuggyQSA = [],
+
+ // qSa(:focus) reports false when true (Chrome 21),
+ // A support test would require too much code (would include document ready)
+ rbuggyQSA = [":focus"],
+
+ // matchesSelector(:focus) reports false when true (Chrome 21),
// matchesSelector(:active) reports false when true (IE9/Opera 11.5)
// A support test would require too much code (would include document ready)
// just skip matchesSelector for :active
- rbuggyMatches = [":active"],
+ rbuggyMatches = [ ":active", ":focus" ],
matches = docElem.matchesSelector ||
docElem.mozMatchesSelector ||
docElem.webkitMatchesSelector ||
@@ -5088,44 +5222,46 @@ if ( document.querySelectorAll ) {
}
});
- rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
+ // rbuggyQSA always contains :focus, so no need for a length check
+ rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") );
select = function( selector, context, results, seed, xml ) {
// Only use querySelectorAll when not filtering,
// when this is not xml,
// and when no QSA bugs apply
if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
- if ( context.nodeType === 9 ) {
- try {
- push.apply( results, slice.call(context.querySelectorAll( selector ), 0) );
- return results;
- } catch(qsaError) {}
+ var groups, i,
+ old = true,
+ nid = expando,
+ newContext = context,
+ newSelector = context.nodeType === 9 && selector;
+
// qSA works strangely on Element-rooted queries
// We can work around this by specifying an extra ID on the root
// and working up from there (Thanks to Andrew Dupont for the technique)
// IE 8 doesn't work on object elements
- } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
- var groups, i, len,
- old = context.getAttribute("id"),
- nid = old || expando,
- newContext = rsibling.test( selector ) && context.parentNode || context;
-
- if ( old ) {
- nid = nid.replace( rescape, "\\$&" );
+ if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
+ groups = tokenize( selector );
+
+ if ( (old = context.getAttribute("id")) ) {
+ nid = old.replace( rescape, "\\$&" );
} else {
context.setAttribute( "id", nid );
}
+ nid = "[id='" + nid + "'] ";
- groups = tokenize(selector, context, xml);
- // Trailing space is unnecessary
- // There is always a context check
- nid = "[id='" + nid + "']";
- for ( i = 0, len = groups.length; i < len; i++ ) {
- groups[i] = nid + groups[i].selector;
+ i = groups.length;
+ while ( i-- ) {
+ groups[i] = nid + groups[i].join("");
}
+ newContext = rsibling.test( selector ) && context.parentNode || context;
+ newSelector = groups.join(",");
+ }
+
+ if ( newSelector ) {
try {
push.apply( results, slice.call( newContext.querySelectorAll(
- groups.join(",")
+ newSelector
), 0 ) );
return results;
} catch(qsaError) {
@@ -5150,11 +5286,11 @@ if ( document.querySelectorAll ) {
// Gecko does not error, returns false instead
try {
matches.call( div, "[test!='']:sizzle" );
- rbuggyMatches.push( matchExpr["PSEUDO"].source, matchExpr["POS"].source, "!=" );
+ rbuggyMatches.push( "!=", pseudos );
} catch ( e ) {}
});
- // rbuggyMatches always contains :active, so no need for a length check
+ // rbuggyMatches always contains :active and :focus, so no need for a length check
rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );
Sizzle.matchesSelector = function( elem, expr ) {
@@ -5183,10 +5319,12 @@ if ( document.querySelectorAll ) {
}
// Deprecated
-Expr.setFilters["nth"] = Expr.setFilters["eq"];
+Expr.pseudos["nth"] = Expr.pseudos["eq"];
// Back-compat
-Expr.filters = Expr.pseudos;
+function setFilters() {}
+Expr.filters = setFilters.prototype = Expr.pseudos;
+Expr.setFilters = new setFilters();
// Override sizzle attribute retrieval
Sizzle.attr = jQuery.attr;
@@ -7123,10 +7261,10 @@ function buildParams( prefix, obj, traditional, add ) {
add( prefix, obj );
}
}
-var // Document location
- ajaxLocation,
- // Document location segments
+var
+ // Document location
ajaxLocParts,
+ ajaxLocation,
rhash = /#.*$/,
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
@@ -7643,7 +7781,7 @@ jQuery.extend({
// Set data for the fake xhr object
jqXHR.status = status;
- jqXHR.statusText = "" + ( nativeStatusText || statusText );
+ jqXHR.statusText = ( nativeStatusText || statusText ) + "";
// Success/Error
if ( isSuccess ) {
@@ -7703,14 +7841,11 @@ jQuery.extend({
// Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
- // Determine if a cross-domain request is in order
+ // A cross-domain request is in order when we have a protocol:host:port mismatch
if ( s.crossDomain == null ) {
- parts = rurl.exec( s.url.toLowerCase() );
- s.crossDomain = !!( parts &&
- ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
- ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
- ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
- );
+ parts = rurl.exec( s.url.toLowerCase() ) || false;
+ s.crossDomain = parts && ( parts.join(":") + ( parts[ 3 ] ? "" : parts[ 1 ] === "http:" ? 80 : 443 ) ) !==
+ ( ajaxLocParts.join(":") + ( ajaxLocParts[ 3 ] ? "" : ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) );
}
// Convert data if not already a string
@@ -8405,12 +8540,13 @@ var fxNow, timerId,
animationPrefilters = [ defaultPrefilter ],
tweeners = {
"*": [function( prop, value ) {
- var end, unit, prevScale,
+ var end, unit,
tween = this.createTween( prop, value ),
parts = rfxnum.exec( value ),
target = tween.cur(),
start = +target || 0,
- scale = 1;
+ scale = 1,
+ maxIterations = 20;
if ( parts ) {
end = +parts[2];
@@ -8426,17 +8562,15 @@ var fxNow, timerId,
do {
// If previous iteration zeroed out, double until we get *something*
// Use a string for doubling factor so we don't accidentally see scale as unchanged below
- prevScale = scale = scale || ".5";
+ scale = scale || ".5";
// Adjust and apply
start = start / scale;
jQuery.style( tween.elem, prop, start + unit );
- // Update scale, tolerating zeroes from tween.cur()
- scale = tween.cur() / target;
-
- // Stop looping if we've hit the mark or scale is unchanged
- } while ( scale !== 1 && scale !== prevScale );
+ // Update scale, tolerating zero or NaN from tween.cur()
+ // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
+ } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
}
tween.unit = unit;
@@ -9069,7 +9203,8 @@ jQuery.fn.offset = function( options ) {
});
}
- var box, docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft, top, left,
+ var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft,
+ box = { top: 0, left: 0 },
elem = this[ 0 ],
doc = elem && elem.ownerDocument;
@@ -9083,21 +9218,25 @@ jQuery.fn.offset = function( options ) {
docElem = doc.documentElement;
- // Make sure we're not dealing with a disconnected DOM node
+ // Make sure it's not a disconnected DOM node
if ( !jQuery.contains( docElem, elem ) ) {
- return { top: 0, left: 0 };
+ return box;
}
- box = elem.getBoundingClientRect();
+ // If we don't have gBCR, just use 0,0 rather than error
+ // BlackBerry 5, iOS 3 (original iPhone)
+ if ( typeof elem.getBoundingClientRect !== "undefined" ) {
+ box = elem.getBoundingClientRect();
+ }
win = getWindow( doc );
clientTop = docElem.clientTop || body.clientTop || 0;
clientLeft = docElem.clientLeft || body.clientLeft || 0;
scrollTop = win.pageYOffset || docElem.scrollTop;
scrollLeft = win.pageXOffset || docElem.scrollLeft;
- top = box.top + scrollTop - clientTop;
- left = box.left + scrollLeft - clientLeft;
-
- return { top: top, left: left };
+ return {
+ top: box.top + scrollTop - clientTop,
+ left: box.left + scrollLeft - clientLeft
+ };
};
jQuery.offset = {