2 * jQuery JavaScript Library v1.11.3
8 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
9 * Released under the MIT license
10 * http://jquery.org/license
12 * Date: 2015-04-28T16:19Z
15 (function( global, factory ) {
17 if ( typeof module === "object" && typeof module.exports === "object" ) {
18 // For CommonJS and CommonJS-like environments where a proper window is present,
19 // execute the factory and get jQuery
20 // For environments that do not inherently posses a window with a document
21 // (such as Node.js), expose a jQuery-making factory as module.exports
22 // This accentuates the need for the creation of a real window
23 // e.g. var jQuery = require("jquery")(window);
24 // See ticket #14549 for more info
25 module.exports = global.document ?
26 factory( global, true ) :
29 throw new Error( "jQuery requires a window with a document" );
37 // Pass this if window is not defined yet
38 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
40 // Can't do this because several apps including ASP.NET trace
41 // the stack via arguments.caller.callee and Firefox dies if
42 // you try to trace through "use strict" call chains. (#13335)
43 // Support: Firefox 18+
48 var slice = deletedIds.slice;
50 var concat = deletedIds.concat;
52 var push = deletedIds.push;
54 var indexOf = deletedIds.indexOf;
58 var toString = class2type.toString;
60 var hasOwn = class2type.hasOwnProperty;
69 // Define a local copy of jQuery
70 jQuery = function( selector, context ) {
71 // The jQuery object is actually just the init constructor 'enhanced'
72 // Need init if jQuery is called (just allow error to be thrown if not included)
73 return new jQuery.fn.init( selector, context );
76 // Support: Android<4.1, IE<9
77 // Make sure we trim BOM and NBSP
78 rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
80 // Matches dashed string for camelizing
82 rdashAlpha = /-([\da-z])/gi,
84 // Used by jQuery.camelCase as callback to replace()
85 fcamelCase = function( all, letter ) {
86 return letter.toUpperCase();
89 jQuery.fn = jQuery.prototype = {
90 // The current version of jQuery being used
95 // Start with an empty selector
98 // The default length of a jQuery object is 0
101 toArray: function() {
102 return slice.call( this );
105 // Get the Nth element in the matched element set OR
106 // Get the whole matched element set as a clean array
107 get: function( num ) {
110 // Return just the one element from the set
111 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
113 // Return all the elements in a clean array
117 // Take an array of elements and push it onto the stack
118 // (returning the new matched element set)
119 pushStack: function( elems ) {
121 // Build a new jQuery matched element set
122 var ret = jQuery.merge( this.constructor(), elems );
124 // Add the old object onto the stack (as a reference)
125 ret.prevObject = this;
126 ret.context = this.context;
128 // Return the newly-formed element set
132 // Execute a callback for every element in the matched set.
133 // (You can seed the arguments with an array of args, but this is
134 // only used internally.)
135 each: function( callback, args ) {
136 return jQuery.each( this, callback, args );
139 map: function( callback ) {
140 return this.pushStack( jQuery.map(this, function( elem, i ) {
141 return callback.call( elem, i, elem );
146 return this.pushStack( slice.apply( this, arguments ) );
154 return this.eq( -1 );
158 var len = this.length,
159 j = +i + ( i < 0 ? len : 0 );
160 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
164 return this.prevObject || this.constructor(null);
167 // For internal use only.
168 // Behaves like an Array's method, not like a jQuery method.
170 sort: deletedIds.sort,
171 splice: deletedIds.splice
174 jQuery.extend = jQuery.fn.extend = function() {
175 var src, copyIsArray, copy, name, options, clone,
176 target = arguments[0] || {},
178 length = arguments.length,
181 // Handle a deep copy situation
182 if ( typeof target === "boolean" ) {
185 // skip the boolean and the target
186 target = arguments[ i ] || {};
190 // Handle case when target is a string or something (possible in deep copy)
191 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
195 // extend jQuery itself if only one argument is passed
196 if ( i === length ) {
201 for ( ; i < length; i++ ) {
202 // Only deal with non-null/undefined values
203 if ( (options = arguments[ i ]) != null ) {
204 // Extend the base object
205 for ( name in options ) {
206 src = target[ name ];
207 copy = options[ name ];
209 // Prevent never-ending loop
210 if ( target === copy ) {
214 // Recurse if we're merging plain objects or arrays
215 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
218 clone = src && jQuery.isArray(src) ? src : [];
221 clone = src && jQuery.isPlainObject(src) ? src : {};
224 // Never move original objects, clone them
225 target[ name ] = jQuery.extend( deep, clone, copy );
227 // Don't bring in undefined values
228 } else if ( copy !== undefined ) {
229 target[ name ] = copy;
235 // Return the modified object
240 // Unique for each copy of jQuery on the page
241 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
243 // Assume jQuery is ready without the ready module
246 error: function( msg ) {
247 throw new Error( msg );
252 // See test/unit/core.js for details concerning isFunction.
253 // Since version 1.3, DOM methods and functions like alert
254 // aren't supported. They return false on IE (#2968).
255 isFunction: function( obj ) {
256 return jQuery.type(obj) === "function";
259 isArray: Array.isArray || function( obj ) {
260 return jQuery.type(obj) === "array";
263 isWindow: function( obj ) {
264 /* jshint eqeqeq: false */
265 return obj != null && obj == obj.window;
268 isNumeric: function( obj ) {
269 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
270 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
271 // subtraction forces infinities to NaN
272 // adding 1 corrects loss of precision from parseFloat (#15100)
273 return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
276 isEmptyObject: function( obj ) {
278 for ( name in obj ) {
284 isPlainObject: function( obj ) {
287 // Must be an Object.
288 // Because of IE, we also have to check the presence of the constructor property.
289 // Make sure that DOM nodes and window objects don't pass through, as well
290 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
295 // Not own constructor property must be Object
296 if ( obj.constructor &&
297 !hasOwn.call(obj, "constructor") &&
298 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
302 // IE8,9 Will throw exceptions on certain host objects #9897
307 // Handle iteration over inherited properties before own properties.
308 if ( support.ownLast ) {
310 return hasOwn.call( obj, key );
314 // Own properties are enumerated firstly, so to speed up,
315 // if last one is own, then all properties are own.
316 for ( key in obj ) {}
318 return key === undefined || hasOwn.call( obj, key );
321 type: function( obj ) {
325 return typeof obj === "object" || typeof obj === "function" ?
326 class2type[ toString.call(obj) ] || "object" :
330 // Evaluates a script in a global context
331 // Workarounds based on findings by Jim Driscoll
332 // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
333 globalEval: function( data ) {
334 if ( data && jQuery.trim( data ) ) {
335 // We use execScript on Internet Explorer
336 // We use an anonymous function so that context is window
337 // rather than jQuery in Firefox
338 ( window.execScript || function( data ) {
339 window[ "eval" ].call( window, data );
344 // Convert dashed to camelCase; used by the css and data modules
345 // Microsoft forgot to hump their vendor prefix (#9572)
346 camelCase: function( string ) {
347 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
350 nodeName: function( elem, name ) {
351 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
354 // args is for internal usage only
355 each: function( obj, callback, args ) {
359 isArray = isArraylike( obj );
363 for ( ; i < length; i++ ) {
364 value = callback.apply( obj[ i ], args );
366 if ( value === false ) {
372 value = callback.apply( obj[ i ], args );
374 if ( value === false ) {
380 // A special, fast, case for the most common use of each
383 for ( ; i < length; i++ ) {
384 value = callback.call( obj[ i ], i, obj[ i ] );
386 if ( value === false ) {
392 value = callback.call( obj[ i ], i, obj[ i ] );
394 if ( value === false ) {
404 // Support: Android<4.1, IE<9
405 trim: function( text ) {
406 return text == null ?
408 ( text + "" ).replace( rtrim, "" );
411 // results is for internal usage only
412 makeArray: function( arr, results ) {
413 var ret = results || [];
416 if ( isArraylike( Object(arr) ) ) {
418 typeof arr === "string" ?
422 push.call( ret, arr );
429 inArray: function( elem, arr, i ) {
434 return indexOf.call( arr, elem, i );
438 i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
440 for ( ; i < len; i++ ) {
441 // Skip accessing in sparse arrays
442 if ( i in arr && arr[ i ] === elem ) {
451 merge: function( first, second ) {
452 var len = +second.length,
457 first[ i++ ] = second[ j++ ];
461 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
463 while ( second[j] !== undefined ) {
464 first[ i++ ] = second[ j++ ];
473 grep: function( elems, callback, invert ) {
477 length = elems.length,
478 callbackExpect = !invert;
480 // Go through the array, only saving the items
481 // that pass the validator function
482 for ( ; i < length; i++ ) {
483 callbackInverse = !callback( elems[ i ], i );
484 if ( callbackInverse !== callbackExpect ) {
485 matches.push( elems[ i ] );
492 // arg is for internal usage only
493 map: function( elems, callback, arg ) {
496 length = elems.length,
497 isArray = isArraylike( elems ),
500 // Go through the array, translating each of the items to their new values
502 for ( ; i < length; i++ ) {
503 value = callback( elems[ i ], i, arg );
505 if ( value != null ) {
510 // Go through every key on the object,
513 value = callback( elems[ i ], i, arg );
515 if ( value != null ) {
521 // Flatten any nested arrays
522 return concat.apply( [], ret );
525 // A global GUID counter for objects
528 // Bind a function to a context, optionally partially applying any
530 proxy: function( fn, context ) {
531 var args, proxy, tmp;
533 if ( typeof context === "string" ) {
539 // Quick check to determine if target is callable, in the spec
540 // this throws a TypeError, but we will just return undefined.
541 if ( !jQuery.isFunction( fn ) ) {
546 args = slice.call( arguments, 2 );
548 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
551 // Set the guid of unique handler to the same of original handler, so it can be removed
552 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
558 return +( new Date() );
561 // jQuery.support is not used in Core but other projects attach their
562 // properties to it so it needs to exist.
566 // Populate the class2type map
567 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
568 class2type[ "[object " + name + "]" ] = name.toLowerCase();
571 function isArraylike( obj ) {
573 // Support: iOS 8.2 (not reproducible in simulator)
574 // `in` check used to prevent JIT error (gh-2145)
575 // hasOwn isn't used here due to false negatives
576 // regarding Nodelist length in IE
577 var length = "length" in obj && obj.length,
578 type = jQuery.type( obj );
580 if ( type === "function" || jQuery.isWindow( obj ) ) {
584 if ( obj.nodeType === 1 && length ) {
588 return type === "array" || length === 0 ||
589 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
593 * Sizzle CSS Selector Engine v2.2.0-pre
594 * http://sizzlejs.com/
596 * Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors
597 * Released under the MIT license
598 * http://jquery.org/license
602 (function( window ) {
616 // Local document vars
626 // Instance-specific data
627 expando = "sizzle" + 1 * new Date(),
628 preferredDoc = window.document,
631 classCache = createCache(),
632 tokenCache = createCache(),
633 compilerCache = createCache(),
634 sortOrder = function( a, b ) {
641 // General-purpose constants
642 MAX_NEGATIVE = 1 << 31,
645 hasOwn = ({}).hasOwnProperty,
648 push_native = arr.push,
651 // Use a stripped-down indexOf as it's faster than native
652 // http://jsperf.com/thor-indexof-vs-for/5
653 indexOf = function( list, elem ) {
656 for ( ; i < len; i++ ) {
657 if ( list[i] === elem ) {
664 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
666 // Regular expressions
668 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
669 whitespace = "[\\x20\\t\\r\\n\\f]",
670 // http://www.w3.org/TR/css3-syntax/#characters
671 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
673 // Loosely modeled on CSS identifier characters
674 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
675 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
676 identifier = characterEncoding.replace( "w", "w#" ),
678 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
679 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
680 // Operator (capture 2)
681 "*([*^$|!~]?=)" + whitespace +
682 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
683 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
686 pseudos = ":(" + characterEncoding + ")(?:\\((" +
687 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
688 // 1. quoted (capture 3; capture 4 or capture 5)
689 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
690 // 2. simple (capture 6)
691 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
692 // 3. anything else (capture 2)
696 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
697 rwhitespace = new RegExp( whitespace + "+", "g" ),
698 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
700 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
701 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
703 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
705 rpseudo = new RegExp( pseudos ),
706 ridentifier = new RegExp( "^" + identifier + "$" ),
709 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
710 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
711 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
712 "ATTR": new RegExp( "^" + attributes ),
713 "PSEUDO": new RegExp( "^" + pseudos ),
714 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
715 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
716 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
717 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
718 // For use in libraries implementing .is()
719 // We use this for POS matching in `select`
720 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
721 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
724 rinputs = /^(?:input|select|textarea|button)$/i,
727 rnative = /^[^{]+\{\s*\[native \w/,
729 // Easily-parseable/retrievable ID or TAG or CLASS selectors
730 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
735 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
736 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
737 funescape = function( _, escaped, escapedWhitespace ) {
738 var high = "0x" + escaped - 0x10000;
739 // NaN means non-codepoint
740 // Support: Firefox<24
741 // Workaround erroneous numeric interpretation of +"0x"
742 return high !== high || escapedWhitespace ?
746 String.fromCharCode( high + 0x10000 ) :
747 // Supplemental Plane codepoint (surrogate pair)
748 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
753 // Removing the function wrapper causes a "Permission Denied"
755 unloadHandler = function() {
759 // Optimize for push.apply( _, NodeList )
762 (arr = slice.call( preferredDoc.childNodes )),
763 preferredDoc.childNodes
765 // Support: Android<4.0
766 // Detect silently failing push.apply
767 arr[ preferredDoc.childNodes.length ].nodeType;
769 push = { apply: arr.length ?
771 // Leverage slice if possible
772 function( target, els ) {
773 push_native.apply( target, slice.call(els) );
777 // Otherwise append directly
778 function( target, els ) {
779 var j = target.length,
781 // Can't trust NodeList.length
782 while ( (target[j++] = els[i++]) ) {}
783 target.length = j - 1;
788 function Sizzle( selector, context, results, seed ) {
789 var match, elem, m, nodeType,
791 i, groups, old, nid, newContext, newSelector;
793 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
794 setDocument( context );
797 context = context || document;
798 results = results || [];
799 nodeType = context.nodeType;
801 if ( typeof selector !== "string" || !selector ||
802 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
807 if ( !seed && documentIsHTML ) {
809 // Try to shortcut find operations when possible (e.g., not under DocumentFragment)
810 if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
811 // Speed-up: Sizzle("#ID")
812 if ( (m = match[1]) ) {
813 if ( nodeType === 9 ) {
814 elem = context.getElementById( m );
815 // Check parentNode to catch when Blackberry 4.6 returns
816 // nodes that are no longer in the document (jQuery #6963)
817 if ( elem && elem.parentNode ) {
818 // Handle the case where IE, Opera, and Webkit return items
819 // by name instead of ID
820 if ( elem.id === m ) {
821 results.push( elem );
828 // Context is not a document
829 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
830 contains( context, elem ) && elem.id === m ) {
831 results.push( elem );
836 // Speed-up: Sizzle("TAG")
837 } else if ( match[2] ) {
838 push.apply( results, context.getElementsByTagName( selector ) );
841 // Speed-up: Sizzle(".CLASS")
842 } else if ( (m = match[3]) && support.getElementsByClassName ) {
843 push.apply( results, context.getElementsByClassName( m ) );
849 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
851 newContext = context;
852 newSelector = nodeType !== 1 && selector;
854 // qSA works strangely on Element-rooted queries
855 // We can work around this by specifying an extra ID on the root
856 // and working up from there (Thanks to Andrew Dupont for the technique)
857 // IE 8 doesn't work on object elements
858 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
859 groups = tokenize( selector );
861 if ( (old = context.getAttribute("id")) ) {
862 nid = old.replace( rescape, "\\$&" );
864 context.setAttribute( "id", nid );
866 nid = "[id='" + nid + "'] ";
870 groups[i] = nid + toSelector( groups[i] );
872 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
873 newSelector = groups.join(",");
879 newContext.querySelectorAll( newSelector )
885 context.removeAttribute("id");
893 return select( selector.replace( rtrim, "$1" ), context, results, seed );
897 * Create key-value caches of limited size
898 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
899 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
900 * deleting the oldest entry
902 function createCache() {
905 function cache( key, value ) {
906 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
907 if ( keys.push( key + " " ) > Expr.cacheLength ) {
908 // Only keep the most recent entries
909 delete cache[ keys.shift() ];
911 return (cache[ key + " " ] = value);
917 * Mark a function for special use by Sizzle
918 * @param {Function} fn The function to mark
920 function markFunction( fn ) {
921 fn[ expando ] = true;
926 * Support testing using an element
927 * @param {Function} fn Passed the created div and expects a boolean result
929 function assert( fn ) {
930 var div = document.createElement("div");
937 // Remove from its parent by default
938 if ( div.parentNode ) {
939 div.parentNode.removeChild( div );
941 // release memory in IE
947 * Adds the same handler for all of the specified attrs
948 * @param {String} attrs Pipe-separated list of attributes
949 * @param {Function} handler The method that will be applied
951 function addHandle( attrs, handler ) {
952 var arr = attrs.split("|"),
956 Expr.attrHandle[ arr[i] ] = handler;
961 * Checks document order of two siblings
964 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
966 function siblingCheck( a, b ) {
968 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
969 ( ~b.sourceIndex || MAX_NEGATIVE ) -
970 ( ~a.sourceIndex || MAX_NEGATIVE );
972 // Use IE sourceIndex if available on both nodes
977 // Check if b follows a
979 while ( (cur = cur.nextSibling) ) {
990 * Returns a function to use in pseudos for input types
991 * @param {String} type
993 function createInputPseudo( type ) {
994 return function( elem ) {
995 var name = elem.nodeName.toLowerCase();
996 return name === "input" && elem.type === type;
1001 * Returns a function to use in pseudos for buttons
1002 * @param {String} type
1004 function createButtonPseudo( type ) {
1005 return function( elem ) {
1006 var name = elem.nodeName.toLowerCase();
1007 return (name === "input" || name === "button") && elem.type === type;
1012 * Returns a function to use in pseudos for positionals
1013 * @param {Function} fn
1015 function createPositionalPseudo( fn ) {
1016 return markFunction(function( argument ) {
1017 argument = +argument;
1018 return markFunction(function( seed, matches ) {
1020 matchIndexes = fn( [], seed.length, argument ),
1021 i = matchIndexes.length;
1023 // Match elements found at the specified indexes
1025 if ( seed[ (j = matchIndexes[i]) ] ) {
1026 seed[j] = !(matches[j] = seed[j]);
1034 * Checks a node for validity as a Sizzle context
1035 * @param {Element|Object=} context
1036 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1038 function testContext( context ) {
1039 return context && typeof context.getElementsByTagName !== "undefined" && context;
1042 // Expose support vars for convenience
1043 support = Sizzle.support = {};
1047 * @param {Element|Object} elem An element or a document
1048 * @returns {Boolean} True iff elem is a non-HTML XML node
1050 isXML = Sizzle.isXML = function( elem ) {
1051 // documentElement is verified for cases where it doesn't yet exist
1052 // (such as loading iframes in IE - #4833)
1053 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
1054 return documentElement ? documentElement.nodeName !== "HTML" : false;
1058 * Sets document-related variables once based on the current document
1059 * @param {Element|Object} [doc] An element or document object to use to set the document
1060 * @returns {Object} Returns the current document
1062 setDocument = Sizzle.setDocument = function( node ) {
1063 var hasCompare, parent,
1064 doc = node ? node.ownerDocument || node : preferredDoc;
1066 // If no document and documentElement is available, return
1067 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
1073 docElem = doc.documentElement;
1074 parent = doc.defaultView;
1077 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
1078 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
1079 // IE6-8 do not support the defaultView property so parent will be undefined
1080 if ( parent && parent !== parent.top ) {
1081 // IE11 does not have attachEvent, so all must suffer
1082 if ( parent.addEventListener ) {
1083 parent.addEventListener( "unload", unloadHandler, false );
1084 } else if ( parent.attachEvent ) {
1085 parent.attachEvent( "onunload", unloadHandler );
1090 ---------------------------------------------------------------------- */
1091 documentIsHTML = !isXML( doc );
1094 ---------------------------------------------------------------------- */
1097 // Verify that getAttribute really returns attributes and not properties
1098 // (excepting IE8 booleans)
1099 support.attributes = assert(function( div ) {
1100 div.className = "i";
1101 return !div.getAttribute("className");
1105 ---------------------------------------------------------------------- */
1107 // Check if getElementsByTagName("*") returns only elements
1108 support.getElementsByTagName = assert(function( div ) {
1109 div.appendChild( doc.createComment("") );
1110 return !div.getElementsByTagName("*").length;
1114 support.getElementsByClassName = rnative.test( doc.getElementsByClassName );
1117 // Check if getElementById returns elements by name
1118 // The broken getElementById methods don't pick up programatically-set names,
1119 // so use a roundabout getElementsByName test
1120 support.getById = assert(function( div ) {
1121 docElem.appendChild( div ).id = expando;
1122 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
1125 // ID find and filter
1126 if ( support.getById ) {
1127 Expr.find["ID"] = function( id, context ) {
1128 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1129 var m = context.getElementById( id );
1130 // Check parentNode to catch when Blackberry 4.6 returns
1131 // nodes that are no longer in the document #6963
1132 return m && m.parentNode ? [ m ] : [];
1135 Expr.filter["ID"] = function( id ) {
1136 var attrId = id.replace( runescape, funescape );
1137 return function( elem ) {
1138 return elem.getAttribute("id") === attrId;
1143 // getElementById is not reliable as a find shortcut
1144 delete Expr.find["ID"];
1146 Expr.filter["ID"] = function( id ) {
1147 var attrId = id.replace( runescape, funescape );
1148 return function( elem ) {
1149 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
1150 return node && node.value === attrId;
1156 Expr.find["TAG"] = support.getElementsByTagName ?
1157 function( tag, context ) {
1158 if ( typeof context.getElementsByTagName !== "undefined" ) {
1159 return context.getElementsByTagName( tag );
1161 // DocumentFragment nodes don't have gEBTN
1162 } else if ( support.qsa ) {
1163 return context.querySelectorAll( tag );
1167 function( tag, context ) {
1171 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1172 results = context.getElementsByTagName( tag );
1174 // Filter out possible comments
1175 if ( tag === "*" ) {
1176 while ( (elem = results[i++]) ) {
1177 if ( elem.nodeType === 1 ) {
1188 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
1189 if ( documentIsHTML ) {
1190 return context.getElementsByClassName( className );
1194 /* QSA/matchesSelector
1195 ---------------------------------------------------------------------- */
1197 // QSA and matchesSelector support
1199 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1202 // qSa(:focus) reports false when true (Chrome 21)
1203 // We allow this because of a bug in IE8/9 that throws an error
1204 // whenever `document.activeElement` is accessed on an iframe
1205 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1206 // See http://bugs.jquery.com/ticket/13378
1209 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
1211 // Regex strategy adopted from Diego Perini
1212 assert(function( div ) {
1213 // Select is set to empty string on purpose
1214 // This is to test IE's treatment of not explicitly
1215 // setting a boolean content attribute,
1216 // since its presence should be enough
1217 // http://bugs.jquery.com/ticket/12359
1218 docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
1219 "<select id='" + expando + "-\f]' msallowcapture=''>" +
1220 "<option selected=''></option></select>";
1222 // Support: IE8, Opera 11-12.16
1223 // Nothing should be selected when empty strings follow ^= or $= or *=
1224 // The test attribute must be unknown in Opera but "safe" for WinRT
1225 // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1226 if ( div.querySelectorAll("[msallowcapture^='']").length ) {
1227 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1231 // Boolean attributes and "value" are not treated correctly
1232 if ( !div.querySelectorAll("[selected]").length ) {
1233 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1236 // Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+
1237 if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
1238 rbuggyQSA.push("~=");
1241 // Webkit/Opera - :checked should return selected option elements
1242 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1243 // IE8 throws error here and will not see later tests
1244 if ( !div.querySelectorAll(":checked").length ) {
1245 rbuggyQSA.push(":checked");
1248 // Support: Safari 8+, iOS 8+
1249 // https://bugs.webkit.org/show_bug.cgi?id=136851
1250 // In-page `selector#id sibing-combinator selector` fails
1251 if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
1252 rbuggyQSA.push(".#.+[+~]");
1256 assert(function( div ) {
1257 // Support: Windows 8 Native Apps
1258 // The type and name attributes are restricted during .innerHTML assignment
1259 var input = doc.createElement("input");
1260 input.setAttribute( "type", "hidden" );
1261 div.appendChild( input ).setAttribute( "name", "D" );
1264 // Enforce case-sensitivity of name attribute
1265 if ( div.querySelectorAll("[name=d]").length ) {
1266 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1269 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1270 // IE8 throws error here and will not see later tests
1271 if ( !div.querySelectorAll(":enabled").length ) {
1272 rbuggyQSA.push( ":enabled", ":disabled" );
1275 // Opera 10-11 does not throw on post-comma invalid pseudos
1276 div.querySelectorAll("*,:x");
1277 rbuggyQSA.push(",.*:");
1281 if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
1282 docElem.webkitMatchesSelector ||
1283 docElem.mozMatchesSelector ||
1284 docElem.oMatchesSelector ||
1285 docElem.msMatchesSelector) )) ) {
1287 assert(function( div ) {
1288 // Check to see if it's possible to do matchesSelector
1289 // on a disconnected node (IE 9)
1290 support.disconnectedMatch = matches.call( div, "div" );
1292 // This should fail with an exception
1293 // Gecko does not error, returns false instead
1294 matches.call( div, "[s!='']:x" );
1295 rbuggyMatches.push( "!=", pseudos );
1299 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
1300 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
1303 ---------------------------------------------------------------------- */
1304 hasCompare = rnative.test( docElem.compareDocumentPosition );
1306 // Element contains another
1307 // Purposefully does not implement inclusive descendent
1308 // As in, an element does not contain itself
1309 contains = hasCompare || rnative.test( docElem.contains ) ?
1311 var adown = a.nodeType === 9 ? a.documentElement : a,
1312 bup = b && b.parentNode;
1313 return a === bup || !!( bup && bup.nodeType === 1 && (
1315 adown.contains( bup ) :
1316 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1321 while ( (b = b.parentNode) ) {
1331 ---------------------------------------------------------------------- */
1333 // Document order sorting
1334 sortOrder = hasCompare ?
1337 // Flag for duplicate removal
1339 hasDuplicate = true;
1343 // Sort on method existence if only one input has compareDocumentPosition
1344 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1349 // Calculate position if both inputs belong to the same document
1350 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
1351 a.compareDocumentPosition( b ) :
1353 // Otherwise we know they are disconnected
1356 // Disconnected nodes
1358 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
1360 // Choose the first element that is related to our preferred document
1361 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
1364 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
1368 // Maintain original order
1370 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1374 return compare & 4 ? -1 : 1;
1377 // Exit early if the nodes are identical
1379 hasDuplicate = true;
1390 // Parentless nodes are either documents or disconnected
1391 if ( !aup || !bup ) {
1392 return a === doc ? -1 :
1397 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1400 // If the nodes are siblings, we can do a quick check
1401 } else if ( aup === bup ) {
1402 return siblingCheck( a, b );
1405 // Otherwise we need full lists of their ancestors for comparison
1407 while ( (cur = cur.parentNode) ) {
1411 while ( (cur = cur.parentNode) ) {
1415 // Walk down the tree looking for a discrepancy
1416 while ( ap[i] === bp[i] ) {
1421 // Do a sibling check if the nodes have a common ancestor
1422 siblingCheck( ap[i], bp[i] ) :
1424 // Otherwise nodes in our document sort first
1425 ap[i] === preferredDoc ? -1 :
1426 bp[i] === preferredDoc ? 1 :
1433 Sizzle.matches = function( expr, elements ) {
1434 return Sizzle( expr, null, null, elements );
1437 Sizzle.matchesSelector = function( elem, expr ) {
1438 // Set document vars if needed
1439 if ( ( elem.ownerDocument || elem ) !== document ) {
1440 setDocument( elem );
1443 // Make sure that attribute selectors are quoted
1444 expr = expr.replace( rattributeQuotes, "='$1']" );
1446 if ( support.matchesSelector && documentIsHTML &&
1447 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1448 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1451 var ret = matches.call( elem, expr );
1453 // IE 9's matchesSelector returns false on disconnected nodes
1454 if ( ret || support.disconnectedMatch ||
1455 // As well, disconnected nodes are said to be in a document
1457 elem.document && elem.document.nodeType !== 11 ) {
1463 return Sizzle( expr, document, null, [ elem ] ).length > 0;
1466 Sizzle.contains = function( context, elem ) {
1467 // Set document vars if needed
1468 if ( ( context.ownerDocument || context ) !== document ) {
1469 setDocument( context );
1471 return contains( context, elem );
1474 Sizzle.attr = function( elem, name ) {
1475 // Set document vars if needed
1476 if ( ( elem.ownerDocument || elem ) !== document ) {
1477 setDocument( elem );
1480 var fn = Expr.attrHandle[ name.toLowerCase() ],
1481 // Don't get fooled by Object.prototype properties (jQuery #13807)
1482 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1483 fn( elem, name, !documentIsHTML ) :
1486 return val !== undefined ?
1488 support.attributes || !documentIsHTML ?
1489 elem.getAttribute( name ) :
1490 (val = elem.getAttributeNode(name)) && val.specified ?
1495 Sizzle.error = function( msg ) {
1496 throw new Error( "Syntax error, unrecognized expression: " + msg );
1500 * Document sorting and removing duplicates
1501 * @param {ArrayLike} results
1503 Sizzle.uniqueSort = function( results ) {
1509 // Unless we *know* we can detect duplicates, assume their presence
1510 hasDuplicate = !support.detectDuplicates;
1511 sortInput = !support.sortStable && results.slice( 0 );
1512 results.sort( sortOrder );
1514 if ( hasDuplicate ) {
1515 while ( (elem = results[i++]) ) {
1516 if ( elem === results[ i ] ) {
1517 j = duplicates.push( i );
1521 results.splice( duplicates[ j ], 1 );
1525 // Clear input after sorting to release objects
1526 // See https://github.com/jquery/sizzle/pull/225
1533 * Utility function for retrieving the text value of an array of DOM nodes
1534 * @param {Array|Element} elem
1536 getText = Sizzle.getText = function( elem ) {
1540 nodeType = elem.nodeType;
1543 // If no nodeType, this is expected to be an array
1544 while ( (node = elem[i++]) ) {
1545 // Do not traverse comment nodes
1546 ret += getText( node );
1548 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1549 // Use textContent for elements
1550 // innerText usage removed for consistency of new lines (jQuery #11153)
1551 if ( typeof elem.textContent === "string" ) {
1552 return elem.textContent;
1554 // Traverse its children
1555 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1556 ret += getText( elem );
1559 } else if ( nodeType === 3 || nodeType === 4 ) {
1560 return elem.nodeValue;
1562 // Do not include comment or processing instruction nodes
1567 Expr = Sizzle.selectors = {
1569 // Can be adjusted by the user
1572 createPseudo: markFunction,
1581 ">": { dir: "parentNode", first: true },
1582 " ": { dir: "parentNode" },
1583 "+": { dir: "previousSibling", first: true },
1584 "~": { dir: "previousSibling" }
1588 "ATTR": function( match ) {
1589 match[1] = match[1].replace( runescape, funescape );
1591 // Move the given value to match[3] whether quoted or unquoted
1592 match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
1594 if ( match[2] === "~=" ) {
1595 match[3] = " " + match[3] + " ";
1598 return match.slice( 0, 4 );
1601 "CHILD": function( match ) {
1602 /* matches from matchExpr["CHILD"]
1603 1 type (only|nth|...)
1604 2 what (child|of-type)
1605 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1606 4 xn-component of xn+y argument ([+-]?\d*n|)
1607 5 sign of xn-component
1609 7 sign of y-component
1612 match[1] = match[1].toLowerCase();
1614 if ( match[1].slice( 0, 3 ) === "nth" ) {
1615 // nth-* requires argument
1617 Sizzle.error( match[0] );
1620 // numeric x and y parameters for Expr.filter.CHILD
1621 // remember that false/true cast respectively to 0/1
1622 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1623 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1625 // other types prohibit arguments
1626 } else if ( match[3] ) {
1627 Sizzle.error( match[0] );
1633 "PSEUDO": function( match ) {
1635 unquoted = !match[6] && match[2];
1637 if ( matchExpr["CHILD"].test( match[0] ) ) {
1641 // Accept quoted arguments as-is
1643 match[2] = match[4] || match[5] || "";
1645 // Strip excess characters from unquoted arguments
1646 } else if ( unquoted && rpseudo.test( unquoted ) &&
1647 // Get excess from tokenize (recursively)
1648 (excess = tokenize( unquoted, true )) &&
1649 // advance to the next closing parenthesis
1650 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
1652 // excess is a negative index
1653 match[0] = match[0].slice( 0, excess );
1654 match[2] = unquoted.slice( 0, excess );
1657 // Return only captures needed by the pseudo filter method (type and argument)
1658 return match.slice( 0, 3 );
1664 "TAG": function( nodeNameSelector ) {
1665 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1666 return nodeNameSelector === "*" ?
1667 function() { return true; } :
1669 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1673 "CLASS": function( className ) {
1674 var pattern = classCache[ className + " " ];
1677 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1678 classCache( className, function( elem ) {
1679 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
1683 "ATTR": function( name, operator, check ) {
1684 return function( elem ) {
1685 var result = Sizzle.attr( elem, name );
1687 if ( result == null ) {
1688 return operator === "!=";
1696 return operator === "=" ? result === check :
1697 operator === "!=" ? result !== check :
1698 operator === "^=" ? check && result.indexOf( check ) === 0 :
1699 operator === "*=" ? check && result.indexOf( check ) > -1 :
1700 operator === "$=" ? check && result.slice( -check.length ) === check :
1701 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
1702 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1707 "CHILD": function( type, what, argument, first, last ) {
1708 var simple = type.slice( 0, 3 ) !== "nth",
1709 forward = type.slice( -4 ) !== "last",
1710 ofType = what === "of-type";
1712 return first === 1 && last === 0 ?
1714 // Shortcut for :nth-*(n)
1716 return !!elem.parentNode;
1719 function( elem, context, xml ) {
1720 var cache, outerCache, node, diff, nodeIndex, start,
1721 dir = simple !== forward ? "nextSibling" : "previousSibling",
1722 parent = elem.parentNode,
1723 name = ofType && elem.nodeName.toLowerCase(),
1724 useCache = !xml && !ofType;
1728 // :(first|last|only)-(child|of-type)
1732 while ( (node = node[ dir ]) ) {
1733 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
1737 // Reverse direction for :only-* (if we haven't yet done so)
1738 start = dir = type === "only" && !start && "nextSibling";
1743 start = [ forward ? parent.firstChild : parent.lastChild ];
1745 // non-xml :nth-child(...) stores cache data on `parent`
1746 if ( forward && useCache ) {
1747 // Seek `elem` from a previously-cached index
1748 outerCache = parent[ expando ] || (parent[ expando ] = {});
1749 cache = outerCache[ type ] || [];
1750 nodeIndex = cache[0] === dirruns && cache[1];
1751 diff = cache[0] === dirruns && cache[2];
1752 node = nodeIndex && parent.childNodes[ nodeIndex ];
1754 while ( (node = ++nodeIndex && node && node[ dir ] ||
1756 // Fallback to seeking `elem` from the start
1757 (diff = nodeIndex = 0) || start.pop()) ) {
1759 // When found, cache indexes on `parent` and break
1760 if ( node.nodeType === 1 && ++diff && node === elem ) {
1761 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
1766 // Use previously-cached element index if available
1767 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
1770 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
1772 // Use the same loop as above to seek `elem` from the start
1773 while ( (node = ++nodeIndex && node && node[ dir ] ||
1774 (diff = nodeIndex = 0) || start.pop()) ) {
1776 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
1777 // Cache the index of each encountered element
1779 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
1782 if ( node === elem ) {
1789 // Incorporate the offset, then check against cycle size
1791 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1796 "PSEUDO": function( pseudo, argument ) {
1797 // pseudo-class names are case-insensitive
1798 // http://www.w3.org/TR/selectors/#pseudo-classes
1799 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1800 // Remember that setFilters inherits from pseudos
1802 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1803 Sizzle.error( "unsupported pseudo: " + pseudo );
1805 // The user may use createPseudo to indicate that
1806 // arguments are needed to create the filter function
1807 // just as Sizzle does
1808 if ( fn[ expando ] ) {
1809 return fn( argument );
1812 // But maintain support for old signatures
1813 if ( fn.length > 1 ) {
1814 args = [ pseudo, pseudo, "", argument ];
1815 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1816 markFunction(function( seed, matches ) {
1818 matched = fn( seed, argument ),
1821 idx = indexOf( seed, matched[i] );
1822 seed[ idx ] = !( matches[ idx ] = matched[i] );
1826 return fn( elem, 0, args );
1835 // Potentially complex pseudos
1836 "not": markFunction(function( selector ) {
1837 // Trim the selector passed to compile
1838 // to avoid treating leading and trailing
1839 // spaces as combinators
1842 matcher = compile( selector.replace( rtrim, "$1" ) );
1844 return matcher[ expando ] ?
1845 markFunction(function( seed, matches, context, xml ) {
1847 unmatched = matcher( seed, null, xml, [] ),
1850 // Match elements unmatched by `matcher`
1852 if ( (elem = unmatched[i]) ) {
1853 seed[i] = !(matches[i] = elem);
1857 function( elem, context, xml ) {
1859 matcher( input, null, xml, results );
1860 // Don't keep the element (issue #299)
1862 return !results.pop();
1866 "has": markFunction(function( selector ) {
1867 return function( elem ) {
1868 return Sizzle( selector, elem ).length > 0;
1872 "contains": markFunction(function( text ) {
1873 text = text.replace( runescape, funescape );
1874 return function( elem ) {
1875 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1879 // "Whether an element is represented by a :lang() selector
1880 // is based solely on the element's language value
1881 // being equal to the identifier C,
1882 // or beginning with the identifier C immediately followed by "-".
1883 // The matching of C against the element's language value is performed case-insensitively.
1884 // The identifier C does not have to be a valid language name."
1885 // http://www.w3.org/TR/selectors/#lang-pseudo
1886 "lang": markFunction( function( lang ) {
1887 // lang value must be a valid identifier
1888 if ( !ridentifier.test(lang || "") ) {
1889 Sizzle.error( "unsupported lang: " + lang );
1891 lang = lang.replace( runescape, funescape ).toLowerCase();
1892 return function( elem ) {
1895 if ( (elemLang = documentIsHTML ?
1897 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
1899 elemLang = elemLang.toLowerCase();
1900 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1902 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
1908 "target": function( elem ) {
1909 var hash = window.location && window.location.hash;
1910 return hash && hash.slice( 1 ) === elem.id;
1913 "root": function( elem ) {
1914 return elem === docElem;
1917 "focus": function( elem ) {
1918 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
1921 // Boolean properties
1922 "enabled": function( elem ) {
1923 return elem.disabled === false;
1926 "disabled": function( elem ) {
1927 return elem.disabled === true;
1930 "checked": function( elem ) {
1931 // In CSS3, :checked should return both checked and selected elements
1932 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1933 var nodeName = elem.nodeName.toLowerCase();
1934 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
1937 "selected": function( elem ) {
1938 // Accessing this property makes selected-by-default
1939 // options in Safari work properly
1940 if ( elem.parentNode ) {
1941 elem.parentNode.selectedIndex;
1944 return elem.selected === true;
1948 "empty": function( elem ) {
1949 // http://www.w3.org/TR/selectors/#empty-pseudo
1950 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1951 // but not by others (comment: 8; processing instruction: 7; etc.)
1952 // nodeType < 6 works because attributes (2) do not appear as children
1953 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1954 if ( elem.nodeType < 6 ) {
1961 "parent": function( elem ) {
1962 return !Expr.pseudos["empty"]( elem );
1965 // Element/input types
1966 "header": function( elem ) {
1967 return rheader.test( elem.nodeName );
1970 "input": function( elem ) {
1971 return rinputs.test( elem.nodeName );
1974 "button": function( elem ) {
1975 var name = elem.nodeName.toLowerCase();
1976 return name === "input" && elem.type === "button" || name === "button";
1979 "text": function( elem ) {
1981 return elem.nodeName.toLowerCase() === "input" &&
1982 elem.type === "text" &&
1985 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1986 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
1989 // Position-in-collection
1990 "first": createPositionalPseudo(function() {
1994 "last": createPositionalPseudo(function( matchIndexes, length ) {
1995 return [ length - 1 ];
1998 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
1999 return [ argument < 0 ? argument + length : argument ];
2002 "even": createPositionalPseudo(function( matchIndexes, length ) {
2004 for ( ; i < length; i += 2 ) {
2005 matchIndexes.push( i );
2007 return matchIndexes;
2010 "odd": createPositionalPseudo(function( matchIndexes, length ) {
2012 for ( ; i < length; i += 2 ) {
2013 matchIndexes.push( i );
2015 return matchIndexes;
2018 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2019 var i = argument < 0 ? argument + length : argument;
2020 for ( ; --i >= 0; ) {
2021 matchIndexes.push( i );
2023 return matchIndexes;
2026 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
2027 var i = argument < 0 ? argument + length : argument;
2028 for ( ; ++i < length; ) {
2029 matchIndexes.push( i );
2031 return matchIndexes;
2036 Expr.pseudos["nth"] = Expr.pseudos["eq"];
2038 // Add button/input type pseudos
2039 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2040 Expr.pseudos[ i ] = createInputPseudo( i );
2042 for ( i in { submit: true, reset: true } ) {
2043 Expr.pseudos[ i ] = createButtonPseudo( i );
2046 // Easy API for creating new setFilters
2047 function setFilters() {}
2048 setFilters.prototype = Expr.filters = Expr.pseudos;
2049 Expr.setFilters = new setFilters();
2051 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
2052 var matched, match, tokens, type,
2053 soFar, groups, preFilters,
2054 cached = tokenCache[ selector + " " ];
2057 return parseOnly ? 0 : cached.slice( 0 );
2062 preFilters = Expr.preFilter;
2066 // Comma and first run
2067 if ( !matched || (match = rcomma.exec( soFar )) ) {
2069 // Don't consume trailing commas as valid
2070 soFar = soFar.slice( match[0].length ) || soFar;
2072 groups.push( (tokens = []) );
2078 if ( (match = rcombinators.exec( soFar )) ) {
2079 matched = match.shift();
2082 // Cast descendant combinators to space
2083 type: match[0].replace( rtrim, " " )
2085 soFar = soFar.slice( matched.length );
2089 for ( type in Expr.filter ) {
2090 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
2091 (match = preFilters[ type ]( match ))) ) {
2092 matched = match.shift();
2098 soFar = soFar.slice( matched.length );
2107 // Return the length of the invalid excess
2108 // if we're just parsing
2109 // Otherwise, throw an error or return tokens
2113 Sizzle.error( selector ) :
2115 tokenCache( selector, groups ).slice( 0 );
2118 function toSelector( tokens ) {
2120 len = tokens.length,
2122 for ( ; i < len; i++ ) {
2123 selector += tokens[i].value;
2128 function addCombinator( matcher, combinator, base ) {
2129 var dir = combinator.dir,
2130 checkNonElements = base && dir === "parentNode",
2133 return combinator.first ?
2134 // Check against closest ancestor/preceding element
2135 function( elem, context, xml ) {
2136 while ( (elem = elem[ dir ]) ) {
2137 if ( elem.nodeType === 1 || checkNonElements ) {
2138 return matcher( elem, context, xml );
2143 // Check against all ancestor/preceding elements
2144 function( elem, context, xml ) {
2145 var oldCache, outerCache,
2146 newCache = [ dirruns, doneName ];
2148 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
2150 while ( (elem = elem[ dir ]) ) {
2151 if ( elem.nodeType === 1 || checkNonElements ) {
2152 if ( matcher( elem, context, xml ) ) {
2158 while ( (elem = elem[ dir ]) ) {
2159 if ( elem.nodeType === 1 || checkNonElements ) {
2160 outerCache = elem[ expando ] || (elem[ expando ] = {});
2161 if ( (oldCache = outerCache[ dir ]) &&
2162 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2164 // Assign to newCache so results back-propagate to previous elements
2165 return (newCache[ 2 ] = oldCache[ 2 ]);
2167 // Reuse newcache so results back-propagate to previous elements
2168 outerCache[ dir ] = newCache;
2170 // A match means we're done; a fail means we have to keep checking
2171 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
2181 function elementMatcher( matchers ) {
2182 return matchers.length > 1 ?
2183 function( elem, context, xml ) {
2184 var i = matchers.length;
2186 if ( !matchers[i]( elem, context, xml ) ) {
2195 function multipleContexts( selector, contexts, results ) {
2197 len = contexts.length;
2198 for ( ; i < len; i++ ) {
2199 Sizzle( selector, contexts[i], results );
2204 function condense( unmatched, map, filter, context, xml ) {
2208 len = unmatched.length,
2209 mapped = map != null;
2211 for ( ; i < len; i++ ) {
2212 if ( (elem = unmatched[i]) ) {
2213 if ( !filter || filter( elem, context, xml ) ) {
2214 newUnmatched.push( elem );
2222 return newUnmatched;
2225 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2226 if ( postFilter && !postFilter[ expando ] ) {
2227 postFilter = setMatcher( postFilter );
2229 if ( postFinder && !postFinder[ expando ] ) {
2230 postFinder = setMatcher( postFinder, postSelector );
2232 return markFunction(function( seed, results, context, xml ) {
2236 preexisting = results.length,
2238 // Get initial elements from seed or context
2239 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
2241 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2242 matcherIn = preFilter && ( seed || !selector ) ?
2243 condense( elems, preMap, preFilter, context, xml ) :
2246 matcherOut = matcher ?
2247 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2248 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2250 // ...intermediate processing is necessary
2253 // ...otherwise use results directly
2257 // Find primary matches
2259 matcher( matcherIn, matcherOut, context, xml );
2264 temp = condense( matcherOut, postMap );
2265 postFilter( temp, [], context, xml );
2267 // Un-match failing elements by moving them back to matcherIn
2270 if ( (elem = temp[i]) ) {
2271 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
2277 if ( postFinder || preFilter ) {
2279 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2281 i = matcherOut.length;
2283 if ( (elem = matcherOut[i]) ) {
2284 // Restore matcherIn since elem is not yet a final match
2285 temp.push( (matcherIn[i] = elem) );
2288 postFinder( null, (matcherOut = []), temp, xml );
2291 // Move matched elements from seed to results to keep them synchronized
2292 i = matcherOut.length;
2294 if ( (elem = matcherOut[i]) &&
2295 (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
2297 seed[temp] = !(results[temp] = elem);
2302 // Add elements to results, through postFinder if defined
2304 matcherOut = condense(
2305 matcherOut === results ?
2306 matcherOut.splice( preexisting, matcherOut.length ) :
2310 postFinder( null, results, matcherOut, xml );
2312 push.apply( results, matcherOut );
2318 function matcherFromTokens( tokens ) {
2319 var checkContext, matcher, j,
2320 len = tokens.length,
2321 leadingRelative = Expr.relative[ tokens[0].type ],
2322 implicitRelative = leadingRelative || Expr.relative[" "],
2323 i = leadingRelative ? 1 : 0,
2325 // The foundational matcher ensures that elements are reachable from top-level context(s)
2326 matchContext = addCombinator( function( elem ) {
2327 return elem === checkContext;
2328 }, implicitRelative, true ),
2329 matchAnyContext = addCombinator( function( elem ) {
2330 return indexOf( checkContext, elem ) > -1;
2331 }, implicitRelative, true ),
2332 matchers = [ function( elem, context, xml ) {
2333 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2334 (checkContext = context).nodeType ?
2335 matchContext( elem, context, xml ) :
2336 matchAnyContext( elem, context, xml ) );
2337 // Avoid hanging onto element (issue #299)
2338 checkContext = null;
2342 for ( ; i < len; i++ ) {
2343 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
2344 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
2346 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
2348 // Return special upon seeing a positional matcher
2349 if ( matcher[ expando ] ) {
2350 // Find the next relative operator (if any) for proper handling
2352 for ( ; j < len; j++ ) {
2353 if ( Expr.relative[ tokens[j].type ] ) {
2358 i > 1 && elementMatcher( matchers ),
2359 i > 1 && toSelector(
2360 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2361 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
2362 ).replace( rtrim, "$1" ),
2364 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2365 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
2366 j < len && toSelector( tokens )
2369 matchers.push( matcher );
2373 return elementMatcher( matchers );
2376 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2377 var bySet = setMatchers.length > 0,
2378 byElement = elementMatchers.length > 0,
2379 superMatcher = function( seed, context, xml, results, outermost ) {
2380 var elem, j, matcher,
2383 unmatched = seed && [],
2385 contextBackup = outermostContext,
2386 // We must always have either seed elements or outermost context
2387 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
2388 // Use integer dirruns iff this is the outermost matcher
2389 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
2393 outermostContext = context !== document && context;
2396 // Add elements passing elementMatchers directly to results
2397 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
2398 // Support: IE<9, Safari
2399 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2400 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
2401 if ( byElement && elem ) {
2403 while ( (matcher = elementMatchers[j++]) ) {
2404 if ( matcher( elem, context, xml ) ) {
2405 results.push( elem );
2410 dirruns = dirrunsUnique;
2414 // Track unmatched elements for set filters
2416 // They will have gone through all possible matchers
2417 if ( (elem = !matcher && elem) ) {
2421 // Lengthen the array for every element, matched or not
2423 unmatched.push( elem );
2428 // Apply set filters to unmatched elements
2430 if ( bySet && i !== matchedCount ) {
2432 while ( (matcher = setMatchers[j++]) ) {
2433 matcher( unmatched, setMatched, context, xml );
2437 // Reintegrate element matches to eliminate the need for sorting
2438 if ( matchedCount > 0 ) {
2440 if ( !(unmatched[i] || setMatched[i]) ) {
2441 setMatched[i] = pop.call( results );
2446 // Discard index placeholder values to get only actual matches
2447 setMatched = condense( setMatched );
2450 // Add matches to results
2451 push.apply( results, setMatched );
2453 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2454 if ( outermost && !seed && setMatched.length > 0 &&
2455 ( matchedCount + setMatchers.length ) > 1 ) {
2457 Sizzle.uniqueSort( results );
2461 // Override manipulation of globals by nested matchers
2463 dirruns = dirrunsUnique;
2464 outermostContext = contextBackup;
2471 markFunction( superMatcher ) :
2475 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
2478 elementMatchers = [],
2479 cached = compilerCache[ selector + " " ];
2482 // Generate a function of recursive functions that can be used to check each element
2484 match = tokenize( selector );
2488 cached = matcherFromTokens( match[i] );
2489 if ( cached[ expando ] ) {
2490 setMatchers.push( cached );
2492 elementMatchers.push( cached );
2496 // Cache the compiled function
2497 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
2499 // Save selector and tokenization
2500 cached.selector = selector;
2506 * A low-level selection function that works with Sizzle's compiled
2507 * selector functions
2508 * @param {String|Function} selector A selector or a pre-compiled
2509 * selector function built with Sizzle.compile
2510 * @param {Element} context
2511 * @param {Array} [results]
2512 * @param {Array} [seed] A set of elements to match against
2514 select = Sizzle.select = function( selector, context, results, seed ) {
2515 var i, tokens, token, type, find,
2516 compiled = typeof selector === "function" && selector,
2517 match = !seed && tokenize( (selector = compiled.selector || selector) );
2519 results = results || [];
2521 // Try to minimize operations if there is no seed and only one group
2522 if ( match.length === 1 ) {
2524 // Take a shortcut and set the context if the root selector is an ID
2525 tokens = match[0] = match[0].slice( 0 );
2526 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
2527 support.getById && context.nodeType === 9 && documentIsHTML &&
2528 Expr.relative[ tokens[1].type ] ) {
2530 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
2534 // Precompiled matchers will still verify ancestry, so step up a level
2535 } else if ( compiled ) {
2536 context = context.parentNode;
2539 selector = selector.slice( tokens.shift().value.length );
2542 // Fetch a seed set for right-to-left matching
2543 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
2547 // Abort if we hit a combinator
2548 if ( Expr.relative[ (type = token.type) ] ) {
2551 if ( (find = Expr.find[ type ]) ) {
2552 // Search, expanding context for leading sibling combinators
2554 token.matches[0].replace( runescape, funescape ),
2555 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
2558 // If seed is empty or no tokens remain, we can return early
2559 tokens.splice( i, 1 );
2560 selector = seed.length && toSelector( tokens );
2562 push.apply( results, seed );
2572 // Compile and execute a filtering function if one is not provided
2573 // Provide `match` to avoid retokenization if we modified the selector above
2574 ( compiled || compile( selector, match ) )(
2579 rsibling.test( selector ) && testContext( context.parentNode ) || context
2584 // One-time assignments
2587 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
2589 // Support: Chrome 14-35+
2590 // Always assume duplicates if they aren't passed to the comparison function
2591 support.detectDuplicates = !!hasDuplicate;
2593 // Initialize against the default document
2596 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2597 // Detached nodes confoundingly follow *each other*
2598 support.sortDetached = assert(function( div1 ) {
2599 // Should return 1, but returns 4 (following)
2600 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
2604 // Prevent attribute/property "interpolation"
2605 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2606 if ( !assert(function( div ) {
2607 div.innerHTML = "<a href='#'></a>";
2608 return div.firstChild.getAttribute("href") === "#" ;
2610 addHandle( "type|href|height|width", function( elem, name, isXML ) {
2612 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2618 // Use defaultValue in place of getAttribute("value")
2619 if ( !support.attributes || !assert(function( div ) {
2620 div.innerHTML = "<input/>";
2621 div.firstChild.setAttribute( "value", "" );
2622 return div.firstChild.getAttribute( "value" ) === "";
2624 addHandle( "value", function( elem, name, isXML ) {
2625 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2626 return elem.defaultValue;
2632 // Use getAttributeNode to fetch booleans when getAttribute lies
2633 if ( !assert(function( div ) {
2634 return div.getAttribute("disabled") == null;
2636 addHandle( booleans, function( elem, name, isXML ) {
2639 return elem[ name ] === true ? name.toLowerCase() :
2640 (val = elem.getAttributeNode( name )) && val.specified ?
2653 jQuery.find = Sizzle;
2654 jQuery.expr = Sizzle.selectors;
2655 jQuery.expr[":"] = jQuery.expr.pseudos;
2656 jQuery.unique = Sizzle.uniqueSort;
2657 jQuery.text = Sizzle.getText;
2658 jQuery.isXMLDoc = Sizzle.isXML;
2659 jQuery.contains = Sizzle.contains;
2663 var rneedsContext = jQuery.expr.match.needsContext;
2665 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
2669 var risSimple = /^.[^:#\[\.,]*$/;
2671 // Implement the identical functionality for filter and not
2672 function winnow( elements, qualifier, not ) {
2673 if ( jQuery.isFunction( qualifier ) ) {
2674 return jQuery.grep( elements, function( elem, i ) {
2676 return !!qualifier.call( elem, i, elem ) !== not;
2681 if ( qualifier.nodeType ) {
2682 return jQuery.grep( elements, function( elem ) {
2683 return ( elem === qualifier ) !== not;
2688 if ( typeof qualifier === "string" ) {
2689 if ( risSimple.test( qualifier ) ) {
2690 return jQuery.filter( qualifier, elements, not );
2693 qualifier = jQuery.filter( qualifier, elements );
2696 return jQuery.grep( elements, function( elem ) {
2697 return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
2701 jQuery.filter = function( expr, elems, not ) {
2702 var elem = elems[ 0 ];
2705 expr = ":not(" + expr + ")";
2708 return elems.length === 1 && elem.nodeType === 1 ?
2709 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
2710 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
2711 return elem.nodeType === 1;
2716 find: function( selector ) {
2722 if ( typeof selector !== "string" ) {
2723 return this.pushStack( jQuery( selector ).filter(function() {
2724 for ( i = 0; i < len; i++ ) {
2725 if ( jQuery.contains( self[ i ], this ) ) {
2732 for ( i = 0; i < len; i++ ) {
2733 jQuery.find( selector, self[ i ], ret );
2736 // Needed because $( selector, context ) becomes $( context ).find( selector )
2737 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
2738 ret.selector = this.selector ? this.selector + " " + selector : selector;
2741 filter: function( selector ) {
2742 return this.pushStack( winnow(this, selector || [], false) );
2744 not: function( selector ) {
2745 return this.pushStack( winnow(this, selector || [], true) );
2747 is: function( selector ) {
2751 // If this is a positional/relative selector, check membership in the returned set
2752 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2753 typeof selector === "string" && rneedsContext.test( selector ) ?
2754 jQuery( selector ) :
2762 // Initialize a jQuery object
2765 // A central reference to the root jQuery(document)
2768 // Use the correct document accordingly with window argument (sandbox)
2769 document = window.document,
2771 // A simple way to check for HTML strings
2772 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2773 // Strict HTML recognition (#11290: must start with <)
2774 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
2776 init = jQuery.fn.init = function( selector, context ) {
2779 // HANDLE: $(""), $(null), $(undefined), $(false)
2784 // Handle HTML strings
2785 if ( typeof selector === "string" ) {
2786 if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
2787 // Assume that strings that start and end with <> are HTML and skip the regex check
2788 match = [ null, selector, null ];
2791 match = rquickExpr.exec( selector );
2794 // Match html or make sure no context is specified for #id
2795 if ( match && (match[1] || !context) ) {
2797 // HANDLE: $(html) -> $(array)
2799 context = context instanceof jQuery ? context[0] : context;
2801 // scripts is true for back-compat
2802 // Intentionally let the error be thrown if parseHTML is not present
2803 jQuery.merge( this, jQuery.parseHTML(
2805 context && context.nodeType ? context.ownerDocument || context : document,
2809 // HANDLE: $(html, props)
2810 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
2811 for ( match in context ) {
2812 // Properties of context are called as methods if possible
2813 if ( jQuery.isFunction( this[ match ] ) ) {
2814 this[ match ]( context[ match ] );
2816 // ...and otherwise set as attributes
2818 this.attr( match, context[ match ] );
2827 elem = document.getElementById( match[2] );
2829 // Check parentNode to catch when Blackberry 4.6 returns
2830 // nodes that are no longer in the document #6963
2831 if ( elem && elem.parentNode ) {
2832 // Handle the case where IE and Opera return items
2833 // by name instead of ID
2834 if ( elem.id !== match[2] ) {
2835 return rootjQuery.find( selector );
2838 // Otherwise, we inject the element directly into the jQuery object
2843 this.context = document;
2844 this.selector = selector;
2848 // HANDLE: $(expr, $(...))
2849 } else if ( !context || context.jquery ) {
2850 return ( context || rootjQuery ).find( selector );
2852 // HANDLE: $(expr, context)
2853 // (which is just equivalent to: $(context).find(expr)
2855 return this.constructor( context ).find( selector );
2858 // HANDLE: $(DOMElement)
2859 } else if ( selector.nodeType ) {
2860 this.context = this[0] = selector;
2864 // HANDLE: $(function)
2865 // Shortcut for document ready
2866 } else if ( jQuery.isFunction( selector ) ) {
2867 return typeof rootjQuery.ready !== "undefined" ?
2868 rootjQuery.ready( selector ) :
2869 // Execute immediately if ready is not present
2873 if ( selector.selector !== undefined ) {
2874 this.selector = selector.selector;
2875 this.context = selector.context;
2878 return jQuery.makeArray( selector, this );
2881 // Give the init function the jQuery prototype for later instantiation
2882 init.prototype = jQuery.fn;
2884 // Initialize central reference
2885 rootjQuery = jQuery( document );
2888 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
2889 // methods guaranteed to produce a unique set when starting from a unique set
2890 guaranteedUnique = {