2 * jQuery JavaScript Library v3.1.1
6 * https://sizzlejs.com/
8 * Copyright jQuery Foundation and other contributors
9 * Released under the MIT license
10 * https://jquery.org/license
12 * Date: 2016-09-22T22:30Z
14 ( function( global
, factory
) {
18 if ( typeof module
=== "object" && typeof module
.exports
=== "object" ) {
20 // For CommonJS and CommonJS-like environments where a proper `window`
21 // is present, execute the factory and get jQuery.
22 // For environments that do not have a `window` with a `document`
23 // (such as Node.js), expose a factory as module.exports.
24 // This accentuates the need for the creation of a real `window`.
25 // e.g. var jQuery = require("jquery")(window);
26 // See ticket #14549 for more info.
27 module
.exports
= global
.document
?
28 factory( global
, true ) :
31 throw new Error( "jQuery requires a window with a document" );
39 // Pass this if window is not defined yet
40 } )( typeof window
!== "undefined" ? window
: this, function( window
, noGlobal
) {
42 // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
43 // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
44 // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
45 // enough that all such attempts are guarded in a try block.
50 var document
= window
.document
;
52 var getProto
= Object
.getPrototypeOf
;
54 var slice
= arr
.slice
;
56 var concat
= arr
.concat
;
60 var indexOf
= arr
.indexOf
;
64 var toString
= class2type
.toString
;
66 var hasOwn
= class2type
.hasOwnProperty
;
68 var fnToString
= hasOwn
.toString
;
70 var ObjectFunctionString
= fnToString
.call( Object
);
76 function DOMEval( code
, doc
) {
77 doc
= doc
|| document
;
79 var script
= doc
.createElement( "script" );
82 doc
.head
.appendChild( script
).parentNode
.removeChild( script
);
85 // Defining this global in .eslintrc.json would create a danger of using the global
86 // unguarded in another place, it seems safer to define global only for this module
93 // Define a local copy of jQuery
94 jQuery = function( selector
, context
) {
96 // The jQuery object is actually just the init constructor 'enhanced'
97 // Need init if jQuery is called (just allow error to be thrown if not included)
98 return new jQuery
.fn
.init( selector
, context
);
101 // Support: Android <=4.0 only
102 // Make sure we trim BOM and NBSP
103 rtrim
= /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
105 // Matches dashed string for camelizing
107 rdashAlpha
= /-([a-z])/g,
109 // Used by jQuery.camelCase as callback to replace()
110 fcamelCase = function( all
, letter
) {
111 return letter
.toUpperCase();
114 jQuery
.fn
= jQuery
.prototype = {
116 // The current version of jQuery being used
121 // The default length of a jQuery object is 0
124 toArray: function() {
125 return slice
.call( this );
128 // Get the Nth element in the matched element set OR
129 // Get the whole matched element set as a clean array
130 get: function( num
) {
132 // Return all the elements in a clean array
134 return slice
.call( this );
137 // Return just the one element from the set
138 return num
< 0 ? this[ num
+ this.length
] : this[ num
];
141 // Take an array of elements and push it onto the stack
142 // (returning the new matched element set)
143 pushStack: function( elems
) {
145 // Build a new jQuery matched element set
146 var ret
= jQuery
.merge( this.constructor(), elems
);
148 // Add the old object onto the stack (as a reference)
149 ret
.prevObject
= this;
151 // Return the newly-formed element set
155 // Execute a callback for every element in the matched set.
156 each: function( callback
) {
157 return jQuery
.each( this, callback
);
160 map: function( callback
) {
161 return this.pushStack( jQuery
.map( this, function( elem
, i
) {
162 return callback
.call( elem
, i
, elem
);
167 return this.pushStack( slice
.apply( this, arguments
) );
175 return this.eq( -1 );
179 var len
= this.length
,
180 j
= +i
+ ( i
< 0 ? len
: 0 );
181 return this.pushStack( j
>= 0 && j
< len
? [ this[ j
] ] : [] );
185 return this.prevObject
|| this.constructor();
188 // For internal use only.
189 // Behaves like an Array's method, not like a jQuery method.
195 jQuery
.extend
= jQuery
.fn
.extend = function() {
196 var options
, name
, src
, copy
, copyIsArray
, clone
,
197 target
= arguments
[ 0 ] || {},
199 length
= arguments
.length
,
202 // Handle a deep copy situation
203 if ( typeof target
=== "boolean" ) {
206 // Skip the boolean and the target
207 target
= arguments
[ i
] || {};
211 // Handle case when target is a string or something (possible in deep copy)
212 if ( typeof target
!== "object" && !jQuery
.isFunction( target
) ) {
216 // Extend jQuery itself if only one argument is passed
217 if ( i
=== length
) {
222 for ( ; i
< length
; i
++ ) {
224 // Only deal with non-null/undefined values
225 if ( ( options
= arguments
[ i
] ) != null ) {
227 // Extend the base object
228 for ( name
in options
) {
229 src
= target
[ name
];
230 copy
= options
[ name
];
232 // Prevent never-ending loop
233 if ( target
=== copy
) {
237 // Recurse if we're merging plain objects or arrays
238 if ( deep
&& copy
&& ( jQuery
.isPlainObject( copy
) ||
239 ( copyIsArray
= jQuery
.isArray( copy
) ) ) ) {
243 clone
= src
&& jQuery
.isArray( src
) ? src
: [];
246 clone
= src
&& jQuery
.isPlainObject( src
) ? src
: {};
249 // Never move original objects, clone them
250 target
[ name
] = jQuery
.extend( deep
, clone
, copy
);
252 // Don't bring in undefined values
253 } else if ( copy
!== undefined ) {
254 target
[ name
] = copy
;
260 // Return the modified object
266 // Unique for each copy of jQuery on the page
267 expando
: "jQuery" + ( version
+ Math
.random() ).replace( /\D/g, "" ),
269 // Assume jQuery is ready without the ready module
272 error: function( msg
) {
273 throw new Error( msg
);
278 isFunction: function( obj
) {
279 return jQuery
.type( obj
) === "function";
282 isArray
: Array
.isArray
,
284 isWindow: function( obj
) {
285 return obj
!= null && obj
=== obj
.window
;
288 isNumeric: function( obj
) {
290 // As of jQuery 3.0, isNumeric is limited to
291 // strings and numbers (primitives or objects)
292 // that can be coerced to finite numbers (gh-2662)
293 var type
= jQuery
.type( obj
);
294 return ( type
=== "number" || type
=== "string" ) &&
296 // parseFloat NaNs numeric-cast false positives ("")
297 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
298 // subtraction forces infinities to NaN
299 !isNaN( obj
- parseFloat( obj
) );
302 isPlainObject: function( obj
) {
305 // Detect obvious negatives
306 // Use toString instead of jQuery.type to catch host objects
307 if ( !obj
|| toString
.call( obj
) !== "[object Object]" ) {
311 proto
= getProto( obj
);
313 // Objects with no prototype (e.g., `Object.create( null )`) are plain
318 // Objects with prototype are plain iff they were constructed by a global Object function
319 Ctor
= hasOwn
.call( proto
, "constructor" ) && proto
.constructor;
320 return typeof Ctor
=== "function" && fnToString
.call( Ctor
) === ObjectFunctionString
;
323 isEmptyObject: function( obj
) {
325 /* eslint-disable no-unused-vars */
326 // See https://github.com/eslint/eslint/issues/6125
329 for ( name
in obj
) {
335 type: function( obj
) {
340 // Support: Android <=2.3 only (functionish RegExp)
341 return typeof obj
=== "object" || typeof obj
=== "function" ?
342 class2type
[ toString
.call( obj
) ] || "object" :
346 // Evaluates a script in a global context
347 globalEval: function( code
) {
351 // Convert dashed to camelCase; used by the css and data modules
352 // Support: IE <=9 - 11, Edge 12 - 13
353 // Microsoft forgot to hump their vendor prefix (#9572)
354 camelCase: function( string
) {
355 return string
.replace( rmsPrefix
, "ms-" ).replace( rdashAlpha
, fcamelCase
);
358 nodeName: function( elem
, name
) {
359 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === name
.toLowerCase();
362 each: function( obj
, callback
) {
365 if ( isArrayLike( obj
) ) {
367 for ( ; i
< length
; i
++ ) {
368 if ( callback
.call( obj
[ i
], i
, obj
[ i
] ) === false ) {
374 if ( callback
.call( obj
[ i
], i
, obj
[ i
] ) === false ) {
383 // Support: Android <=4.0 only
384 trim: function( text
) {
385 return text
== null ?
387 ( text
+ "" ).replace( rtrim
, "" );
390 // results is for internal usage only
391 makeArray: function( arr
, results
) {
392 var ret
= results
|| [];
395 if ( isArrayLike( Object( arr
) ) ) {
397 typeof arr
=== "string" ?
401 push
.call( ret
, arr
);
408 inArray: function( elem
, arr
, i
) {
409 return arr
== null ? -1 : indexOf
.call( arr
, elem
, i
);
412 // Support: Android <=4.0 only, PhantomJS 1 only
413 // push.apply(_, arraylike) throws on ancient WebKit
414 merge: function( first
, second
) {
415 var len
= +second
.length
,
419 for ( ; j
< len
; j
++ ) {
420 first
[ i
++ ] = second
[ j
];
428 grep: function( elems
, callback
, invert
) {
432 length
= elems
.length
,
433 callbackExpect
= !invert
;
435 // Go through the array, only saving the items
436 // that pass the validator function
437 for ( ; i
< length
; i
++ ) {
438 callbackInverse
= !callback( elems
[ i
], i
);
439 if ( callbackInverse
!== callbackExpect
) {
440 matches
.push( elems
[ i
] );
447 // arg is for internal usage only
448 map: function( elems
, callback
, arg
) {
453 // Go through the array, translating each of the items to their new values
454 if ( isArrayLike( elems
) ) {
455 length
= elems
.length
;
456 for ( ; i
< length
; i
++ ) {
457 value
= callback( elems
[ i
], i
, arg
);
459 if ( value
!= null ) {
464 // Go through every key on the object,
467 value
= callback( elems
[ i
], i
, arg
);
469 if ( value
!= null ) {
475 // Flatten any nested arrays
476 return concat
.apply( [], ret
);
479 // A global GUID counter for objects
482 // Bind a function to a context, optionally partially applying any
484 proxy: function( fn
, context
) {
485 var tmp
, args
, proxy
;
487 if ( typeof context
=== "string" ) {
493 // Quick check to determine if target is callable, in the spec
494 // this throws a TypeError, but we will just return undefined.
495 if ( !jQuery
.isFunction( fn
) ) {
500 args
= slice
.call( arguments
, 2 );
502 return fn
.apply( context
|| this, args
.concat( slice
.call( arguments
) ) );
505 // Set the guid of unique handler to the same of original handler, so it can be removed
506 proxy
.guid
= fn
.guid
= fn
.guid
|| jQuery
.guid
++;
513 // jQuery.support is not used in Core but other projects attach their
514 // properties to it so it needs to exist.
518 if ( typeof Symbol
=== "function" ) {
519 jQuery
.fn
[ Symbol
.iterator
] = arr
[ Symbol
.iterator
];
522 // Populate the class2type map
523 jQuery
.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
524 function( i
, name
) {
525 class2type
[ "[object " + name
+ "]" ] = name
.toLowerCase();
528 function isArrayLike( obj
) {
530 // Support: real iOS 8.2 only (not reproducible in simulator)
531 // `in` check used to prevent JIT error (gh-2145)
532 // hasOwn isn't used here due to false negatives
533 // regarding Nodelist length in IE
534 var length
= !!obj
&& "length" in obj
&& obj
.length
,
535 type
= jQuery
.type( obj
);
537 if ( type
=== "function" || jQuery
.isWindow( obj
) ) {
541 return type
=== "array" || length
=== 0 ||
542 typeof length
=== "number" && length
> 0 && ( length
- 1 ) in obj
;
546 * Sizzle CSS Selector Engine v2.3.3
547 * https://sizzlejs.com/
549 * Copyright jQuery Foundation and other contributors
550 * Released under the MIT license
551 * http://jquery.org/license
555 (function( window
) {
569 // Local document vars
579 // Instance-specific data
580 expando
= "sizzle" + 1 * new Date(),
581 preferredDoc
= window
.document
,
584 classCache
= createCache(),
585 tokenCache
= createCache(),
586 compilerCache
= createCache(),
587 sortOrder = function( a
, b
) {
595 hasOwn
= ({}).hasOwnProperty
,
598 push_native
= arr
.push
,
601 // Use a stripped-down indexOf as it's faster than native
602 // https://jsperf.com/thor-indexof-vs-for/5
603 indexOf = function( list
, elem
) {
606 for ( ; i
< len
; i
++ ) {
607 if ( list
[i
] === elem
) {
614 booleans
= "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
616 // Regular expressions
618 // http://www.w3.org/TR/css3-selectors/#whitespace
619 whitespace
= "[\\x20\\t\\r\\n\\f]",
621 // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
622 identifier
= "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
624 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
625 attributes
= "\\[" + whitespace
+ "*(" + identifier
+ ")(?:" + whitespace
+
626 // Operator (capture 2)
627 "*([*^$|!~]?=)" + whitespace
+
628 // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
629 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier
+ "))|)" + whitespace
+
632 pseudos
= ":(" + identifier
+ ")(?:\\((" +
633 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
634 // 1. quoted (capture 3; capture 4 or capture 5)
635 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
636 // 2. simple (capture 6)
637 "((?:\\\\.|[^\\\\()[\\]]|" + attributes
+ ")*)|" +
638 // 3. anything else (capture 2)
642 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
643 rwhitespace
= new RegExp( whitespace
+ "+", "g" ),
644 rtrim
= new RegExp( "^" + whitespace
+ "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace
+ "+$", "g" ),
646 rcomma
= new RegExp( "^" + whitespace
+ "*," + whitespace
+ "*" ),
647 rcombinators
= new RegExp( "^" + whitespace
+ "*([>+~]|" + whitespace
+ ")" + whitespace
+ "*" ),
649 rattributeQuotes
= new RegExp( "=" + whitespace
+ "*([^\\]'\"]*?)" + whitespace
+ "*\\]", "g" ),
651 rpseudo
= new RegExp( pseudos
),
652 ridentifier
= new RegExp( "^" + identifier
+ "$" ),
655 "ID": new RegExp( "^#(" + identifier
+ ")" ),
656 "CLASS": new RegExp( "^\\.(" + identifier
+ ")" ),
657 "TAG": new RegExp( "^(" + identifier
+ "|[*])" ),
658 "ATTR": new RegExp( "^" + attributes
),
659 "PSEUDO": new RegExp( "^" + pseudos
),
660 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace
+
661 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace
+ "*(?:([+-]|)" + whitespace
+
662 "*(\\d+)|))" + whitespace
+ "*\\)|)", "i" ),
663 "bool": new RegExp( "^(?:" + booleans
+ ")$", "i" ),
664 // For use in libraries implementing .is()
665 // We use this for POS matching in `select`
666 "needsContext": new RegExp( "^" + whitespace
+ "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
667 whitespace
+ "*((?:-\\d)?\\d*)" + whitespace
+ "*\\)|)(?=[^-]|$)", "i" )
670 rinputs
= /^(?:input|select|textarea|button)$/i,
673 rnative
= /^[^{]+\{\s*\[native \w/,
675 // Easily-parseable/retrievable ID or TAG or CLASS selectors
676 rquickExpr
= /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
681 // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
682 runescape
= new RegExp( "\\\\([\\da-f]{1,6}" + whitespace
+ "?|(" + whitespace
+ ")|.)", "ig" ),
683 funescape = function( _
, escaped
, escapedWhitespace
) {
684 var high
= "0x" + escaped
- 0x10000;
685 // NaN means non-codepoint
686 // Support: Firefox<24
687 // Workaround erroneous numeric interpretation of +"0x"
688 return high
!== high
|| escapedWhitespace
?
692 String
.fromCharCode( high
+ 0x10000 ) :
693 // Supplemental Plane codepoint (surrogate pair)
694 String
.fromCharCode( high
>> 10 | 0xD800, high
& 0x3FF | 0xDC00 );
697 // CSS string/identifier serialization
698 // https://drafts.csswg.org/cssom/#common-serializing-idioms
699 rcssescape
= /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
700 fcssescape = function( ch
, asCodePoint
) {
703 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
708 // Control characters and (dependent upon position) numbers get escaped as code points
709 return ch
.slice( 0, -1 ) + "\\" + ch
.charCodeAt( ch
.length
- 1 ).toString( 16 ) + " ";
712 // Other potentially-special ASCII characters get backslash-escaped
718 // Removing the function wrapper causes a "Permission Denied"
720 unloadHandler = function() {
724 disabledAncestor
= addCombinator(
726 return elem
.disabled
=== true && ("form" in elem
|| "label" in elem
);
728 { dir
: "parentNode", next
: "legend" }
731 // Optimize for push.apply( _, NodeList )
734 (arr
= slice
.call( preferredDoc
.childNodes
)),
735 preferredDoc
.childNodes
737 // Support: Android<4.0
738 // Detect silently failing push.apply
739 arr
[ preferredDoc
.childNodes
.length
].nodeType
;
741 push
= { apply
: arr
.length
?
743 // Leverage slice if possible
744 function( target
, els
) {
745 push_native
.apply( target
, slice
.call(els
) );
749 // Otherwise append directly
750 function( target
, els
) {
751 var j
= target
.length
,
753 // Can't trust NodeList.length
754 while ( (target
[j
++] = els
[i
++]) ) {}
755 target
.length
= j
- 1;
760 function Sizzle( selector
, context
, results
, seed
) {
761 var m
, i
, elem
, nid
, match
, groups
, newSelector
,
762 newContext
= context
&& context
.ownerDocument
,
764 // nodeType defaults to 9, since context defaults to document
765 nodeType
= context
? context
.nodeType
: 9;
767 results
= results
|| [];
769 // Return early from calls with invalid selector or context
770 if ( typeof selector
!== "string" || !selector
||
771 nodeType
!== 1 && nodeType
!== 9 && nodeType
!== 11 ) {
776 // Try to shortcut find operations (as opposed to filters) in HTML documents
779 if ( ( context
? context
.ownerDocument
|| context
: preferredDoc
) !== document
) {
780 setDocument( context
);
782 context
= context
|| document
;
784 if ( documentIsHTML
) {
786 // If the selector is sufficiently simple, try using a "get*By*" DOM method
787 // (excepting DocumentFragment context, where the methods don't exist)
788 if ( nodeType
!== 11 && (match
= rquickExpr
.exec( selector
)) ) {
791 if ( (m
= match
[1]) ) {
794 if ( nodeType
=== 9 ) {
795 if ( (elem
= context
.getElementById( m
)) ) {
797 // Support: IE, Opera, Webkit
798 // TODO: identify versions
799 // getElementById can match elements by name instead of ID
800 if ( elem
.id
=== m
) {
801 results
.push( elem
);
811 // Support: IE, Opera, Webkit
812 // TODO: identify versions
813 // getElementById can match elements by name instead of ID
814 if ( newContext
&& (elem
= newContext
.getElementById( m
)) &&
815 contains( context
, elem
) &&
818 results
.push( elem
);
824 } else if ( match
[2] ) {
825 push
.apply( results
, context
.getElementsByTagName( selector
) );
829 } else if ( (m
= match
[3]) && support
.getElementsByClassName
&&
830 context
.getElementsByClassName
) {
832 push
.apply( results
, context
.getElementsByClassName( m
) );
837 // Take advantage of querySelectorAll
839 !compilerCache
[ selector
+ " " ] &&
840 (!rbuggyQSA
|| !rbuggyQSA
.test( selector
)) ) {
842 if ( nodeType
!== 1 ) {
843 newContext
= context
;
844 newSelector
= selector
;
846 // qSA looks outside Element context, which is not what we want
847 // Thanks to Andrew Dupont for this workaround technique
849 // Exclude object elements
850 } else if ( context
.nodeName
.toLowerCase() !== "object" ) {
852 // Capture the context ID, setting it first if necessary
853 if ( (nid
= context
.getAttribute( "id" )) ) {
854 nid
= nid
.replace( rcssescape
, fcssescape
);
856 context
.setAttribute( "id", (nid
= expando
) );
859 // Prefix every selector in the list
860 groups
= tokenize( selector
);
863 groups
[i
] = "#" + nid
+ " " + toSelector( groups
[i
] );
865 newSelector
= groups
.join( "," );
867 // Expand context for sibling selectors
868 newContext
= rsibling
.test( selector
) && testContext( context
.parentNode
) ||
875 newContext
.querySelectorAll( newSelector
)
878 } catch ( qsaError
) {
880 if ( nid
=== expando
) {
881 context
.removeAttribute( "id" );
890 return select( selector
.replace( rtrim
, "$1" ), context
, results
, seed
);
894 * Create key-value caches of limited size
895 * @returns {function(string, object)} Returns the Object data after storing it on itself with
896 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
897 * deleting the oldest entry
899 function createCache() {
902 function cache( key
, value
) {
903 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
904 if ( keys
.push( key
+ " " ) > Expr
.cacheLength
) {
905 // Only keep the most recent entries
906 delete cache
[ keys
.shift() ];
908 return (cache
[ key
+ " " ] = value
);
914 * Mark a function for special use by Sizzle
915 * @param {Function} fn The function to mark
917 function markFunction( fn
) {
918 fn
[ expando
] = true;
923 * Support testing using an element
924 * @param {Function} fn Passed the created element and returns a boolean result
926 function assert( fn
) {
927 var el
= document
.createElement("fieldset");
934 // Remove from its parent by default
935 if ( el
.parentNode
) {
936 el
.parentNode
.removeChild( el
);
938 // release memory in IE
944 * Adds the same handler for all of the specified attrs
945 * @param {String} attrs Pipe-separated list of attributes
946 * @param {Function} handler The method that will be applied
948 function addHandle( attrs
, handler
) {
949 var arr
= attrs
.split("|"),
953 Expr
.attrHandle
[ arr
[i
] ] = handler
;
958 * Checks document order of two siblings
961 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
963 function siblingCheck( a
, b
) {
965 diff
= cur
&& a
.nodeType
=== 1 && b
.nodeType
=== 1 &&
966 a
.sourceIndex
- b
.sourceIndex
;
968 // Use IE sourceIndex if available on both nodes
973 // Check if b follows a
975 while ( (cur
= cur
.nextSibling
) ) {
986 * Returns a function to use in pseudos for input types
987 * @param {String} type
989 function createInputPseudo( type
) {
990 return function( elem
) {
991 var name
= elem
.nodeName
.toLowerCase();
992 return name
=== "input" && elem
.type
=== type
;
997 * Returns a function to use in pseudos for buttons
998 * @param {String} type
1000 function createButtonPseudo( type
) {
1001 return function( elem
) {
1002 var name
= elem
.nodeName
.toLowerCase();
1003 return (name
=== "input" || name
=== "button") && elem
.type
=== type
;
1008 * Returns a function to use in pseudos for :enabled/:disabled
1009 * @param {Boolean} disabled true for :disabled; false for :enabled
1011 function createDisabledPseudo( disabled
) {
1013 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
1014 return function( elem
) {
1016 // Only certain elements can match :enabled or :disabled
1017 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
1018 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
1019 if ( "form" in elem
) {
1021 // Check for inherited disabledness on relevant non-disabled elements:
1022 // * listed form-associated elements in a disabled fieldset
1023 // https://html.spec.whatwg.org/multipage/forms.html#category-listed
1024 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
1025 // * option elements in a disabled optgroup
1026 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
1027 // All such elements have a "form" property.
1028 if ( elem
.parentNode
&& elem
.disabled
=== false ) {
1030 // Option elements defer to a parent optgroup if present
1031 if ( "label" in elem
) {
1032 if ( "label" in elem
.parentNode
) {
1033 return elem
.parentNode
.disabled
=== disabled
;
1035 return elem
.disabled
=== disabled
;
1039 // Support: IE 6 - 11
1040 // Use the isDisabled shortcut property to check for disabled fieldset ancestors
1041 return elem
.isDisabled
=== disabled
||
1043 // Where there is no isDisabled, check manually
1045 elem
.isDisabled
!== !disabled
&&
1046 disabledAncestor( elem
) === disabled
;
1049 return elem
.disabled
=== disabled
;
1051 // Try to winnow out elements that can't be disabled before trusting the disabled property.
1052 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
1053 // even exist on them, let alone have a boolean value.
1054 } else if ( "label" in elem
) {
1055 return elem
.disabled
=== disabled
;
1058 // Remaining elements are neither :enabled nor :disabled
1064 * Returns a function to use in pseudos for positionals
1065 * @param {Function} fn
1067 function createPositionalPseudo( fn
) {
1068 return markFunction(function( argument
) {
1069 argument
= +argument
;
1070 return markFunction(function( seed
, matches
) {
1072 matchIndexes
= fn( [], seed
.length
, argument
),
1073 i
= matchIndexes
.length
;
1075 // Match elements found at the specified indexes
1077 if ( seed
[ (j
= matchIndexes
[i
]) ] ) {
1078 seed
[j
] = !(matches
[j
] = seed
[j
]);
1086 * Checks a node for validity as a Sizzle context
1087 * @param {Element|Object=} context
1088 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1090 function testContext( context
) {
1091 return context
&& typeof context
.getElementsByTagName
!== "undefined" && context
;
1094 // Expose support vars for convenience
1095 support
= Sizzle
.support
= {};
1099 * @param {Element|Object} elem An element or a document
1100 * @returns {Boolean} True iff elem is a non-HTML XML node
1102 isXML
= Sizzle
.isXML = function( elem
) {
1103 // documentElement is verified for cases where it doesn't yet exist
1104 // (such as loading iframes in IE - #4833)
1105 var documentElement
= elem
&& (elem
.ownerDocument
|| elem
).documentElement
;
1106 return documentElement
? documentElement
.nodeName
!== "HTML" : false;
1110 * Sets document-related variables once based on the current document
1111 * @param {Element|Object} [doc] An element or document object to use to set the document
1112 * @returns {Object} Returns the current document
1114 setDocument
= Sizzle
.setDocument = function( node
) {
1115 var hasCompare
, subWindow
,
1116 doc
= node
? node
.ownerDocument
|| node
: preferredDoc
;
1118 // Return early if doc is invalid or already selected
1119 if ( doc
=== document
|| doc
.nodeType
!== 9 || !doc
.documentElement
) {
1123 // Update global variables
1125 docElem
= document
.documentElement
;
1126 documentIsHTML
= !isXML( document
);
1128 // Support: IE 9-11, Edge
1129 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
1130 if ( preferredDoc
!== document
&&
1131 (subWindow
= document
.defaultView
) && subWindow
.top
!== subWindow
) {
1133 // Support: IE 11, Edge
1134 if ( subWindow
.addEventListener
) {
1135 subWindow
.addEventListener( "unload", unloadHandler
, false );
1137 // Support: IE 9 - 10 only
1138 } else if ( subWindow
.attachEvent
) {
1139 subWindow
.attachEvent( "onunload", unloadHandler
);
1144 ---------------------------------------------------------------------- */
1147 // Verify that getAttribute really returns attributes and not properties
1148 // (excepting IE8 booleans)
1149 support
.attributes
= assert(function( el
) {
1151 return !el
.getAttribute("className");
1155 ---------------------------------------------------------------------- */
1157 // Check if getElementsByTagName("*") returns only elements
1158 support
.getElementsByTagName
= assert(function( el
) {
1159 el
.appendChild( document
.createComment("") );
1160 return !el
.getElementsByTagName("*").length
;
1164 support
.getElementsByClassName
= rnative
.test( document
.getElementsByClassName
);
1167 // Check if getElementById returns elements by name
1168 // The broken getElementById methods don't pick up programmatically-set names,
1169 // so use a roundabout getElementsByName test
1170 support
.getById
= assert(function( el
) {
1171 docElem
.appendChild( el
).id
= expando
;
1172 return !document
.getElementsByName
|| !document
.getElementsByName( expando
).length
;
1175 // ID filter and find
1176 if ( support
.getById
) {
1177 Expr
.filter
["ID"] = function( id
) {
1178 var attrId
= id
.replace( runescape
, funescape
);
1179 return function( elem
) {
1180 return elem
.getAttribute("id") === attrId
;
1183 Expr
.find
["ID"] = function( id
, context
) {
1184 if ( typeof context
.getElementById
!== "undefined" && documentIsHTML
) {
1185 var elem
= context
.getElementById( id
);
1186 return elem
? [ elem
] : [];
1190 Expr
.filter
["ID"] = function( id
) {
1191 var attrId
= id
.replace( runescape
, funescape
);
1192 return function( elem
) {
1193 var node
= typeof elem
.getAttributeNode
!== "undefined" &&
1194 elem
.getAttributeNode("id");
1195 return node
&& node
.value
=== attrId
;
1199 // Support: IE 6 - 7 only
1200 // getElementById is not reliable as a find shortcut
1201 Expr
.find
["ID"] = function( id
, context
) {
1202 if ( typeof context
.getElementById
!== "undefined" && documentIsHTML
) {
1204 elem
= context
.getElementById( id
);
1208 // Verify the id attribute
1209 node
= elem
.getAttributeNode("id");
1210 if ( node
&& node
.value
=== id
) {
1214 // Fall back on getElementsByName
1215 elems
= context
.getElementsByName( id
);
1217 while ( (elem
= elems
[i
++]) ) {
1218 node
= elem
.getAttributeNode("id");
1219 if ( node
&& node
.value
=== id
) {
1231 Expr
.find
["TAG"] = support
.getElementsByTagName
?
1232 function( tag
, context
) {
1233 if ( typeof context
.getElementsByTagName
!== "undefined" ) {
1234 return context
.getElementsByTagName( tag
);
1236 // DocumentFragment nodes don't have gEBTN
1237 } else if ( support
.qsa
) {
1238 return context
.querySelectorAll( tag
);
1242 function( tag
, context
) {
1246 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1247 results
= context
.getElementsByTagName( tag
);
1249 // Filter out possible comments
1250 if ( tag
=== "*" ) {
1251 while ( (elem
= results
[i
++]) ) {
1252 if ( elem
.nodeType
=== 1 ) {
1263 Expr
.find
["CLASS"] = support
.getElementsByClassName
&& function( className
, context
) {
1264 if ( typeof context
.getElementsByClassName
!== "undefined" && documentIsHTML
) {
1265 return context
.getElementsByClassName( className
);
1269 /* QSA/matchesSelector
1270 ---------------------------------------------------------------------- */
1272 // QSA and matchesSelector support
1274 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1277 // qSa(:focus) reports false when true (Chrome 21)
1278 // We allow this because of a bug in IE8/9 that throws an error
1279 // whenever `document.activeElement` is accessed on an iframe
1280 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1281 // See https://bugs.jquery.com/ticket/13378
1284 if ( (support
.qsa
= rnative
.test( document
.querySelectorAll
)) ) {
1286 // Regex strategy adopted from Diego Perini
1287 assert(function( el
) {
1288 // Select is set to empty string on purpose
1289 // This is to test IE's treatment of not explicitly
1290 // setting a boolean content attribute,
1291 // since its presence should be enough
1292 // https://bugs.jquery.com/ticket/12359
1293 docElem
.appendChild( el
).innerHTML
= "<a id='" + expando
+ "'></a>" +
1294 "<select id='" + expando
+ "-\r\\' msallowcapture=''>" +
1295 "<option selected=''></option></select>";
1297 // Support: IE8, Opera 11-12.16
1298 // Nothing should be selected when empty strings follow ^= or $= or *=
1299 // The test attribute must be unknown in Opera but "safe" for WinRT
1300 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1301 if ( el
.querySelectorAll("[msallowcapture^='']").length
) {
1302 rbuggyQSA
.push( "[*^$]=" + whitespace
+ "*(?:''|\"\")" );
1306 // Boolean attributes and "value" are not treated correctly
1307 if ( !el
.querySelectorAll("[selected]").length
) {
1308 rbuggyQSA
.push( "\\[" + whitespace
+ "*(?:value|" + booleans
+ ")" );
1311 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
1312 if ( !el
.querySelectorAll( "[id~=" + expando
+ "-]" ).length
) {
1313 rbuggyQSA
.push("~=");
1316 // Webkit/Opera - :checked should return selected option elements
1317 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1318 // IE8 throws error here and will not see later tests
1319 if ( !el
.querySelectorAll(":checked").length
) {
1320 rbuggyQSA
.push(":checked");
1323 // Support: Safari 8+, iOS 8+
1324 // https://bugs.webkit.org/show_bug.cgi?id=136851
1325 // In-page `selector#id sibling-combinator selector` fails
1326 if ( !el
.querySelectorAll( "a#" + expando
+ "+*" ).length
) {
1327 rbuggyQSA
.push(".#.+[+~]");
1331 assert(function( el
) {
1332 el
.innerHTML
= "<a href='' disabled='disabled'></a>" +
1333 "<select disabled='disabled'><option/></select>";
1335 // Support: Windows 8 Native Apps
1336 // The type and name attributes are restricted during .innerHTML assignment
1337 var input
= document
.createElement("input");
1338 input
.setAttribute( "type", "hidden" );
1339 el
.appendChild( input
).setAttribute( "name", "D" );
1342 // Enforce case-sensitivity of name attribute
1343 if ( el
.querySelectorAll("[name=d]").length
) {
1344 rbuggyQSA
.push( "name" + whitespace
+ "*[*^$|!~]?=" );
1347 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1348 // IE8 throws error here and will not see later tests
1349 if ( el
.querySelectorAll(":enabled").length
!== 2 ) {
1350 rbuggyQSA
.push( ":enabled", ":disabled" );
1354 // IE's :disabled selector does not pick up the children of disabled fieldsets
1355 docElem
.appendChild( el
).disabled
= true;
1356 if ( el
.querySelectorAll(":disabled").length
!== 2 ) {
1357 rbuggyQSA
.push( ":enabled", ":disabled" );
1360 // Opera 10-11 does not throw on post-comma invalid pseudos
1361 el
.querySelectorAll("*,:x");
1362 rbuggyQSA
.push(",.*:");
1366 if ( (support
.matchesSelector
= rnative
.test( (matches
= docElem
.matches
||
1367 docElem
.webkitMatchesSelector
||
1368 docElem
.mozMatchesSelector
||
1369 docElem
.oMatchesSelector
||
1370 docElem
.msMatchesSelector
) )) ) {
1372 assert(function( el
) {
1373 // Check to see if it's possible to do matchesSelector
1374 // on a disconnected node (IE 9)
1375 support
.disconnectedMatch
= matches
.call( el
, "*" );
1377 // This should fail with an exception
1378 // Gecko does not error, returns false instead
1379 matches
.call( el
, "[s!='']:x" );
1380 rbuggyMatches
.push( "!=", pseudos
);
1384 rbuggyQSA
= rbuggyQSA
.length
&& new RegExp( rbuggyQSA
.join("|") );
1385 rbuggyMatches
= rbuggyMatches
.length
&& new RegExp( rbuggyMatches
.join("|") );
1388 ---------------------------------------------------------------------- */
1389 hasCompare
= rnative
.test( docElem
.compareDocumentPosition
);
1391 // Element contains another
1392 // Purposefully self-exclusive
1393 // As in, an element does not contain itself
1394 contains
= hasCompare
|| rnative
.test( docElem
.contains
) ?
1396 var adown
= a
.nodeType
=== 9 ? a
.documentElement
: a
,
1397 bup
= b
&& b
.parentNode
;
1398 return a
=== bup
|| !!( bup
&& bup
.nodeType
=== 1 && (
1400 adown
.contains( bup
) :
1401 a
.compareDocumentPosition
&& a
.compareDocumentPosition( bup
) & 16
1406 while ( (b
= b
.parentNode
) ) {
1416 ---------------------------------------------------------------------- */
1418 // Document order sorting
1419 sortOrder
= hasCompare
?
1422 // Flag for duplicate removal
1424 hasDuplicate
= true;
1428 // Sort on method existence if only one input has compareDocumentPosition
1429 var compare
= !a
.compareDocumentPosition
- !b
.compareDocumentPosition
;
1434 // Calculate position if both inputs belong to the same document
1435 compare
= ( a
.ownerDocument
|| a
) === ( b
.ownerDocument
|| b
) ?
1436 a
.compareDocumentPosition( b
) :
1438 // Otherwise we know they are disconnected
1441 // Disconnected nodes
1443 (!support
.sortDetached
&& b
.compareDocumentPosition( a
) === compare
) ) {
1445 // Choose the first element that is related to our preferred document
1446 if ( a
=== document
|| a
.ownerDocument
=== preferredDoc
&& contains(preferredDoc
, a
) ) {
1449 if ( b
=== document
|| b
.ownerDocument
=== preferredDoc
&& contains(preferredDoc
, b
) ) {
1453 // Maintain original order
1455 ( indexOf( sortInput
, a
) - indexOf( sortInput
, b
) ) :
1459 return compare
& 4 ? -1 : 1;
1462 // Exit early if the nodes are identical
1464 hasDuplicate
= true;
1475 // Parentless nodes are either documents or disconnected
1476 if ( !aup
|| !bup
) {
1477 return a
=== document
? -1 :
1478 b
=== document
? 1 :
1482 ( indexOf( sortInput
, a
) - indexOf( sortInput
, b
) ) :
1485 // If the nodes are siblings, we can do a quick check
1486 } else if ( aup
=== bup
) {
1487 return siblingCheck( a
, b
);
1490 // Otherwise we need full lists of their ancestors for comparison
1492 while ( (cur
= cur
.parentNode
) ) {
1496 while ( (cur
= cur
.parentNode
) ) {
1500 // Walk down the tree looking for a discrepancy
1501 while ( ap
[i
] === bp
[i
] ) {
1506 // Do a sibling check if the nodes have a common ancestor
1507 siblingCheck( ap
[i
], bp
[i
] ) :
1509 // Otherwise nodes in our document sort first
1510 ap
[i
] === preferredDoc
? -1 :
1511 bp
[i
] === preferredDoc
? 1 :
1518 Sizzle
.matches = function( expr
, elements
) {
1519 return Sizzle( expr
, null, null, elements
);
1522 Sizzle
.matchesSelector = function( elem
, expr
) {
1523 // Set document vars if needed
1524 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1525 setDocument( elem
);
1528 // Make sure that attribute selectors are quoted
1529 expr
= expr
.replace( rattributeQuotes
, "='$1']" );
1531 if ( support
.matchesSelector
&& documentIsHTML
&&
1532 !compilerCache
[ expr
+ " " ] &&
1533 ( !rbuggyMatches
|| !rbuggyMatches
.test( expr
) ) &&
1534 ( !rbuggyQSA
|| !rbuggyQSA
.test( expr
) ) ) {
1537 var ret
= matches
.call( elem
, expr
);
1539 // IE 9's matchesSelector returns false on disconnected nodes
1540 if ( ret
|| support
.disconnectedMatch
||
1541 // As well, disconnected nodes are said to be in a document
1543 elem
.document
&& elem
.document
.nodeType
!== 11 ) {
1549 return Sizzle( expr
, document
, null, [ elem
] ).length
> 0;
1552 Sizzle
.contains = function( context
, elem
) {
1553 // Set document vars if needed
1554 if ( ( context
.ownerDocument
|| context
) !== document
) {
1555 setDocument( context
);
1557 return contains( context
, elem
);
1560 Sizzle
.attr = function( elem
, name
) {
1561 // Set document vars if needed
1562 if ( ( elem
.ownerDocument
|| elem
) !== document
) {
1563 setDocument( elem
);
1566 var fn
= Expr
.attrHandle
[ name
.toLowerCase() ],
1567 // Don't get fooled by Object.prototype properties (jQuery #13807)
1568 val
= fn
&& hasOwn
.call( Expr
.attrHandle
, name
.toLowerCase() ) ?
1569 fn( elem
, name
, !documentIsHTML
) :
1572 return val
!== undefined ?
1574 support
.attributes
|| !documentIsHTML
?
1575 elem
.getAttribute( name
) :
1576 (val
= elem
.getAttributeNode(name
)) && val
.specified
?
1581 Sizzle
.escape = function( sel
) {
1582 return (sel
+ "").replace( rcssescape
, fcssescape
);
1585 Sizzle
.error = function( msg
) {
1586 throw new Error( "Syntax error, unrecognized expression: " + msg
);
1590 * Document sorting and removing duplicates
1591 * @param {ArrayLike} results
1593 Sizzle
.uniqueSort = function( results
) {
1599 // Unless we *know* we can detect duplicates, assume their presence
1600 hasDuplicate
= !support
.detectDuplicates
;
1601 sortInput
= !support
.sortStable
&& results
.slice( 0 );
1602 results
.sort( sortOrder
);
1604 if ( hasDuplicate
) {
1605 while ( (elem
= results
[i
++]) ) {
1606 if ( elem
=== results
[ i
] ) {
1607 j
= duplicates
.push( i
);
1611 results
.splice( duplicates
[ j
], 1 );
1615 // Clear input after sorting to release objects
1616 // See https://github.com/jquery/sizzle/pull/225
1623 * Utility function for retrieving the text value of an array of DOM nodes
1624 * @param {Array|Element} elem
1626 getText
= Sizzle
.getText = function( elem
) {
1630 nodeType
= elem
.nodeType
;
1633 // If no nodeType, this is expected to be an array
1634 while ( (node
= elem
[i
++]) ) {
1635 // Do not traverse comment nodes
1636 ret
+= getText( node
);
1638 } else if ( nodeType
=== 1 || nodeType
=== 9 || nodeType
=== 11 ) {
1639 // Use textContent for elements
1640 // innerText usage removed for consistency of new lines (jQuery #11153)
1641 if ( typeof elem
.textContent
=== "string" ) {
1642 return elem
.textContent
;
1644 // Traverse its children
1645 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
1646 ret
+= getText( elem
);
1649 } else if ( nodeType
=== 3 || nodeType
=== 4 ) {
1650 return elem
.nodeValue
;
1652 // Do not include comment or processing instruction nodes
1657 Expr
= Sizzle
.selectors
= {
1659 // Can be adjusted by the user
1662 createPseudo
: markFunction
,
1671 ">": { dir
: "parentNode", first
: true },
1672 " ": { dir
: "parentNode" },
1673 "+": { dir
: "previousSibling", first
: true },
1674 "~": { dir
: "previousSibling" }
1678 "ATTR": function( match
) {
1679 match
[1] = match
[1].replace( runescape
, funescape
);
1681 // Move the given value to match[3] whether quoted or unquoted
1682 match
[3] = ( match
[3] || match
[4] || match
[5] || "" ).replace( runescape
, funescape
);
1684 if ( match
[2] === "~=" ) {
1685 match
[3] = " " + match
[3] + " ";
1688 return match
.slice( 0, 4 );
1691 "CHILD": function( match
) {
1692 /* matches from matchExpr["CHILD"]
1693 1 type (only|nth|...)
1694 2 what (child|of-type)
1695 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1696 4 xn-component of xn+y argument ([+-]?\d*n|)
1697 5 sign of xn-component
1699 7 sign of y-component
1702 match
[1] = match
[1].toLowerCase();
1704 if ( match
[1].slice( 0, 3 ) === "nth" ) {
1705 // nth-* requires argument
1707 Sizzle
.error( match
[0] );
1710 // numeric x and y parameters for Expr.filter.CHILD
1711 // remember that false/true cast respectively to 0/1
1712 match
[4] = +( match
[4] ? match
[5] + (match
[6] || 1) : 2 * ( match
[3] === "even" || match
[3] === "odd" ) );
1713 match
[5] = +( ( match
[7] + match
[8] ) || match
[3] === "odd" );
1715 // other types prohibit arguments
1716 } else if ( match
[3] ) {
1717 Sizzle
.error( match
[0] );
1723 "PSEUDO": function( match
) {
1725 unquoted
= !match
[6] && match
[2];
1727 if ( matchExpr
["CHILD"].test( match
[0] ) ) {
1731 // Accept quoted arguments as-is
1733 match
[2] = match
[4] || match
[5] || "";
1735 // Strip excess characters from unquoted arguments
1736 } else if ( unquoted
&& rpseudo
.test( unquoted
) &&
1737 // Get excess from tokenize (recursively)
1738 (excess
= tokenize( unquoted
, true )) &&
1739 // advance to the next closing parenthesis
1740 (excess
= unquoted
.indexOf( ")", unquoted
.length
- excess
) - unquoted
.length
) ) {
1742 // excess is a negative index
1743 match
[0] = match
[0].slice( 0, excess
);
1744 match
[2] = unquoted
.slice( 0, excess
);
1747 // Return only captures needed by the pseudo filter method (type and argument)
1748 return match
.slice( 0, 3 );
1754 "TAG": function( nodeNameSelector
) {
1755 var nodeName
= nodeNameSelector
.replace( runescape
, funescape
).toLowerCase();
1756 return nodeNameSelector
=== "*" ?
1757 function() { return true; } :
1759 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === nodeName
;
1763 "CLASS": function( className
) {
1764 var pattern
= classCache
[ className
+ " " ];
1767 (pattern
= new RegExp( "(^|" + whitespace
+ ")" + className
+ "(" + whitespace
+ "|$)" )) &&
1768 classCache( className
, function( elem
) {
1769 return pattern
.test( typeof elem
.className
=== "string" && elem
.className
|| typeof elem
.getAttribute
!== "undefined" && elem
.getAttribute("class") || "" );
1773 "ATTR": function( name
, operator
, check
) {
1774 return function( elem
) {
1775 var result
= Sizzle
.attr( elem
, name
);
1777 if ( result
== null ) {
1778 return operator
=== "!=";
1786 return operator
=== "=" ? result
=== check
:
1787 operator
=== "!=" ? result
!== check
:
1788 operator
=== "^=" ? check
&& result
.indexOf( check
) === 0 :
1789 operator
=== "*=" ? check
&& result
.indexOf( check
) > -1 :
1790 operator
=== "$=" ? check
&& result
.slice( -check
.length
) === check
:
1791 operator
=== "~=" ? ( " " + result
.replace( rwhitespace
, " " ) + " " ).indexOf( check
) > -1 :
1792 operator
=== "|=" ? result
=== check
|| result
.slice( 0, check
.length
+ 1 ) === check
+ "-" :
1797 "CHILD": function( type
, what
, argument
, first
, last
) {
1798 var simple
= type
.slice( 0, 3 ) !== "nth",
1799 forward
= type
.slice( -4 ) !== "last",
1800 ofType
= what
=== "of-type";
1802 return first
=== 1 && last
=== 0 ?
1804 // Shortcut for :nth-*(n)
1806 return !!elem
.parentNode
;
1809 function( elem
, context
, xml
) {
1810 var cache
, uniqueCache
, outerCache
, node
, nodeIndex
, start
,
1811 dir
= simple
!== forward
? "nextSibling" : "previousSibling",
1812 parent
= elem
.parentNode
,
1813 name
= ofType
&& elem
.nodeName
.toLowerCase(),
1814 useCache
= !xml
&& !ofType
,
1819 // :(first|last|only)-(child|of-type)
1823 while ( (node
= node
[ dir
]) ) {
1825 node
.nodeName
.toLowerCase() === name
:
1826 node
.nodeType
=== 1 ) {
1831 // Reverse direction for :only-* (if we haven't yet done so)
1832 start
= dir
= type
=== "only" && !start
&& "nextSibling";
1837 start
= [ forward
? parent
.firstChild
: parent
.lastChild
];
1839 // non-xml :nth-child(...) stores cache data on `parent`
1840 if ( forward
&& useCache
) {
1842 // Seek `elem` from a previously-cached index
1844 // ...in a gzip-friendly way
1846 outerCache
= node
[ expando
] || (node
[ expando
] = {});
1848 // Support: IE <9 only
1849 // Defend against cloned attroperties (jQuery gh-1709)
1850 uniqueCache
= outerCache
[ node
.uniqueID
] ||
1851 (outerCache
[ node
.uniqueID
] = {});
1853 cache
= uniqueCache
[ type
] || [];
1854 nodeIndex
= cache
[ 0 ] === dirruns
&& cache
[ 1 ];
1855 diff
= nodeIndex
&& cache
[ 2 ];
1856 node
= nodeIndex
&& parent
.childNodes
[ nodeIndex
];
1858 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
1860 // Fallback to seeking `elem` from the start
1861 (diff
= nodeIndex
= 0) || start
.pop()) ) {
1863 // When found, cache indexes on `parent` and break
1864 if ( node
.nodeType
=== 1 && ++diff
&& node
=== elem
) {
1865 uniqueCache
[ type
] = [ dirruns
, nodeIndex
, diff
];
1871 // Use previously-cached element index if available
1873 // ...in a gzip-friendly way
1875 outerCache
= node
[ expando
] || (node
[ expando
] = {});
1877 // Support: IE <9 only
1878 // Defend against cloned attroperties (jQuery gh-1709)
1879 uniqueCache
= outerCache
[ node
.uniqueID
] ||
1880 (outerCache
[ node
.uniqueID
] = {});
1882 cache
= uniqueCache
[ type
] || [];
1883 nodeIndex
= cache
[ 0 ] === dirruns
&& cache
[ 1 ];
1887 // xml :nth-child(...)
1888 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
1889 if ( diff
=== false ) {
1890 // Use the same loop as above to seek `elem` from the start
1891 while ( (node
= ++nodeIndex
&& node
&& node
[ dir
] ||
1892 (diff
= nodeIndex
= 0) || start
.pop()) ) {
1895 node
.nodeName
.toLowerCase() === name
:
1896 node
.nodeType
=== 1 ) &&
1899 // Cache the index of each encountered element
1901 outerCache
= node
[ expando
] || (node
[ expando
] = {});
1903 // Support: IE <9 only
1904 // Defend against cloned attroperties (jQuery gh-1709)
1905 uniqueCache
= outerCache
[ node
.uniqueID
] ||
1906 (outerCache
[ node
.uniqueID
] = {});
1908 uniqueCache
[ type
] = [ dirruns
, diff
];
1911 if ( node
=== elem
) {
1919 // Incorporate the offset, then check against cycle size
1921 return diff
=== first
|| ( diff
% first
=== 0 && diff
/ first
>= 0 );
1926 "PSEUDO": function( pseudo
, argument
) {
1927 // pseudo-class names are case-insensitive
1928 // http://www.w3.org/TR/selectors/#pseudo-classes
1929 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1930 // Remember that setFilters inherits from pseudos
1932 fn
= Expr
.pseudos
[ pseudo
] || Expr
.setFilters
[ pseudo
.toLowerCase() ] ||
1933 Sizzle
.error( "unsupported pseudo: " + pseudo
);
1935 // The user may use createPseudo to indicate that
1936 // arguments are needed to create the filter function
1937 // just as Sizzle does
1938 if ( fn
[ expando
] ) {
1939 return fn( argument
);
1942 // But maintain support for old signatures
1943 if ( fn
.length
> 1 ) {
1944 args
= [ pseudo
, pseudo
, "", argument
];
1945 return Expr
.setFilters
.hasOwnProperty( pseudo
.toLowerCase() ) ?
1946 markFunction(function( seed
, matches
) {
1948 matched
= fn( seed
, argument
),
1951 idx
= indexOf( seed
, matched
[i
] );
1952 seed
[ idx
] = !( matches
[ idx
] = matched
[i
] );
1956 return fn( elem
, 0, args
);
1965 // Potentially complex pseudos
1966 "not": markFunction(function( selector
) {
1967 // Trim the selector passed to compile
1968 // to avoid treating leading and trailing
1969 // spaces as combinators
1972 matcher
= compile( selector
.replace( rtrim
, "$1" ) );
1974 return matcher
[ expando
] ?
1975 markFunction(function( seed
, matches
, context
, xml
) {
1977 unmatched
= matcher( seed
, null, xml
, [] ),
1980 // Match elements unmatched by `matcher`
1982 if ( (elem
= unmatched
[i
]) ) {
1983 seed
[i
] = !(matches
[i
] = elem
);
1987 function( elem
, context
, xml
) {
1989 matcher( input
, null, xml
, results
);
1990 // Don't keep the element (issue #299)
1992 return !results
.pop();
1996 "has": markFunction(function( selector
) {
1997 return function( elem
) {
1998 return Sizzle( selector
, elem
).length
> 0;
2002 "contains": markFunction(function( text
) {
2003 text
= text
.replace( runescape
, funescape
);
2004 return function( elem
) {
2005 return ( elem
.textContent
|| elem
.innerText
|| getText( elem
) ).indexOf( text
) > -1;
2009 // "Whether an element is represented by a :lang() selector
2010 // is based solely on the element's language value
2011 // being equal to the identifier C,
2012 // or beginning with the identifier C immediately followed by "-".
2013 // The matching of C against the element's language value is performed case-insensitively.
2014 // The identifier C does not have to be a valid language name."
2015 // http://www.w3.org/TR/selectors/#lang-pseudo
2016 "lang": markFunction( function( lang
) {
2017 // lang value must be a valid identifier
2018 if ( !ridentifier
.test(lang
|| "") ) {
2019 Sizzle
.error( "unsupported lang: " + lang
);
2021 lang
= lang
.replace( runescape
, funescape
).toLowerCase();
2022 return function( elem
) {
2025 if ( (elemLang
= documentIsHTML
?
2027 elem
.getAttribute("xml:lang") || elem
.getAttribute("lang")) ) {
2029 elemLang
= elemLang
.toLowerCase();
2030 return elemLang
=== lang
|| elemLang
.indexOf( lang
+ "-" ) === 0;
2032 } while ( (elem
= elem
.parentNode
) && elem
.nodeType
=== 1 );
2038 "target": function( elem
) {
2039 var hash
= window
.location
&& window
.location
.hash
;
2040 return hash
&& hash
.slice( 1 ) === elem
.id
;
2043 "root": function( elem
) {
2044 return elem
=== docElem
;
2047 "focus": function( elem
) {
2048 return elem
=== document
.activeElement
&& (!document
.hasFocus
|| document
.hasFocus()) && !!(elem
.type
|| elem
.href
|| ~elem
.tabIndex
);
2051 // Boolean properties
2052 "enabled": createDisabledPseudo( false ),
2053 "disabled": createDisabledPseudo( true ),
2055 "checked": function( elem
) {
2056 // In CSS3, :checked should return both checked and selected elements
2057 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
2058 var nodeName
= elem
.nodeName
.toLowerCase();
2059 return (nodeName
=== "input" && !!elem
.checked
) || (nodeName
=== "option" && !!elem
.selected
);
2062 "selected": function( elem
) {
2063 // Accessing this property makes selected-by-default
2064 // options in Safari work properly
2065 if ( elem
.parentNode
) {
2066 elem
.parentNode
.selectedIndex
;
2069 return elem
.selected
=== true;
2073 "empty": function( elem
) {
2074 // http://www.w3.org/TR/selectors/#empty-pseudo
2075 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
2076 // but not by others (comment: 8; processing instruction: 7; etc.)
2077 // nodeType < 6 works because attributes (2) do not appear as children
2078 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
2079 if ( elem
.nodeType
< 6 ) {
2086 "parent": function( elem
) {
2087 return !Expr
.pseudos
["empty"]( elem
);
2090 // Element/input types
2091 "header": function( elem
) {
2092 return rheader
.test( elem
.nodeName
);
2095 "input": function( elem
) {
2096 return rinputs
.test( elem
.nodeName
);
2099 "button": function( elem
) {
2100 var name
= elem
.nodeName
.toLowerCase();
2101 return name
=== "input" && elem
.type
=== "button" || name
=== "button";
2104 "text": function( elem
) {
2106 return elem
.nodeName
.toLowerCase() === "input" &&
2107 elem
.type
=== "text" &&
2110 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
2111 ( (attr
= elem
.getAttribute("type")) == null || attr
.toLowerCase() === "text" );
2114 // Position-in-collection
2115 "first": createPositionalPseudo(function() {
2119 "last": createPositionalPseudo(function( matchIndexes
, length
) {
2120 return [ length
- 1 ];
2123 "eq": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2124 return [ argument
< 0 ? argument
+ length
: argument
];
2127 "even": createPositionalPseudo(function( matchIndexes
, length
) {
2129 for ( ; i
< length
; i
+= 2 ) {
2130 matchIndexes
.push( i
);
2132 return matchIndexes
;
2135 "odd": createPositionalPseudo(function( matchIndexes
, length
) {
2137 for ( ; i
< length
; i
+= 2 ) {
2138 matchIndexes
.push( i
);
2140 return matchIndexes
;
2143 "lt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2144 var i
= argument
< 0 ? argument
+ length
: argument
;
2145 for ( ; --i
>= 0; ) {
2146 matchIndexes
.push( i
);
2148 return matchIndexes
;
2151 "gt": createPositionalPseudo(function( matchIndexes
, length
, argument
) {
2152 var i
= argument
< 0 ? argument
+ length
: argument
;
2153 for ( ; ++i
< length
; ) {
2154 matchIndexes
.push( i
);
2156 return matchIndexes
;
2161 Expr
.pseudos
["nth"] = Expr
.pseudos
["eq"];
2163 // Add button/input type pseudos
2164 for ( i
in { radio
: true, checkbox
: true, file
: true, password
: true, image
: true } ) {
2165 Expr
.pseudos
[ i
] = createInputPseudo( i
);
2167 for ( i
in { submit
: true, reset
: true } ) {
2168 Expr
.pseudos
[ i
] = createButtonPseudo( i
);
2171 // Easy API for creating new setFilters
2172 function setFilters() {}
2173 setFilters
.prototype = Expr
.filters
= Expr
.pseudos
;
2174 Expr
.setFilters
= new setFilters();
2176 tokenize
= Sizzle
.tokenize = function( selector
, parseOnly
) {
2177 var matched
, match
, tokens
, type
,
2178 soFar
, groups
, preFilters
,
2179 cached
= tokenCache
[ selector
+ " " ];
2182 return parseOnly
? 0 : cached
.slice( 0 );
2187 preFilters
= Expr
.preFilter
;
2191 // Comma and first run
2192 if ( !matched
|| (match
= rcomma
.exec( soFar
)) ) {
2194 // Don't consume trailing commas as valid
2195 soFar
= soFar
.slice( match
[0].length
) || soFar
;
2197 groups
.push( (tokens
= []) );
2203 if ( (match
= rcombinators
.exec( soFar
)) ) {
2204 matched
= match
.shift();
2207 // Cast descendant combinators to space
2208 type
: match
[0].replace( rtrim
, " " )
2210 soFar
= soFar
.slice( matched
.length
);
2214 for ( type
in Expr
.filter
) {
2215 if ( (match
= matchExpr
[ type
].exec( soFar
)) && (!preFilters
[ type
] ||
2216 (match
= preFilters
[ type
]( match
))) ) {
2217 matched
= match
.shift();
2223 soFar
= soFar
.slice( matched
.length
);
2232 // Return the length of the invalid excess
2233 // if we're just parsing
2234 // Otherwise, throw an error or return tokens
2238 Sizzle
.error( selector
) :
2240 tokenCache( selector
, groups
).slice( 0 );
2243 function toSelector( tokens
) {
2245 len
= tokens
.length
,
2247 for ( ; i
< len
; i
++ ) {
2248 selector
+= tokens
[i
].value
;
2253 function addCombinator( matcher
, combinator
, base
) {
2254 var dir
= combinator
.dir
,
2255 skip
= combinator
.next
,
2257 checkNonElements
= base
&& key
=== "parentNode",
2260 return combinator
.first
?
2261 // Check against closest ancestor/preceding element
2262 function( elem
, context
, xml
) {
2263 while ( (elem
= elem
[ dir
]) ) {
2264 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2265 return matcher( elem
, context
, xml
);
2271 // Check against all ancestor/preceding elements
2272 function( elem
, context
, xml
) {
2273 var oldCache
, uniqueCache
, outerCache
,
2274 newCache
= [ dirruns
, doneName
];
2276 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2278 while ( (elem
= elem
[ dir
]) ) {
2279 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2280 if ( matcher( elem
, context
, xml
) ) {
2286 while ( (elem
= elem
[ dir
]) ) {
2287 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2288 outerCache
= elem
[ expando
] || (elem
[ expando
] = {});
2290 // Support: IE <9 only
2291 // Defend against cloned attroperties (jQuery gh-1709)
2292 uniqueCache
= outerCache
[ elem
.uniqueID
] || (outerCache
[ elem
.uniqueID
] = {});
2294 if ( skip
&& skip
=== elem
.nodeName
.toLowerCase() ) {
2295 elem
= elem
[ dir
] || elem
;
2296 } else if ( (oldCache
= uniqueCache
[ key
]) &&
2297 oldCache
[ 0 ] === dirruns
&& oldCache
[ 1 ] === doneName
) {
2299 // Assign to newCache so results back-propagate to previous elements
2300 return (newCache
[ 2 ] = oldCache
[ 2 ]);
2302 // Reuse newcache so results back-propagate to previous elements
2303 uniqueCache
[ key
] = newCache
;
2305 // A match means we're done; a fail means we have to keep checking
2306 if ( (newCache
[ 2 ] = matcher( elem
, context
, xml
)) ) {
2317 function elementMatcher( matchers
) {
2318 return matchers
.length
> 1 ?
2319 function( elem
, context
, xml
) {
2320 var i
= matchers
.length
;
2322 if ( !matchers
[i
]( elem
, context
, xml
) ) {
2331 function multipleContexts( selector
, contexts
, results
) {
2333 len
= contexts
.length
;
2334 for ( ; i
< len
; i
++ ) {
2335 Sizzle( selector
, contexts
[i
], results
);
2340 function condense( unmatched
, map
, filter
, context
, xml
) {
2344 len
= unmatched
.length
,
2345 mapped
= map
!= null;
2347 for ( ; i
< len
; i
++ ) {
2348 if ( (elem
= unmatched
[i
]) ) {
2349 if ( !filter
|| filter( elem
, context
, xml
) ) {
2350 newUnmatched
.push( elem
);
2358 return newUnmatched
;
2361 function setMatcher( preFilter
, selector
, matcher
, postFilter
, postFinder
, postSelector
) {
2362 if ( postFilter
&& !postFilter
[ expando
] ) {
2363 postFilter
= setMatcher( postFilter
);
2365 if ( postFinder
&& !postFinder
[ expando
] ) {
2366 postFinder
= setMatcher( postFinder
, postSelector
);
2368 return markFunction(function( seed
, results
, context
, xml
) {
2372 preexisting
= results
.length
,
2374 // Get initial elements from seed or context
2375 elems
= seed
|| multipleContexts( selector
|| "*", context
.nodeType
? [ context
] : context
, [] ),
2377 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2378 matcherIn
= preFilter
&& ( seed
|| !selector
) ?
2379 condense( elems
, preMap
, preFilter
, context
, xml
) :
2382 matcherOut
= matcher
?
2383 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2384 postFinder
|| ( seed
? preFilter
: preexisting
|| postFilter
) ?
2386 // ...intermediate processing is necessary
2389 // ...otherwise use results directly
2393 // Find primary matches
2395 matcher( matcherIn
, matcherOut
, context
, xml
);
2400 temp
= condense( matcherOut
, postMap
);
2401 postFilter( temp
, [], context
, xml
);
2403 // Un-match failing elements by moving them back to matcherIn
2406 if ( (elem
= temp
[i
]) ) {
2407 matcherOut
[ postMap
[i
] ] = !(matcherIn
[ postMap
[i
] ] = elem
);
2413 if ( postFinder
|| preFilter
) {
2415 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2417 i
= matcherOut
.length
;
2419 if ( (elem
= matcherOut
[i
]) ) {
2420 // Restore matcherIn since elem is not yet a final match
2421 temp
.push( (matcherIn
[i
] = elem
) );
2424 postFinder( null, (matcherOut
= []), temp
, xml
);
2427 // Move matched elements from seed to results to keep them synchronized
2428 i
= matcherOut
.length
;
2430 if ( (elem
= matcherOut
[i
]) &&
2431 (temp
= postFinder
? indexOf( seed
, elem
) : preMap
[i
]) > -1 ) {
2433 seed
[temp
] = !(results
[temp
] = elem
);
2438 // Add elements to results, through postFinder if defined
2440 matcherOut
= condense(
2441 matcherOut
=== results
?
2442 matcherOut
.splice( preexisting
, matcherOut
.length
) :
2446 postFinder( null, results
, matcherOut
, xml
);
2448 push
.apply( results
, matcherOut
);
2454 function matcherFromTokens( tokens
) {
2455 var checkContext
, matcher
, j
,
2456 len
= tokens
.length
,
2457 leadingRelative
= Expr
.relative
[ tokens
[0].type
],
2458 implicitRelative
= leadingRelative
|| Expr
.relative
[" "],
2459 i
= leadingRelative
? 1 : 0,
2461 // The foundational matcher ensures that elements are reachable from top-level context(s)
2462 matchContext
= addCombinator( function( elem
) {
2463 return elem
=== checkContext
;
2464 }, implicitRelative
, true ),
2465 matchAnyContext
= addCombinator( function( elem
) {
2466 return indexOf( checkContext
, elem
) > -1;
2467 }, implicitRelative
, true ),
2468 matchers
= [ function( elem
, context
, xml
) {
2469 var ret
= ( !leadingRelative
&& ( xml
|| context
!== outermostContext
) ) || (
2470 (checkContext
= context
).nodeType
?
2471 matchContext( elem
, context
, xml
) :
2472 matchAnyContext( elem
, context
, xml
) );
2473 // Avoid hanging onto element (issue #299)
2474 checkContext
= null;
2478 for ( ; i
< len
; i
++ ) {
2479 if ( (matcher
= Expr
.relative
[ tokens
[i
].type
]) ) {
2480 matchers
= [ addCombinator(elementMatcher( matchers
), matcher
) ];
2482 matcher
= Expr
.filter
[ tokens
[i
].type
].apply( null, tokens
[i
].matches
);
2484 // Return special upon seeing a positional matcher
2485 if ( matcher
[ expando
] ) {
2486 // Find the next relative operator (if any) for proper handling
2488 for ( ; j
< len
; j
++ ) {
2489 if ( Expr
.relative
[ tokens
[j
].type
] ) {
2494 i
> 1 && elementMatcher( matchers
),
2495 i
> 1 && toSelector(
2496 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2497 tokens
.slice( 0, i
- 1 ).concat({ value
: tokens
[ i
- 2 ].type
=== " " ? "*" : "" })
2498 ).replace( rtrim
, "$1" ),
2500 i
< j
&& matcherFromTokens( tokens
.slice( i
, j
) ),
2501 j
< len
&& matcherFromTokens( (tokens
= tokens
.slice( j
)) ),
2502 j
< len
&& toSelector( tokens
)
2505 matchers
.push( matcher
);
2509 return elementMatcher( matchers
);
2512 function matcherFromGroupMatchers( elementMatchers
, setMatchers
) {
2513 var bySet
= setMatchers
.length
> 0,
2514 byElement
= elementMatchers
.length
> 0,
2515 superMatcher = function( seed
, context
, xml
, results
, outermost
) {
2516 var elem
, j
, matcher
,
2519 unmatched
= seed
&& [],
2521 contextBackup
= outermostContext
,
2522 // We must always have either seed elements or outermost context
2523 elems
= seed
|| byElement
&& Expr
.find
["TAG"]( "*", outermost
),
2524 // Use integer dirruns iff this is the outermost matcher
2525 dirrunsUnique
= (dirruns
+= contextBackup
== null ? 1 : Math
.random() || 0.1),
2529 outermostContext
= context
=== document
|| context
|| outermost
;
2532 // Add elements passing elementMatchers directly to results
2533 // Support: IE<9, Safari
2534 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2535 for ( ; i
!== len
&& (elem
= elems
[i
]) != null; i
++ ) {
2536 if ( byElement
&& elem
) {
2538 if ( !context
&& elem
.ownerDocument
!== document
) {
2539 setDocument( elem
);
2540 xml
= !documentIsHTML
;
2542 while ( (matcher
= elementMatchers
[j
++]) ) {
2543 if ( matcher( elem
, context
|| document
, xml
) ) {
2544 results
.push( elem
);
2549 dirruns
= dirrunsUnique
;
2553 // Track unmatched elements for set filters
2555 // They will have gone through all possible matchers
2556 if ( (elem
= !matcher
&& elem
) ) {
2560 // Lengthen the array for every element, matched or not
2562 unmatched
.push( elem
);
2567 // `i` is now the count of elements visited above, and adding it to `matchedCount`
2568 // makes the latter nonnegative.
2571 // Apply set filters to unmatched elements
2572 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2573 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2574 // no element matchers and no seed.
2575 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2576 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2577 // numerically zero.
2578 if ( bySet
&& i
!== matchedCount
) {
2580 while ( (matcher
= setMatchers
[j
++]) ) {
2581 matcher( unmatched
, setMatched
, context
, xml
);
2585 // Reintegrate element matches to eliminate the need for sorting
2586 if ( matchedCount
> 0 ) {
2588 if ( !(unmatched
[i
] || setMatched
[i
]) ) {
2589 setMatched
[i
] = pop
.call( results
);
2594 // Discard index placeholder values to get only actual matches
2595 setMatched
= condense( setMatched
);
2598 // Add matches to results
2599 push
.apply( results
, setMatched
);
2601 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2602 if ( outermost
&& !seed
&& setMatched
.length
> 0 &&
2603 ( matchedCount
+ setMatchers
.length
) > 1 ) {
2605 Sizzle
.uniqueSort( results
);
2609 // Override manipulation of globals by nested matchers
2611 dirruns
= dirrunsUnique
;
2612 outermostContext
= contextBackup
;
2619 markFunction( superMatcher
) :
2623 compile
= Sizzle
.compile = function( selector
, match
/* Internal Use Only */ ) {
2626 elementMatchers
= [],
2627 cached
= compilerCache
[ selector
+ " " ];
2630 // Generate a function of recursive functions that can be used to check each element
2632 match
= tokenize( selector
);
2636 cached
= matcherFromTokens( match
[i
] );
2637 if ( cached
[ expando
] ) {
2638 setMatchers
.push( cached
);
2640 elementMatchers
.push( cached
);
2644 // Cache the compiled function
2645 cached
= compilerCache( selector
, matcherFromGroupMatchers( elementMatchers
, setMatchers
) );
2647 // Save selector and tokenization
2648 cached
.selector
= selector
;
2654 * A low-level selection function that works with Sizzle's compiled
2655 * selector functions
2656 * @param {String|Function} selector A selector or a pre-compiled
2657 * selector function built with Sizzle.compile
2658 * @param {Element} context
2659 * @param {Array} [results]
2660 * @param {Array} [seed] A set of elements to match against
2662 select
= Sizzle
.select = function( selector
, context
, results
, seed
) {
2663 var i
, tokens
, token
, type
, find
,
2664 compiled
= typeof selector
=== "function" && selector
,
2665 match
= !seed
&& tokenize( (selector
= compiled
.selector
|| selector
) );
2667 results
= results
|| [];
2669 // Try to minimize operations if there is only one selector in the list and no seed
2670 // (the latter of which guarantees us context)
2671 if ( match
.length
=== 1 ) {
2673 // Reduce context if the leading compound selector is an ID
2674 tokens
= match
[0] = match
[0].slice( 0 );
2675 if ( tokens
.length
> 2 && (token
= tokens
[0]).type
=== "ID" &&
2676 context
.nodeType
=== 9 && documentIsHTML
&& Expr
.relative
[ tokens
[1].type
] ) {
2678 context
= ( Expr
.find
["ID"]( token
.matches
[0].replace(runescape
, funescape
), context
) || [] )[0];
2682 // Precompiled matchers will still verify ancestry, so step up a level
2683 } else if ( compiled
) {
2684 context
= context
.parentNode
;
2687 selector
= selector
.slice( tokens
.shift().value
.length
);
2690 // Fetch a seed set for right-to-left matching
2691 i
= matchExpr
["needsContext"].test( selector
) ? 0 : tokens
.length
;
2695 // Abort if we hit a combinator
2696 if ( Expr
.relative
[ (type
= token
.type
) ] ) {
2699 if ( (find
= Expr
.find
[ type
]) ) {
2700 // Search, expanding context for leading sibling combinators
2702 token
.matches
[0].replace( runescape
, funescape
),
2703 rsibling
.test( tokens
[0].type
) && testContext( context
.parentNode
) || context
2706 // If seed is empty or no tokens remain, we can return early
2707 tokens
.splice( i
, 1 );
2708 selector
= seed
.length
&& toSelector( tokens
);
2710 push
.apply( results
, seed
);
2720 // Compile and execute a filtering function if one is not provided
2721 // Provide `match` to avoid retokenization if we modified the selector above
2722 ( compiled
|| compile( selector
, match
) )(
2727 !context
|| rsibling
.test( selector
) && testContext( context
.parentNode
) || context
2732 // One-time assignments
2735 support
.sortStable
= expando
.split("").sort( sortOrder
).join("") === expando
;
2737 // Support: Chrome 14-35+
2738 // Always assume duplicates if they aren't passed to the comparison function
2739 support
.detectDuplicates
= !!hasDuplicate
;
2741 // Initialize against the default document
2744 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2745 // Detached nodes confoundingly follow *each other*
2746 support
.sortDetached
= assert(function( el
) {
2747 // Should return 1, but returns 4 (following)
2748 return el
.compareDocumentPosition( document
.createElement("fieldset") ) & 1;
2752 // Prevent attribute/property "interpolation"
2753 // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2754 if ( !assert(function( el
) {
2755 el
.innerHTML
= "<a href='#'></a>";
2756 return el
.firstChild
.getAttribute("href") === "#" ;
2758 addHandle( "type|href|height|width", function( elem
, name
, isXML
) {
2760 return elem
.getAttribute( name
, name
.toLowerCase() === "type" ? 1 : 2 );
2766 // Use defaultValue in place of getAttribute("value")
2767 if ( !support
.attributes
|| !assert(function( el
) {
2768 el
.innerHTML
= "<input/>";
2769 el
.firstChild
.setAttribute( "value", "" );
2770 return el
.firstChild
.getAttribute( "value" ) === "";
2772 addHandle( "value", function( elem
, name
, isXML
) {
2773 if ( !isXML
&& elem
.nodeName
.toLowerCase() === "input" ) {
2774 return elem
.defaultValue
;
2780 // Use getAttributeNode to fetch booleans when getAttribute lies
2781 if ( !assert(function( el
) {
2782 return el
.getAttribute("disabled") == null;
2784 addHandle( booleans
, function( elem
, name
, isXML
) {
2787 return elem
[ name
] === true ? name
.toLowerCase() :
2788 (val
= elem
.getAttributeNode( name
)) && val
.specified
?
2801 jQuery
.find
= Sizzle
;
2802 jQuery
.expr
= Sizzle
.selectors
;
2805 jQuery
.expr
[ ":" ] = jQuery
.expr
.pseudos
;
2806 jQuery
.uniqueSort
= jQuery
.unique
= Sizzle
.uniqueSort
;
2807 jQuery
.text
= Sizzle
.getText
;
2808 jQuery
.isXMLDoc
= Sizzle
.isXML
;
2809 jQuery
.contains
= Sizzle
.contains
;
2810 jQuery
.escapeSelector
= Sizzle
.escape
;
2815 var dir = function( elem
, dir
, until
) {
2817 truncate
= until
!== undefined;
2819 while ( ( elem
= elem
[ dir
] ) && elem
.nodeType
!== 9 ) {
2820 if ( elem
.nodeType
=== 1 ) {
2821 if ( truncate
&& jQuery( elem
).is( until
) ) {
2824 matched
.push( elem
);
2831 var siblings = function( n
, elem
) {
2834 for ( ; n
; n
= n
.nextSibling
) {
2835 if ( n
.nodeType
=== 1 && n
!== elem
) {
2844 var rneedsContext
= jQuery
.expr
.match
.needsContext
;
2846 var rsingleTag
= ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
2850 var risSimple
= /^.[^:#\[\.,]*$/;
2852 // Implement the identical functionality for filter and not
2853 function winnow( elements
, qualifier
, not
) {
2854 if ( jQuery
.isFunction( qualifier
) ) {
2855 return jQuery
.grep( elements
, function( elem
, i
) {
2856 return !!qualifier
.call( elem
, i
, elem
) !== not
;
2861 if ( qualifier
.nodeType
) {
2862 return jQuery
.grep( elements
, function( elem
) {
2863 return ( elem
=== qualifier
) !== not
;
2867 // Arraylike of elements (jQuery, arguments, Array)
2868 if ( typeof qualifier
!== "string" ) {
2869 return jQuery
.grep( elements
, function( elem
) {
2870 return ( indexOf
.call( qualifier
, elem
) > -1 ) !== not
;
2874 // Simple selector that can be filtered directly, removing non-Elements
2875 if ( risSimple
.test( qualifier
) ) {
2876 return jQuery
.filter( qualifier
, elements
, not
);
2879 // Complex selector, compare the two sets, removing non-Elements
2880 qualifier
= jQuery
.filter( qualifier
, elements
);
2881 return jQuery
.grep( elements
, function( elem
) {
2882 return ( indexOf
.call( qualifier
, elem
) > -1 ) !== not
&& elem
.nodeType
=== 1;
2886 jQuery
.filter = function( expr
, elems
, not
) {
2887 var elem
= elems
[ 0 ];
2890 expr
= ":not(" + expr
+ ")";
2893 if ( elems
.length
=== 1 && elem
.nodeType
=== 1 ) {
2894 return jQuery
.find
.matchesSelector( elem
, expr
) ? [ elem
] : [];
2897 return jQuery
.find
.matches( expr
, jQuery
.grep( elems
, function( elem
) {
2898 return elem
.nodeType
=== 1;
2903 find: function( selector
) {
2908 if ( typeof selector
!== "string" ) {
2909 return this.pushStack( jQuery( selector
).filter( function() {
2910 for ( i
= 0; i
< len
; i
++ ) {
2911 if ( jQuery
.contains( self
[ i
], this ) ) {
2918 ret
= this.pushStack( [] );
2920 for ( i
= 0; i
< len
; i
++ ) {
2921 jQuery
.find( selector
, self
[ i
], ret
);
2924 return len
> 1 ? jQuery
.uniqueSort( ret
) : ret
;
2926 filter: function( selector
) {
2927 return this.pushStack( winnow( this, selector
|| [], false ) );
2929 not: function( selector
) {
2930 return this.pushStack( winnow( this, selector
|| [], true ) );
2932 is: function( selector
) {
2936 // If this is a positional/relative selector, check membership in the returned set
2937 // so $("p:first").is("p:last") won't return true for a doc with two "p".
2938 typeof selector
=== "string" && rneedsContext
.test( selector
) ?
2939 jQuery( selector
) :
2947 // Initialize a jQuery object
2950 // A central reference to the root jQuery(document)
2953 // A simple way to check for HTML strings
2954 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
2955 // Strict HTML recognition (#11290: must start with <)
2956 // Shortcut simple #id case for speed
2957 rquickExpr
= /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
2959 init
= jQuery
.fn
.init = function( selector
, context
, root
) {
2962 // HANDLE: $(""), $(null), $(undefined), $(false)
2967 // Method init() accepts an alternate rootjQuery
2968 // so migrate can support jQuery.sub (gh-2101)
2969 root
= root
|| rootjQuery
;
2971 // Handle HTML strings
2972 if ( typeof selector
=== "string" ) {
2973 if ( selector
[ 0 ] === "<" &&
2974 selector
[ selector
.length
- 1 ] === ">" &&
2975 selector
.length
>= 3 ) {
2977 // Assume that strings that start and end with <> are HTML and skip the regex check
2978 match
= [ null, selector
, null ];
2981 match
= rquickExpr
.exec( selector
);
2984 // Match html or make sure no context is specified for #id
2985 if ( match
&& ( match
[ 1 ] || !context
) ) {
2987 // HANDLE: $(html) -> $(array)
2989 context
= context
instanceof jQuery
? context
[ 0 ] : context
;
2991 // Option to run scripts is true for back-compat
2992 // Intentionally let the error be thrown if parseHTML is not present
2993 jQuery
.merge( this, jQuery
.parseHTML(
2995 context
&& context
.nodeType
? context
.ownerDocument
|| context
: document
,
2999 // HANDLE: $(html, props)
3000 if ( rsingleTag
.test( match
[ 1 ] ) && jQuery
.isPlainObject( context
) ) {
3001 for ( match
in context
) {
3003 // Properties of context are called as methods if possible
3004 if ( jQuery
.isFunction( this[ match
] ) ) {
3005 this[ match
]( context
[ match
] );
3007 // ...and otherwise set as attributes
3009 this.attr( match
, context
[ match
] );
3018 elem
= document
.getElementById( match
[ 2 ] );
3022 // Inject the element directly into the jQuery object
3029 // HANDLE: $(expr, $(...))
3030 } else if ( !context
|| context
.jquery
) {
3031 return ( context
|| root
).find( selector
);
3033 // HANDLE: $(expr, context)
3034 // (which is just equivalent to: $(context).find(expr)
3036 return this.constructor( context
).find( selector
);
3039 // HANDLE: $(DOMElement)
3040 } else if ( selector
.nodeType
) {
3041 this[ 0 ] = selector
;
3045 // HANDLE: $(function)
3046 // Shortcut for document ready
3047 } else if ( jQuery
.isFunction( selector
) ) {
3048 return root
.ready
!== undefined ?
3049 root
.ready( selector
) :
3051 // Execute immediately if ready is not present
3055 return jQuery
.makeArray( selector
, this );
3058 // Give the init function the jQuery prototype for later instantiation
3059 init
.prototype = jQuery
.fn
;
3061 // Initialize central reference
3062 rootjQuery
= jQuery( document
);
3065 var rparentsprev
= /^(?:parents|prev(?:Until|All))/,
3067 // Methods guaranteed to produce a unique set when starting from a unique set
3068 guaranteedUnique
= {
3076 has: function( target
) {
3077 var targets
= jQuery( target
, this ),
3080 return this.filter( function() {
3082 for ( ; i
< l
; i
++ ) {
3083 if ( jQuery
.contains( this, targets
[ i
] ) ) {
3090 closest: function( selectors
, context
) {
3095 targets
= typeof selectors
!== "string" && jQuery( selectors
);
3097 // Positional selectors never match, since there's no _selection_ context
3098 if ( !rneedsContext
.test( selectors
) ) {
3099 for ( ; i
< l
; i
++ ) {
3100 for ( cur
= this[ i
]; cur
&& cur
!== context
; cur
= cur
.parentNode
) {
3102 // Always skip document fragments
3103 if ( cur
.nodeType
< 11 && ( targets
?
3104 targets
.index( cur
) > -1 :
3106 // Don't pass non-elements to Sizzle
3107 cur
.nodeType
=== 1 &&
3108 jQuery
.find
.matchesSelector( cur
, selectors
) ) ) {
3110 matched
.push( cur
);
3117 return this.pushStack( matched
.length
> 1 ? jQuery
.uniqueSort( matched
) : matched
);
3120 // Determine the position of an element within the set
3121 index: function( elem
) {
3123 // No argument, return index in parent
3125 return ( this[ 0 ] && this[ 0 ].parentNode
) ? this.first().prevAll().length
: -1;
3128 // Index in selector
3129 if ( typeof elem
=== "string" ) {
3130 return indexOf
.call( jQuery( elem
), this[ 0 ] );
3133 // Locate the position of the desired element
3134 return indexOf
.call( this,
3136 // If it receives a jQuery object, the first element is used
3137 elem
.jquery
? elem
[ 0 ] : elem
3141 add: function( selector
, context
) {
3142 return this.pushStack(
3144 jQuery
.merge( this.get(), jQuery( selector
, context
) )
3149 addBack: function( selector
) {
3150 return this.add( selector
== null ?
3151 this.prevObject
: this.prevObject
.filter( selector
)
3156 function sibling( cur
, dir
) {
3157 while ( ( cur
= cur
[ dir
] ) && cur
.nodeType
!== 1 ) {}
3162 parent: function( elem
) {
3163 var parent
= elem
.parentNode
;
3164 return parent
&& parent
.nodeType
!== 11 ? parent
: null;
3166 parents: function( elem
) {
3167 return dir( elem
, "parentNode" );
3169 parentsUntil: function( elem
, i
, until
) {
3170 return dir( elem
, "parentNode", until
);
3172 next: function( elem
) {
3173 return sibling( elem
, "nextSibling" );
3175 prev: function( elem
) {
3176 return sibling( elem
, "previousSibling" );
3178 nextAll: function( elem
) {
3179 return dir( elem
, "nextSibling" );
3181 prevAll: function( elem
) {
3182 return dir( elem
, "previousSibling" );
3184 nextUntil: function( elem
, i
, until
) {
3185 return dir( elem
, "nextSibling", until
);
3187 prevUntil: function( elem
, i
, until
) {
3188 return dir( elem
, "previousSibling", until
);
3190 siblings: function( elem
) {
3191 return siblings( ( elem
.parentNode
|| {} ).firstChild
, elem
);
3193 children: function( elem
) {
3194 return siblings( elem
.firstChild
);
3196 contents: function( elem
) {
3197 return elem
.contentDocument
|| jQuery
.merge( [], elem
.childNodes
);
3199 }, function( name
, fn
) {
3200 jQuery
.fn
[ name
] = function( until
, selector
) {
3201 var matched
= jQuery
.map( this, fn
, until
);
3203 if ( name
.slice( -5 ) !== "Until" ) {
3207 if ( selector
&& typeof selector
=== "string" ) {
3208 matched
= jQuery
.filter( selector
, matched
);
3211 if ( this.length
> 1 ) {
3213 // Remove duplicates
3214 if ( !guaranteedUnique
[ name
] ) {
3215 jQuery
.uniqueSort( matched
);
3218 // Reverse order for parents* and prev-derivatives
3219 if ( rparentsprev
.test( name
) ) {
3224 return this.pushStack( matched
);
3227 var rnothtmlwhite
= ( /[^\x20\t\r\n\f]+/g );
3231 // Convert String-formatted options into Object-formatted ones
3232 function createOptions( options
) {
3234 jQuery
.each( options
.match( rnothtmlwhite
) || [], function( _
, flag
) {
3235 object
[ flag
] = true;
3241 * Create a callback list using the following parameters:
3243 * options: an optional list of space-separated options that will change how
3244 * the callback list behaves or a more traditional option object
3246 * By default a callback list will act like an event callback list and can be
3247 * "fired" multiple times.
3251 * once: will ensure the callback list can only be fired once (like a Deferred)
3253 * memory: will keep track of previous values and will call any callback added
3254 * after the list has been fired right away with the latest "memorized"
3255 * values (like a Deferred)
3257 * unique: will ensure a callback can only be added once (no duplicate in the list)
3259 * stopOnFalse: interrupt callings when a callback returns false
3262 jQuery
.Callbacks = function( options
) {
3264 // Convert options from String-formatted to Object-formatted if needed
3265 // (we check in cache first)
3266 options
= typeof options
=== "string" ?
3267 createOptions( options
) :
3268 jQuery
.extend( {}, options
);
3270 var // Flag to know if list is currently firing
3273 // Last fire value for non-forgettable lists
3276 // Flag to know if list was already fired
3279 // Flag to prevent firing
3282 // Actual callback list
3285 // Queue of execution data for repeatable lists
3288 // Index of currently firing callback (modified by add/remove as needed)
3294 // Enforce single-firing
3295 locked
= options
.once
;
3297 // Execute callbacks for all pending executions,
3298 // respecting firingIndex overrides and runtime changes
3299 fired
= firing
= true;
3300 for ( ; queue
.length
; firingIndex
= -1 ) {
3301 memory
= queue
.shift();
3302 while ( ++firingIndex
< list
.length
) {
3304 // Run callback and check for early termination
3305 if ( list
[ firingIndex
].apply( memory
[ 0 ], memory
[ 1 ] ) === false &&
3306 options
.stopOnFalse
) {
3308 // Jump to end and forget the data so .add doesn't re-fire
3309 firingIndex
= list
.length
;
3315 // Forget the data if we're done with it
3316 if ( !options
.memory
) {
3322 // Clean up if we're done firing for good
3325 // Keep an empty list if we have data for future add calls
3329 // Otherwise, this object is spent
3336 // Actual Callbacks object
3339 // Add a callback or a collection of callbacks to the list
3343 // If we have memory from a past run, we should fire after adding
3344 if ( memory
&& !firing
) {
3345 firingIndex
= list
.length
- 1;
3346 queue
.push( memory
);
3349 ( function add( args
) {
3350 jQuery
.each( args
, function( _
, arg
) {
3351 if ( jQuery
.isFunction( arg
) ) {
3352 if ( !options
.unique
|| !self
.has( arg
) ) {
3355 } else if ( arg
&& arg
.length
&& jQuery
.type( arg
) !== "string" ) {
3357 // Inspect recursively
3363 if ( memory
&& !firing
) {
3370 // Remove a callback from the list
3371 remove: function() {
3372 jQuery
.each( arguments
, function( _
, arg
) {
3374 while ( ( index
= jQuery
.inArray( arg
, list
, index
) ) > -1 ) {
3375 list
.splice( index
, 1 );
3377 // Handle firing indexes
3378 if ( index
<= firingIndex
) {
3386 // Check if a given callback is in the list.
3387 // If no argument is given, return whether or not list has callbacks attached.
3388 has: function( fn
) {
3390 jQuery
.inArray( fn
, list
) > -1 :
3394 // Remove all callbacks from the list
3402 // Disable .fire and .add
3403 // Abort any current/pending executions
3404 // Clear all callbacks and values
3405 disable: function() {
3406 locked
= queue
= [];
3410 disabled: function() {
3415 // Also disable .add unless we have memory (since it would have no effect)
3416 // Abort any pending executions
3418 locked
= queue
= [];
3419 if ( !memory
&& !firing
) {
3424 locked: function() {
3428 // Call all callbacks with the given context and arguments
3429 fireWith: function( context
, args
) {
3432 args
= [ context
, args
.slice
? args
.slice() : args
];
3441 // Call all the callbacks with the given arguments
3443 self
.fireWith( this, arguments
);
3447 // To know if the callbacks have already been called at least once
3457 function Identity( v
) {
3460 function Thrower( ex
) {
3464 function adoptValue( value
, resolve
, reject
) {
3469 // Check for promise aspect first to privilege synchronous behavior
3470 if ( value
&& jQuery
.isFunction( ( method
= value
.promise
) ) ) {
3471 method
.call( value
).done( resolve
).fail( reject
);
3474 } else if ( value
&& jQuery
.isFunction( ( method
= value
.then
) ) ) {
3475 method
.call( value
, resolve
, reject
);
3477 // Other non-thenables
3480 // Support: Android 4.0 only
3481 // Strict mode functions invoked without .call/.apply get global-object context
3482 resolve
.call( undefined, value
);
3485 // For Promises/A+, convert exceptions into rejections
3486 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
3487 // Deferred#then to conditionally suppress rejection.
3490 // Support: Android 4.0 only
3491 // Strict mode functions invoked without .call/.apply get global-object context
3492 reject
.call( undefined, value
);
3498 Deferred: function( func
) {
3501 // action, add listener, callbacks,
3502 // ... .then handlers, argument index, [final state]
3503 [ "notify", "progress", jQuery
.Callbacks( "memory" ),
3504 jQuery
.Callbacks( "memory" ), 2 ],
3505 [ "resolve", "done", jQuery
.Callbacks( "once memory" ),
3506 jQuery
.Callbacks( "once memory" ), 0, "resolved" ],
3507 [ "reject", "fail", jQuery
.Callbacks( "once memory" ),
3508 jQuery
.Callbacks( "once memory" ), 1, "rejected" ]
3515 always: function() {
3516 deferred
.done( arguments
).fail( arguments
);
3519 "catch": function( fn
) {
3520 return promise
.then( null, fn
);
3523 // Keep pipe for back-compat
3524 pipe: function( /* fnDone, fnFail, fnProgress */ ) {
3525 var fns
= arguments
;
3527 return jQuery
.Deferred( function( newDefer
) {
3528 jQuery
.each( tuples
, function( i
, tuple
) {
3530 // Map tuples (progress, done, fail) to arguments (done, fail, progress)
3531 var fn
= jQuery
.isFunction( fns
[ tuple
[ 4 ] ] ) && fns
[ tuple
[ 4 ] ];
3533 // deferred.progress(function() { bind to newDefer or newDefer.notify })
3534 // deferred.done(function() { bind to newDefer or newDefer.resolve })
3535 // deferred.fail(function() { bind to newDefer or newDefer.reject })
3536 deferred
[ tuple
[ 1 ] ]( function() {
3537 var returned
= fn
&& fn
.apply( this, arguments
);
3538 if ( returned
&& jQuery
.isFunction( returned
.promise
) ) {
3540 .progress( newDefer
.notify
)
3541 .done( newDefer
.resolve
)
3542 .fail( newDefer
.reject
);
3544 newDefer
[ tuple
[ 0 ] + "With" ](