2 * jQuery JavaScript Library v3.6.0
6 * https://sizzlejs.com/
8 * Copyright OpenJS Foundation and other contributors
9 * Released under the MIT license
10 * https://jquery.org/license
12 * Date: 2021-03-02T17:08Z
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 getProto
= Object
.getPrototypeOf
;
52 var slice
= arr
.slice
;
54 var flat
= arr
.flat
? function( array
) {
55 return arr
.flat
.call( array
);
56 } : function( array
) {
57 return arr
.concat
.apply( [], array
);
63 var indexOf
= arr
.indexOf
;
67 var toString
= class2type
.toString
;
69 var hasOwn
= class2type
.hasOwnProperty
;
71 var fnToString
= hasOwn
.toString
;
73 var ObjectFunctionString
= fnToString
.call( Object
);
77 var isFunction
= function isFunction( obj
) {
79 // Support: Chrome <=57, Firefox <=52
80 // In some browsers, typeof returns "function" for HTML <object> elements
81 // (i.e., `typeof document.createElement( "object" ) === "function"`).
82 // We don't want to classify *any* DOM node as a function.
83 // Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5
84 // Plus for old WebKit, typeof returns "function" for HTML collections
85 // (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756)
86 return typeof obj
=== "function" && typeof obj
.nodeType
!== "number" &&
87 typeof obj
.item
!== "function";
91 var isWindow
= function isWindow( obj
) {
92 return obj
!= null && obj
=== obj
.window
;
96 var document
= window
.document
;
100 var preservedScriptAttributes
= {
107 function DOMEval( code
, node
, doc
) {
108 doc
= doc
|| document
;
111 script
= doc
.createElement( "script" );
115 for ( i
in preservedScriptAttributes
) {
117 // Support: Firefox 64+, Edge 18+
118 // Some browsers don't support the "nonce" property on scripts.
119 // On the other hand, just using `getAttribute` is not enough as
120 // the `nonce` attribute is reset to an empty string whenever it
121 // becomes browsing-context connected.
122 // See https://github.com/whatwg/html/issues/2369
123 // See https://html.spec.whatwg.org/#nonce-attributes
124 // The `node.getAttribute` check was added for the sake of
125 // `jQuery.globalEval` so that it can fake a nonce-containing node
127 val
= node
[ i
] || node
.getAttribute
&& node
.getAttribute( i
);
129 script
.setAttribute( i
, val
);
133 doc
.head
.appendChild( script
).parentNode
.removeChild( script
);
137 function toType( obj
) {
142 // Support: Android <=2.3 only (functionish RegExp)
143 return typeof obj
=== "object" || typeof obj
=== "function" ?
144 class2type
[ toString
.call( obj
) ] || "object" :
148 // Defining this global in .eslintrc.json would create a danger of using the global
149 // unguarded in another place, it seems safer to define global only for this module
156 // Define a local copy of jQuery
157 jQuery = function( selector
, context
) {
159 // The jQuery object is actually just the init constructor 'enhanced'
160 // Need init if jQuery is called (just allow error to be thrown if not included)
161 return new jQuery
.fn
.init( selector
, context
);
164 jQuery
.fn
= jQuery
.prototype = {
166 // The current version of jQuery being used
171 // The default length of a jQuery object is 0
174 toArray: function() {
175 return slice
.call( this );
178 // Get the Nth element in the matched element set OR
179 // Get the whole matched element set as a clean array
180 get: function( num
) {
182 // Return all the elements in a clean array
184 return slice
.call( this );
187 // Return just the one element from the set
188 return num
< 0 ? this[ num
+ this.length
] : this[ num
];
191 // Take an array of elements and push it onto the stack
192 // (returning the new matched element set)
193 pushStack: function( elems
) {
195 // Build a new jQuery matched element set
196 var ret
= jQuery
.merge( this.constructor(), elems
);
198 // Add the old object onto the stack (as a reference)
199 ret
.prevObject
= this;
201 // Return the newly-formed element set
205 // Execute a callback for every element in the matched set.
206 each: function( callback
) {
207 return jQuery
.each( this, callback
);
210 map: function( callback
) {
211 return this.pushStack( jQuery
.map( this, function( elem
, i
) {
212 return callback
.call( elem
, i
, elem
);
217 return this.pushStack( slice
.apply( this, arguments
) );
225 return this.eq( -1 );
229 return this.pushStack( jQuery
.grep( this, function( _elem
, i
) {
230 return ( i
+ 1 ) % 2;
235 return this.pushStack( jQuery
.grep( this, function( _elem
, i
) {
241 var len
= this.length
,
242 j
= +i
+ ( i
< 0 ? len : 0 );
243 return this.pushStack( j
>= 0 && j
< len
? [ this[ j
] ] : [] );
247 return this.prevObject
|| this.constructor();
250 // For internal use only.
251 // Behaves like an Array's method, not like a jQuery method.
257 jQuery
.extend
= jQuery
.fn
.extend = function() {
258 var options
, name
, src
, copy
, copyIsArray
, clone
,
259 target
= arguments
[ 0 ] || {},
261 length
= arguments
.length
,
264 // Handle a deep copy situation
265 if ( typeof target
=== "boolean" ) {
268 // Skip the boolean and the target
269 target
= arguments
[ i
] || {};
273 // Handle case when target is a string or something (possible in deep copy)
274 if ( typeof target
!== "object" && !isFunction( target
) ) {
278 // Extend jQuery itself if only one argument is passed
279 if ( i
=== length
) {
284 for ( ; i
< length
; i
++ ) {
286 // Only deal with non-null/undefined values
287 if ( ( options
= arguments
[ i
] ) != null ) {
289 // Extend the base object
290 for ( name
in options
) {
291 copy
= options
[ name
];
293 // Prevent Object.prototype pollution
294 // Prevent never-ending loop
295 if ( name
=== "__proto__" || target
=== copy
) {
299 // Recurse if we're merging plain objects or arrays
300 if ( deep
&& copy
&& ( jQuery
.isPlainObject( copy
) ||
301 ( copyIsArray
= Array
.isArray( copy
) ) ) ) {
302 src
= target
[ name
];
304 // Ensure proper type for the source value
305 if ( copyIsArray
&& !Array
.isArray( src
) ) {
307 } else if ( !copyIsArray
&& !jQuery
.isPlainObject( src
) ) {
314 // Never move original objects, clone them
315 target
[ name
] = jQuery
.extend( deep
, clone
, copy
);
317 // Don't bring in undefined values
318 } else if ( copy
!== undefined ) {
319 target
[ name
] = copy
;
325 // Return the modified object
331 // Unique for each copy of jQuery on the page
332 expando: "jQuery" + ( version
+ Math
.random() ).replace( /\D/g, "" ),
334 // Assume jQuery is ready without the ready module
337 error: function( msg
) {
338 throw new Error( msg
);
343 isPlainObject: function( obj
) {
346 // Detect obvious negatives
347 // Use toString instead of jQuery.type to catch host objects
348 if ( !obj
|| toString
.call( obj
) !== "[object Object]" ) {
352 proto
= getProto( obj
);
354 // Objects with no prototype (e.g., `Object.create( null )`) are plain
359 // Objects with prototype are plain iff they were constructed by a global Object function
360 Ctor
= hasOwn
.call( proto
, "constructor" ) && proto
.constructor;
361 return typeof Ctor
=== "function" && fnToString
.call( Ctor
) === ObjectFunctionString
;
364 isEmptyObject: function( obj
) {
367 for ( name
in obj
) {
373 // Evaluates a script in a provided context; falls back to the global one
375 globalEval: function( code
, options
, doc
) {
376 DOMEval( code
, { nonce: options
&& options
.nonce
}, doc
);
379 each: function( obj
, callback
) {
382 if ( isArrayLike( obj
) ) {
384 for ( ; i
< length
; i
++ ) {
385 if ( callback
.call( obj
[ i
], i
, obj
[ i
] ) === false ) {
391 if ( callback
.call( obj
[ i
], i
, obj
[ i
] ) === false ) {
400 // results is for internal usage only
401 makeArray: function( arr
, results
) {
402 var ret
= results
|| [];
405 if ( isArrayLike( Object( arr
) ) ) {
407 typeof arr
=== "string" ?
411 push
.call( ret
, arr
);
418 inArray: function( elem
, arr
, i
) {
419 return arr
== null ? -1 : indexOf
.call( arr
, elem
, i
);
422 // Support: Android <=4.0 only, PhantomJS 1 only
423 // push.apply(_, arraylike) throws on ancient WebKit
424 merge: function( first
, second
) {
425 var len
= +second
.length
,
429 for ( ; j
< len
; j
++ ) {
430 first
[ i
++ ] = second
[ j
];
438 grep: function( elems
, callback
, invert
) {
442 length
= elems
.length
,
443 callbackExpect
= !invert
;
445 // Go through the array, only saving the items
446 // that pass the validator function
447 for ( ; i
< length
; i
++ ) {
448 callbackInverse
= !callback( elems
[ i
], i
);
449 if ( callbackInverse
!== callbackExpect
) {
450 matches
.push( elems
[ i
] );
457 // arg is for internal usage only
458 map: function( elems
, callback
, arg
) {
463 // Go through the array, translating each of the items to their new values
464 if ( isArrayLike( elems
) ) {
465 length
= elems
.length
;
466 for ( ; i
< length
; i
++ ) {
467 value
= callback( elems
[ i
], i
, arg
);
469 if ( value
!= null ) {
474 // Go through every key on the object,
477 value
= callback( elems
[ i
], i
, arg
);
479 if ( value
!= null ) {
485 // Flatten any nested arrays
489 // A global GUID counter for objects
492 // jQuery.support is not used in Core but other projects attach their
493 // properties to it so it needs to exist.
497 if ( typeof Symbol
=== "function" ) {
498 jQuery
.fn
[ Symbol
.iterator
] = arr
[ Symbol
.iterator
];
501 // Populate the class2type map
502 jQuery
.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
503 function( _i
, name
) {
504 class2type
[ "[object " + name
+ "]" ] = name
.toLowerCase();
507 function isArrayLike( obj
) {
509 // Support: real iOS 8.2 only (not reproducible in simulator)
510 // `in` check used to prevent JIT error (gh-2145)
511 // hasOwn isn't used here due to false negatives
512 // regarding Nodelist length in IE
513 var length
= !!obj
&& "length" in obj
&& obj
.length
,
514 type
= toType( obj
);
516 if ( isFunction( obj
) || isWindow( obj
) ) {
520 return type
=== "array" || length
=== 0 ||
521 typeof length
=== "number" && length
> 0 && ( length
- 1 ) in obj
;
525 * Sizzle CSS Selector Engine v2.3.6
526 * https://sizzlejs.com/
528 * Copyright JS Foundation and other contributors
529 * Released under the MIT license
530 * https://js.foundation/
534 ( function( window
) {
547 // Local document vars
557 // Instance-specific data
558 expando
= "sizzle" + 1 * new Date(),
559 preferredDoc
= window
.document
,
562 classCache
= createCache(),
563 tokenCache
= createCache(),
564 compilerCache
= createCache(),
565 nonnativeSelectorCache
= createCache(),
566 sortOrder = function( a
, b
) {
574 hasOwn
= ( {} ).hasOwnProperty
,
577 pushNative
= arr
.push
,
581 // Use a stripped-down indexOf as it's faster than native
582 // https://jsperf.com/thor-indexof-vs-for/5
583 indexOf = function( list
, elem
) {
586 for ( ; i
< len
; i
++ ) {
587 if ( list
[ i
] === elem
) {
594 booleans
= "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" +
595 "ismap|loop|multiple|open|readonly|required|scoped",
597 // Regular expressions
599 // http://www.w3.org/TR/css3-selectors/#whitespace
600 whitespace
= "[\\x20\\t\\r\\n\\f]",
602 // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
603 identifier
= "(?:\\\\[\\da-fA-F]{1,6}" + whitespace
+
604 "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
606 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
607 attributes
= "\\[" + whitespace
+ "*(" + identifier
+ ")(?:" + whitespace
+
609 // Operator (capture 2)
610 "*([*^$|!~]?=)" + whitespace
+
612 // "Attribute values must be CSS identifiers [capture 5]
613 // or strings [capture 3 or capture 4]"
614 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier
+ "))|)" +
617 pseudos
= ":(" + identifier
+ ")(?:\\((" +
619 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
620 // 1. quoted (capture 3; capture 4 or capture 5)
621 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
623 // 2. simple (capture 6)
624 "((?:\\\\.|[^\\\\()[\\]]|" + attributes
+ ")*)|" +
626 // 3. anything else (capture 2)
630 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
631 rwhitespace
= new RegExp( whitespace
+ "+", "g" ),
632 rtrim
= new RegExp( "^" + whitespace
+ "+|((?:^|[^\\\\])(?:\\\\.)*)" +
633 whitespace
+ "+$", "g" ),
635 rcomma
= new RegExp( "^" + whitespace
+ "*," + whitespace
+ "*" ),
636 rcombinators
= new RegExp( "^" + whitespace
+ "*([>+~]|" + whitespace
+ ")" + whitespace
+
638 rdescend
= new RegExp( whitespace
+ "|>" ),
640 rpseudo
= new RegExp( pseudos
),
641 ridentifier
= new RegExp( "^" + identifier
+ "$" ),
644 "ID": new RegExp( "^#(" + identifier
+ ")" ),
645 "CLASS": new RegExp( "^\\.(" + identifier
+ ")" ),
646 "TAG": new RegExp( "^(" + identifier
+ "|[*])" ),
647 "ATTR": new RegExp( "^" + attributes
),
648 "PSEUDO": new RegExp( "^" + pseudos
),
649 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
650 whitespace
+ "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace
+ "*(?:([+-]|)" +
651 whitespace
+ "*(\\d+)|))" + whitespace
+ "*\\)|)", "i" ),
652 "bool": new RegExp( "^(?:" + booleans
+ ")$", "i" ),
654 // For use in libraries implementing .is()
655 // We use this for POS matching in `select`
656 "needsContext": new RegExp( "^" + whitespace
+
657 "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace
+
658 "*((?:-\\d)?\\d*)" + whitespace
+ "*\\)|)(?=[^-]|$)", "i" )
662 rinputs
= /^(?:input|select|textarea|button)$/i,
665 rnative
= /^[^{]+\{\s
*\[native \w
/,
667 // Easily-parseable/retrievable ID or TAG or CLASS selectors
668 rquickExpr
= /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
673 // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
674 runescape
= new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace
+ "?|\\\\([^\\r\\n\\f])", "g" ),
675 funescape = function( escape
, nonHex
) {
676 var high
= "0x" + escape
.slice( 1 ) - 0x10000;
680 // Strip the backslash prefix from a non-hex escape sequence
683 // Replace a hexadecimal escape sequence with the encoded Unicode code point
685 // For values outside the Basic Multilingual Plane (BMP), manually construct a
688 String
.fromCharCode( high
+ 0x10000 ) :
689 String
.fromCharCode( high
>> 10 | 0xD800, high
& 0x3FF | 0xDC00 );
692 // CSS string/identifier serialization
693 // https://drafts.csswg.org/cssom/#common-serializing-idioms
694 rcssescape
= /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
695 fcssescape = function( ch
, asCodePoint
) {
698 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
703 // Control characters and (dependent upon position) numbers get escaped as code points
704 return ch
.slice( 0, -1 ) + "\\" +
705 ch
.charCodeAt( ch
.length
- 1 ).toString( 16 ) + " ";
708 // Other potentially-special ASCII characters get backslash-escaped
714 // Removing the function wrapper causes a "Permission Denied"
716 unloadHandler = function() {
720 inDisabledFieldset
= addCombinator(
722 return elem
.disabled
=== true && elem
.nodeName
.toLowerCase() === "fieldset";
724 { dir: "parentNode", next: "legend" }
727 // Optimize for push.apply( _, NodeList )
730 ( arr
= slice
.call( preferredDoc
.childNodes
) ),
731 preferredDoc
.childNodes
734 // Support: Android<4.0
735 // Detect silently failing push.apply
736 // eslint-disable-next-line no-unused-expressions
737 arr
[ preferredDoc
.childNodes
.length
].nodeType
;
739 push
= { apply: arr
.length
?
741 // Leverage slice if possible
742 function( target
, els
) {
743 pushNative
.apply( target
, slice
.call( els
) );
747 // Otherwise append directly
748 function( target
, els
) {
749 var j
= target
.length
,
752 // Can't trust NodeList.length
753 while ( ( target
[ j
++ ] = els
[ i
++ ] ) ) {}
754 target
.length
= j
- 1;
759 function Sizzle( selector
, context
, results
, seed
) {
760 var m
, i
, elem
, nid
, match
, groups
, newSelector
,
761 newContext
= context
&& context
.ownerDocument
,
763 // nodeType defaults to 9, since context defaults to document
764 nodeType
= context
? context
.nodeType : 9;
766 results
= results
|| [];
768 // Return early from calls with invalid selector or context
769 if ( typeof selector
!== "string" || !selector
||
770 nodeType
!== 1 && nodeType
!== 9 && nodeType
!== 11 ) {
775 // Try to shortcut find operations (as opposed to filters) in HTML documents
777 setDocument( context
);
778 context
= context
|| document
;
780 if ( documentIsHTML
) {
782 // If the selector is sufficiently simple, try using a "get*By*" DOM method
783 // (excepting DocumentFragment context, where the methods don't exist)
784 if ( nodeType
!== 11 && ( match
= rquickExpr
.exec( selector
) ) ) {
787 if ( ( m
= match
[ 1 ] ) ) {
790 if ( nodeType
=== 9 ) {
791 if ( ( elem
= context
.getElementById( m
) ) ) {
793 // Support: IE, Opera, Webkit
794 // TODO: identify versions
795 // getElementById can match elements by name instead of ID
796 if ( elem
.id
=== m
) {
797 results
.push( elem
);
807 // Support: IE, Opera, Webkit
808 // TODO: identify versions
809 // getElementById can match elements by name instead of ID
810 if ( newContext
&& ( elem
= newContext
.getElementById( m
) ) &&
811 contains( context
, elem
) &&
814 results
.push( elem
);
820 } else if ( match
[ 2 ] ) {
821 push
.apply( results
, context
.getElementsByTagName( selector
) );
825 } else if ( ( m
= match
[ 3 ] ) && support
.getElementsByClassName
&&
826 context
.getElementsByClassName
) {
828 push
.apply( results
, context
.getElementsByClassName( m
) );
833 // Take advantage of querySelectorAll
835 !nonnativeSelectorCache
[ selector
+ " " ] &&
836 ( !rbuggyQSA
|| !rbuggyQSA
.test( selector
) ) &&
838 // Support: IE 8 only
839 // Exclude object elements
840 ( nodeType
!== 1 || context
.nodeName
.toLowerCase() !== "object" ) ) {
842 newSelector
= selector
;
843 newContext
= context
;
845 // qSA considers elements outside a scoping root when evaluating child or
846 // descendant combinators, which is not what we want.
847 // In such cases, we work around the behavior by prefixing every selector in the
848 // list with an ID selector referencing the scope context.
849 // The technique has to be used as well when a leading combinator is used
850 // as such selectors are not recognized by querySelectorAll.
851 // Thanks to Andrew Dupont for this technique.
852 if ( nodeType
=== 1 &&
853 ( rdescend
.test( selector
) || rcombinators
.test( selector
) ) ) {
855 // Expand context for sibling selectors
856 newContext
= rsibling
.test( selector
) && testContext( context
.parentNode
) ||
859 // We can use :scope instead of the ID hack if the browser
860 // supports it & if we're not changing the context.
861 if ( newContext
!== context
|| !support
.scope
) {
863 // Capture the context ID, setting it first if necessary
864 if ( ( nid
= context
.getAttribute( "id" ) ) ) {
865 nid
= nid
.replace( rcssescape
, fcssescape
);
867 context
.setAttribute( "id", ( nid
= expando
) );
871 // Prefix every selector in the list
872 groups
= tokenize( selector
);
875 groups
[ i
] = ( nid
? "#" + nid : ":scope" ) + " " +
876 toSelector( groups
[ i
] );
878 newSelector
= groups
.join( "," );
883 newContext
.querySelectorAll( newSelector
)
886 } catch ( qsaError
) {
887 nonnativeSelectorCache( selector
, true );
889 if ( nid
=== expando
) {
890 context
.removeAttribute( "id" );
898 return select( selector
.replace( rtrim
, "$1" ), context
, results
, seed
);
902 * Create key-value caches of limited size
903 * @returns {function(string, object)} Returns the Object data after storing it on itself with
904 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
905 * deleting the oldest entry
907 function createCache() {
910 function cache( key
, value
) {
912 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
913 if ( keys
.push( key
+ " " ) > Expr
.cacheLength
) {
915 // Only keep the most recent entries
916 delete cache
[ keys
.shift() ];
918 return ( cache
[ key
+ " " ] = value
);
924 * Mark a function for special use by Sizzle
925 * @param {Function} fn The function to mark
927 function markFunction( fn
) {
928 fn
[ expando
] = true;
933 * Support testing using an element
934 * @param {Function} fn Passed the created element and returns a boolean result
936 function assert( fn
) {
937 var el
= document
.createElement( "fieldset" );
945 // Remove from its parent by default
946 if ( el
.parentNode
) {
947 el
.parentNode
.removeChild( el
);
950 // release memory in IE
956 * Adds the same handler for all of the specified attrs
957 * @param {String} attrs Pipe-separated list of attributes
958 * @param {Function} handler The method that will be applied
960 function addHandle( attrs
, handler
) {
961 var arr
= attrs
.split( "|" ),
965 Expr
.attrHandle
[ arr
[ i
] ] = handler
;
970 * Checks document order of two siblings
973 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
975 function siblingCheck( a
, b
) {
977 diff
= cur
&& a
.nodeType
=== 1 && b
.nodeType
=== 1 &&
978 a
.sourceIndex
- b
.sourceIndex
;
980 // Use IE sourceIndex if available on both nodes
985 // Check if b follows a
987 while ( ( cur
= cur
.nextSibling
) ) {
998 * Returns a function to use in pseudos for input types
999 * @param {String} type
1001 function createInputPseudo( type
) {
1002 return function( elem
) {
1003 var name
= elem
.nodeName
.toLowerCase();
1004 return name
=== "input" && elem
.type
=== type
;
1009 * Returns a function to use in pseudos for buttons
1010 * @param {String} type
1012 function createButtonPseudo( type
) {
1013 return function( elem
) {
1014 var name
= elem
.nodeName
.toLowerCase();
1015 return ( name
=== "input" || name
=== "button" ) && elem
.type
=== type
;
1020 * Returns a function to use in pseudos for :enabled/:disabled
1021 * @param {Boolean} disabled true for :disabled; false for :enabled
1023 function createDisabledPseudo( disabled
) {
1025 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
1026 return function( elem
) {
1028 // Only certain elements can match :enabled or :disabled
1029 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
1030 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
1031 if ( "form" in elem
) {
1033 // Check for inherited disabledness on relevant non-disabled elements:
1034 // * listed form-associated elements in a disabled fieldset
1035 // https://html.spec.whatwg.org/multipage/forms.html#category-listed
1036 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
1037 // * option elements in a disabled optgroup
1038 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
1039 // All such elements have a "form" property.
1040 if ( elem
.parentNode
&& elem
.disabled
=== false ) {
1042 // Option elements defer to a parent optgroup if present
1043 if ( "label" in elem
) {
1044 if ( "label" in elem
.parentNode
) {
1045 return elem
.parentNode
.disabled
=== disabled
;
1047 return elem
.disabled
=== disabled
;
1051 // Support: IE 6 - 11
1052 // Use the isDisabled shortcut property to check for disabled fieldset ancestors
1053 return elem
.isDisabled
=== disabled
||
1055 // Where there is no isDisabled, check manually
1057 elem
.isDisabled
!== !disabled
&&
1058 inDisabledFieldset( elem
) === disabled
;
1061 return elem
.disabled
=== disabled
;
1063 // Try to winnow out elements that can't be disabled before trusting the disabled property.
1064 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
1065 // even exist on them, let alone have a boolean value.
1066 } else if ( "label" in elem
) {
1067 return elem
.disabled
=== disabled
;
1070 // Remaining elements are neither :enabled nor :disabled
1076 * Returns a function to use in pseudos for positionals
1077 * @param {Function} fn
1079 function createPositionalPseudo( fn
) {
1080 return markFunction( function( argument
) {
1081 argument
= +argument
;
1082 return markFunction( function( seed
, matches
) {
1084 matchIndexes
= fn( [], seed
.length
, argument
),
1085 i
= matchIndexes
.length
;
1087 // Match elements found at the specified indexes
1089 if ( seed
[ ( j
= matchIndexes
[ i
] ) ] ) {
1090 seed
[ j
] = !( matches
[ j
] = seed
[ j
] );
1098 * Checks a node for validity as a Sizzle context
1099 * @param {Element|Object=} context
1100 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1102 function testContext( context
) {
1103 return context
&& typeof context
.getElementsByTagName
!== "undefined" && context
;
1106 // Expose support vars for convenience
1107 support
= Sizzle
.support
= {};
1111 * @param {Element|Object} elem An element or a document
1112 * @returns {Boolean} True iff elem is a non-HTML XML node
1114 isXML
= Sizzle
.isXML = function( elem
) {
1115 var namespace = elem
&& elem
.namespaceURI
,
1116 docElem
= elem
&& ( elem
.ownerDocument
|| elem
).documentElement
;
1119 // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
1120 // https://bugs.jquery.com/ticket/4833
1121 return !rhtml
.test( namespace || docElem
&& docElem
.nodeName
|| "HTML" );
1125 * Sets document-related variables once based on the current document
1126 * @param {Element|Object} [doc] An element or document object to use to set the document
1127 * @returns {Object} Returns the current document
1129 setDocument
= Sizzle
.setDocument = function( node
) {
1130 var hasCompare
, subWindow
,
1131 doc
= node
? node
.ownerDocument
|| node : preferredDoc
;
1133 // Return early if doc is invalid or already selected
1134 // Support: IE 11+, Edge 17 - 18+
1135 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1136 // two documents; shallow comparisons work.
1137 // eslint-disable-next-line eqeqeq
1138 if ( doc
== document
|| doc
.nodeType
!== 9 || !doc
.documentElement
) {
1142 // Update global variables
1144 docElem
= document
.documentElement
;
1145 documentIsHTML
= !isXML( document
);
1147 // Support: IE 9 - 11+, Edge 12 - 18+
1148 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
1149 // Support: IE 11+, Edge 17 - 18+
1150 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1151 // two documents; shallow comparisons work.
1152 // eslint-disable-next-line eqeqeq
1153 if ( preferredDoc
!= document
&&
1154 ( subWindow
= document
.defaultView
) && subWindow
.top
!== subWindow
) {
1156 // Support: IE 11, Edge
1157 if ( subWindow
.addEventListener
) {
1158 subWindow
.addEventListener( "unload", unloadHandler
, false );
1160 // Support: IE 9 - 10 only
1161 } else if ( subWindow
.attachEvent
) {
1162 subWindow
.attachEvent( "onunload", unloadHandler
);
1166 // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only,
1167 // Safari 4 - 5 only, Opera <=11.6 - 12.x only
1168 // IE/Edge & older browsers don't support the :scope pseudo-class.
1169 // Support: Safari 6.0 only
1170 // Safari 6.0 supports :scope but it's an alias of :root there.
1171 support
.scope
= assert( function( el
) {
1172 docElem
.appendChild( el
).appendChild( document
.createElement( "div" ) );
1173 return typeof el
.querySelectorAll
!== "undefined" &&
1174 !el
.querySelectorAll( ":scope fieldset div" ).length
;
1178 ---------------------------------------------------------------------- */
1181 // Verify that getAttribute really returns attributes and not properties
1182 // (excepting IE8 booleans)
1183 support
.attributes
= assert( function( el
) {
1185 return !el
.getAttribute( "className" );
1189 ---------------------------------------------------------------------- */
1191 // Check if getElementsByTagName("*") returns only elements
1192 support
.getElementsByTagName
= assert( function( el
) {
1193 el
.appendChild( document
.createComment( "" ) );
1194 return !el
.getElementsByTagName( "*" ).length
;
1198 support
.getElementsByClassName
= rnative
.test( document
.getElementsByClassName
);
1201 // Check if getElementById returns elements by name
1202 // The broken getElementById methods don't pick up programmatically-set names,
1203 // so use a roundabout getElementsByName test
1204 support
.getById
= assert( function( el
) {
1205 docElem
.appendChild( el
).id
= expando
;
1206 return !document
.getElementsByName
|| !document
.getElementsByName( expando
).length
;
1209 // ID filter and find
1210 if ( support
.getById
) {
1211 Expr
.filter
[ "ID" ] = function( id
) {
1212 var attrId
= id
.replace( runescape
, funescape
);
1213 return function( elem
) {
1214 return elem
.getAttribute( "id" ) === attrId
;
1217 Expr
.find
[ "ID" ] = function( id
, context
) {
1218 if ( typeof context
.getElementById
!== "undefined" && documentIsHTML
) {
1219 var elem
= context
.getElementById( id
);
1220 return elem
? [ elem
] : [];
1224 Expr
.filter
[ "ID" ] = function( id
) {
1225 var attrId
= id
.replace( runescape
, funescape
);
1226 return function( elem
) {
1227 var node
= typeof elem
.getAttributeNode
!== "undefined" &&
1228 elem
.getAttributeNode( "id" );
1229 return node
&& node
.value
=== attrId
;
1233 // Support: IE 6 - 7 only
1234 // getElementById is not reliable as a find shortcut
1235 Expr
.find
[ "ID" ] = function( id
, context
) {
1236 if ( typeof context
.getElementById
!== "undefined" && documentIsHTML
) {
1238 elem
= context
.getElementById( id
);
1242 // Verify the id attribute
1243 node
= elem
.getAttributeNode( "id" );
1244 if ( node
&& node
.value
=== id
) {
1248 // Fall back on getElementsByName
1249 elems
= context
.getElementsByName( id
);
1251 while ( ( elem
= elems
[ i
++ ] ) ) {
1252 node
= elem
.getAttributeNode( "id" );
1253 if ( node
&& node
.value
=== id
) {
1265 Expr
.find
[ "TAG" ] = support
.getElementsByTagName
?
1266 function( tag
, context
) {
1267 if ( typeof context
.getElementsByTagName
!== "undefined" ) {
1268 return context
.getElementsByTagName( tag
);
1270 // DocumentFragment nodes don't have gEBTN
1271 } else if ( support
.qsa
) {
1272 return context
.querySelectorAll( tag
);
1276 function( tag
, context
) {
1281 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1282 results
= context
.getElementsByTagName( tag
);
1284 // Filter out possible comments
1285 if ( tag
=== "*" ) {
1286 while ( ( elem
= results
[ i
++ ] ) ) {
1287 if ( elem
.nodeType
=== 1 ) {
1298 Expr
.find
[ "CLASS" ] = support
.getElementsByClassName
&& function( className
, context
) {
1299 if ( typeof context
.getElementsByClassName
!== "undefined" && documentIsHTML
) {
1300 return context
.getElementsByClassName( className
);
1304 /* QSA/matchesSelector
1305 ---------------------------------------------------------------------- */
1307 // QSA and matchesSelector support
1309 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1312 // qSa(:focus) reports false when true (Chrome 21)
1313 // We allow this because of a bug in IE8/9 that throws an error
1314 // whenever `document.activeElement` is accessed on an iframe
1315 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1316 // See https://bugs.jquery.com/ticket/13378
1319 if ( ( support
.qsa
= rnative
.test( document
.querySelectorAll
) ) ) {
1322 // Regex strategy adopted from Diego Perini
1323 assert( function( el
) {
1327 // Select is set to empty string on purpose
1328 // This is to test IE's treatment of not explicitly
1329 // setting a boolean content attribute,
1330 // since its presence should be enough
1331 // https://bugs.jquery.com/ticket/12359
1332 docElem
.appendChild( el
).innerHTML
= "<a id='" + expando
+ "'></a>" +
1333 "<select id='" + expando
+ "-\r\\' msallowcapture=''>" +
1334 "<option selected=''></option></select>";
1336 // Support: IE8, Opera 11-12.16
1337 // Nothing should be selected when empty strings follow ^= or $= or *=
1338 // The test attribute must be unknown in Opera but "safe" for WinRT
1339 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1340 if ( el
.querySelectorAll( "[msallowcapture^='']" ).length
) {
1341 rbuggyQSA
.push( "[*^$]=" + whitespace
+ "*(?:''|\"\")" );
1345 // Boolean attributes and "value" are not treated correctly
1346 if ( !el
.querySelectorAll( "[selected]" ).length
) {
1347 rbuggyQSA
.push( "\\[" + whitespace
+ "*(?:value|" + booleans
+ ")" );
1350 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
1351 if ( !el
.querySelectorAll( "[id~=" + expando
+ "-]" ).length
) {
1352 rbuggyQSA
.push( "~=" );
1355 // Support: IE 11+, Edge 15 - 18+
1356 // IE 11/Edge don't find elements on a `[name='']` query in some cases.
1357 // Adding a temporary attribute to the document before the selection works
1358 // around the issue.
1359 // Interestingly, IE 10 & older don't seem to have the issue.
1360 input
= document
.createElement( "input" );
1361 input
.setAttribute( "name", "" );
1362 el
.appendChild( input
);
1363 if ( !el
.querySelectorAll( "[name='']" ).length
) {
1364 rbuggyQSA
.push( "\\[" + whitespace
+ "*name" + whitespace
+ "*=" +
1365 whitespace
+ "*(?:''|\"\")" );
1368 // Webkit/Opera - :checked should return selected option elements
1369 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1370 // IE8 throws error here and will not see later tests
1371 if ( !el
.querySelectorAll( ":checked" ).length
) {
1372 rbuggyQSA
.push( ":checked" );
1375 // Support: Safari 8+, iOS 8+
1376 // https://bugs.webkit.org/show_bug.cgi?id=136851
1377 // In-page `selector#id sibling-combinator selector` fails
1378 if ( !el
.querySelectorAll( "a#" + expando
+ "+*" ).length
) {
1379 rbuggyQSA
.push( ".#.+[+~]" );
1382 // Support: Firefox <=3.6 - 5 only
1383 // Old Firefox doesn't throw on a badly-escaped identifier.
1384 el
.querySelectorAll( "\\\f" );
1385 rbuggyQSA
.push( "[\\r\\n\\f]" );
1388 assert( function( el
) {
1389 el
.innerHTML
= "<a href='' disabled='disabled'></a>" +
1390 "<select disabled='disabled'><option/></select>";
1392 // Support: Windows 8 Native Apps
1393 // The type and name attributes are restricted during .innerHTML assignment
1394 var input
= document
.createElement( "input" );
1395 input
.setAttribute( "type", "hidden" );
1396 el
.appendChild( input
).setAttribute( "name", "D" );
1399 // Enforce case-sensitivity of name attribute
1400 if ( el
.querySelectorAll( "[name=d]" ).length
) {
1401 rbuggyQSA
.push( "name" + whitespace
+ "*[*^$|!~]?=" );
1404 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1405 // IE8 throws error here and will not see later tests
1406 if ( el
.querySelectorAll( ":enabled" ).length
!== 2 ) {
1407 rbuggyQSA
.push( ":enabled", ":disabled" );
1411 // IE's :disabled selector does not pick up the children of disabled fieldsets
1412 docElem
.appendChild( el
).disabled
= true;
1413 if ( el
.querySelectorAll( ":disabled" ).length
!== 2 ) {
1414 rbuggyQSA
.push( ":enabled", ":disabled" );
1417 // Support: Opera 10 - 11 only
1418 // Opera 10-11 does not throw on post-comma invalid pseudos
1419 el
.querySelectorAll( "*,:x" );
1420 rbuggyQSA
.push( ",.*:" );
1424 if ( ( support
.matchesSelector
= rnative
.test( ( matches
= docElem
.matches
||
1425 docElem
.webkitMatchesSelector
||
1426 docElem
.mozMatchesSelector
||
1427 docElem
.oMatchesSelector
||
1428 docElem
.msMatchesSelector
) ) ) ) {
1430 assert( function( el
) {
1432 // Check to see if it's possible to do matchesSelector
1433 // on a disconnected node (IE 9)
1434 support
.disconnectedMatch
= matches
.call( el
, "*" );
1436 // This should fail with an exception
1437 // Gecko does not error, returns false instead
1438 matches
.call( el
, "[s!='']:x" );
1439 rbuggyMatches
.push( "!=", pseudos
);
1443 rbuggyQSA
= rbuggyQSA
.length
&& new RegExp( rbuggyQSA
.join( "|" ) );
1444 rbuggyMatches
= rbuggyMatches
.length
&& new RegExp( rbuggyMatches
.join( "|" ) );
1447 ---------------------------------------------------------------------- */
1448 hasCompare
= rnative
.test( docElem
.compareDocumentPosition
);
1450 // Element contains another
1451 // Purposefully self-exclusive
1452 // As in, an element does not contain itself
1453 contains
= hasCompare
|| rnative
.test( docElem
.contains
) ?
1455 var adown
= a
.nodeType
=== 9 ? a
.documentElement : a
,
1456 bup
= b
&& b
.parentNode
;
1457 return a
=== bup
|| !!( bup
&& bup
.nodeType
=== 1 && (
1459 adown
.contains( bup
) :
1460 a
.compareDocumentPosition
&& a
.compareDocumentPosition( bup
) & 16
1465 while ( ( b
= b
.parentNode
) ) {
1475 ---------------------------------------------------------------------- */
1477 // Document order sorting
1478 sortOrder
= hasCompare
?
1481 // Flag for duplicate removal
1483 hasDuplicate
= true;
1487 // Sort on method existence if only one input has compareDocumentPosition
1488 var compare
= !a
.compareDocumentPosition
- !b
.compareDocumentPosition
;
1493 // Calculate position if both inputs belong to the same document
1494 // Support: IE 11+, Edge 17 - 18+
1495 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1496 // two documents; shallow comparisons work.
1497 // eslint-disable-next-line eqeqeq
1498 compare
= ( a
.ownerDocument
|| a
) == ( b
.ownerDocument
|| b
) ?
1499 a
.compareDocumentPosition( b
) :
1501 // Otherwise we know they are disconnected
1504 // Disconnected nodes
1506 ( !support
.sortDetached
&& b
.compareDocumentPosition( a
) === compare
) ) {
1508 // Choose the first element that is related to our preferred document
1509 // Support: IE 11+, Edge 17 - 18+
1510 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1511 // two documents; shallow comparisons work.
1512 // eslint-disable-next-line eqeqeq
1513 if ( a
== document
|| a
.ownerDocument
== preferredDoc
&&
1514 contains( preferredDoc
, a
) ) {
1518 // Support: IE 11+, Edge 17 - 18+
1519 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1520 // two documents; shallow comparisons work.
1521 // eslint-disable-next-line eqeqeq
1522 if ( b
== document
|| b
.ownerDocument
== preferredDoc
&&
1523 contains( preferredDoc
, b
) ) {
1527 // Maintain original order
1529 ( indexOf( sortInput
, a
) - indexOf( sortInput
, b
) ) :
1533 return compare
& 4 ? -1 : 1;
1537 // Exit early if the nodes are identical
1539 hasDuplicate
= true;
1550 // Parentless nodes are either documents or disconnected
1551 if ( !aup
|| !bup
) {
1553 // Support: IE 11+, Edge 17 - 18+
1554 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1555 // two documents; shallow comparisons work.
1556 /* eslint-disable eqeqeq */
1557 return a
== document
? -1 :
1559 /* eslint-enable eqeqeq */
1563 ( indexOf( sortInput
, a
) - indexOf( sortInput
, b
) ) :
1566 // If the nodes are siblings, we can do a quick check
1567 } else if ( aup
=== bup
) {
1568 return siblingCheck( a
, b
);
1571 // Otherwise we need full lists of their ancestors for comparison
1573 while ( ( cur
= cur
.parentNode
) ) {
1577 while ( ( cur
= cur
.parentNode
) ) {
1581 // Walk down the tree looking for a discrepancy
1582 while ( ap
[ i
] === bp
[ i
] ) {
1588 // Do a sibling check if the nodes have a common ancestor
1589 siblingCheck( ap
[ i
], bp
[ i
] ) :
1591 // Otherwise nodes in our document sort first
1592 // Support: IE 11+, Edge 17 - 18+
1593 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1594 // two documents; shallow comparisons work.
1595 /* eslint-disable eqeqeq */
1596 ap
[ i
] == preferredDoc
? -1 :
1597 bp
[ i
] == preferredDoc
? 1 :
1598 /* eslint-enable eqeqeq */
1605 Sizzle
.matches = function( expr
, elements
) {
1606 return Sizzle( expr
, null, null, elements
);
1609 Sizzle
.matchesSelector = function( elem
, expr
) {
1610 setDocument( elem
);
1612 if ( support
.matchesSelector
&& documentIsHTML
&&
1613 !nonnativeSelectorCache
[ expr
+ " " ] &&
1614 ( !rbuggyMatches
|| !rbuggyMatches
.test( expr
) ) &&
1615 ( !rbuggyQSA
|| !rbuggyQSA
.test( expr
) ) ) {
1618 var ret
= matches
.call( elem
, expr
);
1620 // IE 9's matchesSelector returns false on disconnected nodes
1621 if ( ret
|| support
.disconnectedMatch
||
1623 // As well, disconnected nodes are said to be in a document
1625 elem
.document
&& elem
.document
.nodeType
!== 11 ) {
1629 nonnativeSelectorCache( expr
, true );
1633 return Sizzle( expr
, document
, null, [ elem
] ).length
> 0;
1636 Sizzle
.contains = function( context
, elem
) {
1638 // Set document vars if needed
1639 // Support: IE 11+, Edge 17 - 18+
1640 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1641 // two documents; shallow comparisons work.
1642 // eslint-disable-next-line eqeqeq
1643 if ( ( context
.ownerDocument
|| context
) != document
) {
1644 setDocument( context
);
1646 return contains( context
, elem
);
1649 Sizzle
.attr = function( elem
, name
) {
1651 // Set document vars if needed
1652 // Support: IE 11+, Edge 17 - 18+
1653 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1654 // two documents; shallow comparisons work.
1655 // eslint-disable-next-line eqeqeq
1656 if ( ( elem
.ownerDocument
|| elem
) != document
) {
1657 setDocument( elem
);
1660 var fn
= Expr
.attrHandle
[ name
.toLowerCase() ],
1662 // Don't get fooled by Object.prototype properties (jQuery #13807)
1663 val
= fn
&& hasOwn
.call( Expr
.attrHandle
, name
.toLowerCase() ) ?
1664 fn( elem
, name
, !documentIsHTML
) :
1667 return val
!== undefined ?
1669 support
.attributes
|| !documentIsHTML
?
1670 elem
.getAttribute( name
) :
1671 ( val
= elem
.getAttributeNode( name
) ) && val
.specified
?
1676 Sizzle
.escape = function( sel
) {
1677 return ( sel
+ "" ).replace( rcssescape
, fcssescape
);
1680 Sizzle
.error = function( msg
) {
1681 throw new Error( "Syntax error, unrecognized expression: " + msg
);
1685 * Document sorting and removing duplicates
1686 * @param {ArrayLike} results
1688 Sizzle
.uniqueSort = function( results
) {
1694 // Unless we *know* we can detect duplicates, assume their presence
1695 hasDuplicate
= !support
.detectDuplicates
;
1696 sortInput
= !support
.sortStable
&& results
.slice( 0 );
1697 results
.sort( sortOrder
);
1699 if ( hasDuplicate
) {
1700 while ( ( elem
= results
[ i
++ ] ) ) {
1701 if ( elem
=== results
[ i
] ) {
1702 j
= duplicates
.push( i
);
1706 results
.splice( duplicates
[ j
], 1 );
1710 // Clear input after sorting to release objects
1711 // See https://github.com/jquery/sizzle/pull/225
1718 * Utility function for retrieving the text value of an array of DOM nodes
1719 * @param {Array|Element} elem
1721 getText
= Sizzle
.getText = function( elem
) {
1725 nodeType
= elem
.nodeType
;
1729 // If no nodeType, this is expected to be an array
1730 while ( ( node
= elem
[ i
++ ] ) ) {
1732 // Do not traverse comment nodes
1733 ret
+= getText( node
);
1735 } else if ( nodeType
=== 1 || nodeType
=== 9 || nodeType
=== 11 ) {
1737 // Use textContent for elements
1738 // innerText usage removed for consistency of new lines (jQuery #11153)
1739 if ( typeof elem
.textContent
=== "string" ) {
1740 return elem
.textContent
;
1743 // Traverse its children
1744 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
1745 ret
+= getText( elem
);
1748 } else if ( nodeType
=== 3 || nodeType
=== 4 ) {
1749 return elem
.nodeValue
;
1752 // Do not include comment or processing instruction nodes
1757 Expr
= Sizzle
.selectors
= {
1759 // Can be adjusted by the user
1762 createPseudo: markFunction
,
1771 ">": { dir: "parentNode", first: true },
1772 " ": { dir: "parentNode" },
1773 "+": { dir: "previousSibling", first: true },
1774 "~": { dir: "previousSibling" }
1778 "ATTR": function( match
) {
1779 match
[ 1 ] = match
[ 1 ].replace( runescape
, funescape
);
1781 // Move the given value to match[3] whether quoted or unquoted
1782 match
[ 3 ] = ( match
[ 3 ] || match
[ 4 ] ||
1783 match
[ 5 ] || "" ).replace( runescape
, funescape
);
1785 if ( match
[ 2 ] === "~=" ) {
1786 match
[ 3 ] = " " + match
[ 3 ] + " ";
1789 return match
.slice( 0, 4 );
1792 "CHILD": function( match
) {
1794 /* matches from matchExpr["CHILD"]
1795 1 type (only|nth|...)
1796 2 what (child|of-type)
1797 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1798 4 xn-component of xn+y argument ([+-]?\d*n|)
1799 5 sign of xn-component
1801 7 sign of y-component
1804 match
[ 1 ] = match
[ 1 ].toLowerCase();
1806 if ( match
[ 1 ].slice( 0, 3 ) === "nth" ) {
1808 // nth-* requires argument
1809 if ( !match
[ 3 ] ) {
1810 Sizzle
.error( match
[ 0 ] );
1813 // numeric x and y parameters for Expr.filter.CHILD
1814 // remember that false/true cast respectively to 0/1
1815 match
[ 4 ] = +( match
[ 4 ] ?
1816 match
[ 5 ] + ( match
[ 6 ] || 1 ) :
1817 2 * ( match
[ 3 ] === "even" || match
[ 3 ] === "odd" ) );
1818 match
[ 5 ] = +( ( match
[ 7 ] + match
[ 8 ] ) || match
[ 3 ] === "odd" );
1820 // other types prohibit arguments
1821 } else if ( match
[ 3 ] ) {
1822 Sizzle
.error( match
[ 0 ] );
1828 "PSEUDO": function( match
) {
1830 unquoted
= !match
[ 6 ] && match
[ 2 ];
1832 if ( matchExpr
[ "CHILD" ].test( match
[ 0 ] ) ) {
1836 // Accept quoted arguments as-is
1838 match
[ 2 ] = match
[ 4 ] || match
[ 5 ] || "";
1840 // Strip excess characters from unquoted arguments
1841 } else if ( unquoted
&& rpseudo
.test( unquoted
) &&
1843 // Get excess from tokenize (recursively)
1844 ( excess
= tokenize( unquoted
, true ) ) &&
1846 // advance to the next closing parenthesis
1847 ( excess
= unquoted
.indexOf( ")", unquoted
.length
- excess
) - unquoted
.length
) ) {
1849 // excess is a negative index
1850 match
[ 0 ] = match
[ 0 ].slice( 0, excess
);
1851 match
[ 2 ] = unquoted
.slice( 0, excess
);
1854 // Return only captures needed by the pseudo filter method (type and argument)
1855 return match
.slice( 0, 3 );
1861 "TAG": function( nodeNameSelector
) {
1862 var nodeName
= nodeNameSelector
.replace( runescape
, funescape
).toLowerCase();
1863 return nodeNameSelector
=== "*" ?
1868 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === nodeName
;
1872 "CLASS": function( className
) {
1873 var pattern
= classCache
[ className
+ " " ];
1876 ( pattern
= new RegExp( "(^|" + whitespace
+
1877 ")" + className
+ "(" + whitespace
+ "|$)" ) ) && classCache(
1878 className
, function( elem
) {
1879 return pattern
.test(
1880 typeof elem
.className
=== "string" && elem
.className
||
1881 typeof elem
.getAttribute
!== "undefined" &&
1882 elem
.getAttribute( "class" ) ||
1888 "ATTR": function( name
, operator
, check
) {
1889 return function( elem
) {
1890 var result
= Sizzle
.attr( elem
, name
);
1892 if ( result
== null ) {
1893 return operator
=== "!=";
1901 /* eslint-disable max-len */
1903 return operator
=== "=" ? result
=== check :
1904 operator
=== "!=" ? result
!== check :
1905 operator
=== "^=" ? check
&& result
.indexOf( check
) === 0 :
1906 operator
=== "*=" ? check
&& result
.indexOf( check
) > -1 :
1907 operator
=== "$=" ? check
&& result
.slice( -check
.length
) === check :
1908 operator
=== "~=" ? ( " " + result
.replace( rwhitespace
, " " ) + " " ).indexOf( check
) > -1 :
1909 operator
=== "|=" ? result
=== check
|| result
.slice( 0, check
.length
+ 1 ) === check
+ "-" :
1911 /* eslint-enable max-len */
1916 "CHILD": function( type
, what
, _argument
, first
, last
) {
1917 var simple
= type
.slice( 0, 3 ) !== "nth",
1918 forward
= type
.slice( -4 ) !== "last",
1919 ofType
= what
=== "of-type";
1921 return first
=== 1 && last
=== 0 ?
1923 // Shortcut for :nth-*(n)
1925 return !!elem
.parentNode
;
1928 function( elem
, _context
, xml
) {
1929 var cache
, uniqueCache
, outerCache
, node
, nodeIndex
, start
,
1930 dir
= simple
!== forward
? "nextSibling" : "previousSibling",
1931 parent
= elem
.parentNode
,
1932 name
= ofType
&& elem
.nodeName
.toLowerCase(),
1933 useCache
= !xml
&& !ofType
,
1938 // :(first|last|only)-(child|of-type)
1942 while ( ( node
= node
[ dir
] ) ) {
1944 node
.nodeName
.toLowerCase() === name :
1945 node
.nodeType
=== 1 ) {
1951 // Reverse direction for :only-* (if we haven't yet done so)
1952 start
= dir
= type
=== "only" && !start
&& "nextSibling";
1957 start
= [ forward
? parent
.firstChild : parent
.lastChild
];
1959 // non-xml :nth-child(...) stores cache data on `parent`
1960 if ( forward
&& useCache
) {
1962 // Seek `elem` from a previously-cached index
1964 // ...in a gzip-friendly way
1966 outerCache
= node
[ expando
] || ( node
[ expando
] = {} );
1968 // Support: IE <9 only
1969 // Defend against cloned attroperties (jQuery gh-1709)
1970 uniqueCache
= outerCache
[ node
.uniqueID
] ||
1971 ( outerCache
[ node
.uniqueID
] = {} );
1973 cache
= uniqueCache
[ type
] || [];
1974 nodeIndex
= cache
[ 0 ] === dirruns
&& cache
[ 1 ];
1975 diff
= nodeIndex
&& cache
[ 2 ];
1976 node
= nodeIndex
&& parent
.childNodes
[ nodeIndex
];
1978 while ( ( node
= ++nodeIndex
&& node
&& node
[ dir
] ||
1980 // Fallback to seeking `elem` from the start
1981 ( diff
= nodeIndex
= 0 ) || start
.pop() ) ) {
1983 // When found, cache indexes on `parent` and break
1984 if ( node
.nodeType
=== 1 && ++diff
&& node
=== elem
) {
1985 uniqueCache
[ type
] = [ dirruns
, nodeIndex
, diff
];
1992 // Use previously-cached element index if available
1995 // ...in a gzip-friendly way
1997 outerCache
= node
[ expando
] || ( node
[ expando
] = {} );
1999 // Support: IE <9 only
2000 // Defend against cloned attroperties (jQuery gh-1709)
2001 uniqueCache
= outerCache
[ node
.uniqueID
] ||
2002 ( outerCache
[ node
.uniqueID
] = {} );
2004 cache
= uniqueCache
[ type
] || [];
2005 nodeIndex
= cache
[ 0 ] === dirruns
&& cache
[ 1 ];
2009 // xml :nth-child(...)
2010 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
2011 if ( diff
=== false ) {
2013 // Use the same loop as above to seek `elem` from the start
2014 while ( ( node
= ++nodeIndex
&& node
&& node
[ dir
] ||
2015 ( diff
= nodeIndex
= 0 ) || start
.pop() ) ) {
2018 node
.nodeName
.toLowerCase() === name :
2019 node
.nodeType
=== 1 ) &&
2022 // Cache the index of each encountered element
2024 outerCache
= node
[ expando
] ||
2025 ( node
[ expando
] = {} );
2027 // Support: IE <9 only
2028 // Defend against cloned attroperties (jQuery gh-1709)
2029 uniqueCache
= outerCache
[ node
.uniqueID
] ||
2030 ( outerCache
[ node
.uniqueID
] = {} );
2032 uniqueCache
[ type
] = [ dirruns
, diff
];
2035 if ( node
=== elem
) {
2043 // Incorporate the offset, then check against cycle size
2045 return diff
=== first
|| ( diff
% first
=== 0 && diff
/ first
>= 0 );
2050 "PSEUDO": function( pseudo
, argument
) {
2052 // pseudo-class names are case-insensitive
2053 // http://www.w3.org/TR/selectors/#pseudo-classes
2054 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
2055 // Remember that setFilters inherits from pseudos
2057 fn
= Expr
.pseudos
[ pseudo
] || Expr
.setFilters
[ pseudo
.toLowerCase() ] ||
2058 Sizzle
.error( "unsupported pseudo: " + pseudo
);
2060 // The user may use createPseudo to indicate that
2061 // arguments are needed to create the filter function
2062 // just as Sizzle does
2063 if ( fn
[ expando
] ) {
2064 return fn( argument
);
2067 // But maintain support for old signatures
2068 if ( fn
.length
> 1 ) {
2069 args
= [ pseudo
, pseudo
, "", argument
];
2070 return Expr
.setFilters
.hasOwnProperty( pseudo
.toLowerCase() ) ?
2071 markFunction( function( seed
, matches
) {
2073 matched
= fn( seed
, argument
),
2076 idx
= indexOf( seed
, matched
[ i
] );
2077 seed
[ idx
] = !( matches
[ idx
] = matched
[ i
] );
2081 return fn( elem
, 0, args
);
2091 // Potentially complex pseudos
2092 "not": markFunction( function( selector
) {
2094 // Trim the selector passed to compile
2095 // to avoid treating leading and trailing
2096 // spaces as combinators
2099 matcher
= compile( selector
.replace( rtrim
, "$1" ) );
2101 return matcher
[ expando
] ?
2102 markFunction( function( seed
, matches
, _context
, xml
) {
2104 unmatched
= matcher( seed
, null, xml
, [] ),
2107 // Match elements unmatched by `matcher`
2109 if ( ( elem
= unmatched
[ i
] ) ) {
2110 seed
[ i
] = !( matches
[ i
] = elem
);
2114 function( elem
, _context
, xml
) {
2116 matcher( input
, null, xml
, results
);
2118 // Don't keep the element (issue #299)
2120 return !results
.pop();
2124 "has": markFunction( function( selector
) {
2125 return function( elem
) {
2126 return Sizzle( selector
, elem
).length
> 0;
2130 "contains": markFunction( function( text
) {
2131 text
= text
.replace( runescape
, funescape
);
2132 return function( elem
) {
2133 return ( elem
.textContent
|| getText( elem
) ).indexOf( text
) > -1;
2137 // "Whether an element is represented by a :lang() selector
2138 // is based solely on the element's language value
2139 // being equal to the identifier C,
2140 // or beginning with the identifier C immediately followed by "-".
2141 // The matching of C against the element's language value is performed case-insensitively.
2142 // The identifier C does not have to be a valid language name."
2143 // http://www.w3.org/TR/selectors/#lang-pseudo
2144 "lang": markFunction( function( lang
) {
2146 // lang value must be a valid identifier
2147 if ( !ridentifier
.test( lang
|| "" ) ) {
2148 Sizzle
.error( "unsupported lang: " + lang
);
2150 lang
= lang
.replace( runescape
, funescape
).toLowerCase();
2151 return function( elem
) {
2154 if ( ( elemLang
= documentIsHTML
?
2156 elem
.getAttribute( "xml:lang" ) || elem
.getAttribute( "lang" ) ) ) {
2158 elemLang
= elemLang
.toLowerCase();
2159 return elemLang
=== lang
|| elemLang
.indexOf( lang
+ "-" ) === 0;
2161 } while ( ( elem
= elem
.parentNode
) && elem
.nodeType
=== 1 );
2167 "target": function( elem
) {
2168 var hash
= window
.location
&& window
.location
.hash
;
2169 return hash
&& hash
.slice( 1 ) === elem
.id
;
2172 "root": function( elem
) {
2173 return elem
=== docElem
;
2176 "focus": function( elem
) {
2177 return elem
=== document
.activeElement
&&
2178 ( !document
.hasFocus
|| document
.hasFocus() ) &&
2179 !!( elem
.type
|| elem
.href
|| ~elem
.tabIndex
);
2182 // Boolean properties
2183 "enabled": createDisabledPseudo( false ),
2184 "disabled": createDisabledPseudo( true ),
2186 "checked": function( elem
) {
2188 // In CSS3, :checked should return both checked and selected elements
2189 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
2190 var nodeName
= elem
.nodeName
.toLowerCase();
2191 return ( nodeName
=== "input" && !!elem
.checked
) ||
2192 ( nodeName
=== "option" && !!elem
.selected
);
2195 "selected": function( elem
) {
2197 // Accessing this property makes selected-by-default
2198 // options in Safari work properly
2199 if ( elem
.parentNode
) {
2200 // eslint-disable-next-line no-unused-expressions
2201 elem
.parentNode
.selectedIndex
;
2204 return elem
.selected
=== true;
2208 "empty": function( elem
) {
2210 // http://www.w3.org/TR/selectors/#empty-pseudo
2211 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
2212 // but not by others (comment: 8; processing instruction: 7; etc.)
2213 // nodeType < 6 works because attributes (2) do not appear as children
2214 for ( elem
= elem
.firstChild
; elem
; elem
= elem
.nextSibling
) {
2215 if ( elem
.nodeType
< 6 ) {
2222 "parent": function( elem
) {
2223 return !Expr
.pseudos
[ "empty" ]( elem
);
2226 // Element/input types
2227 "header": function( elem
) {
2228 return rheader
.test( elem
.nodeName
);
2231 "input": function( elem
) {
2232 return rinputs
.test( elem
.nodeName
);
2235 "button": function( elem
) {
2236 var name
= elem
.nodeName
.toLowerCase();
2237 return name
=== "input" && elem
.type
=== "button" || name
=== "button";
2240 "text": function( elem
) {
2242 return elem
.nodeName
.toLowerCase() === "input" &&
2243 elem
.type
=== "text" &&
2246 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
2247 ( ( attr
= elem
.getAttribute( "type" ) ) == null ||
2248 attr
.toLowerCase() === "text" );
2251 // Position-in-collection
2252 "first": createPositionalPseudo( function() {
2256 "last": createPositionalPseudo( function( _matchIndexes
, length
) {
2257 return [ length
- 1 ];
2260 "eq": createPositionalPseudo( function( _matchIndexes
, length
, argument
) {
2261 return [ argument
< 0 ? argument
+ length : argument
];
2264 "even": createPositionalPseudo( function( matchIndexes
, length
) {
2266 for ( ; i
< length
; i
+= 2 ) {
2267 matchIndexes
.push( i
);
2269 return matchIndexes
;
2272 "odd": createPositionalPseudo( function( matchIndexes
, length
) {
2274 for ( ; i
< length
; i
+= 2 ) {
2275 matchIndexes
.push( i
);
2277 return matchIndexes
;
2280 "lt": createPositionalPseudo( function( matchIndexes
, length
, argument
) {
2281 var i
= argument
< 0 ?
2286 for ( ; --i
>= 0; ) {
2287 matchIndexes
.push( i
);
2289 return matchIndexes
;
2292 "gt": createPositionalPseudo( function( matchIndexes
, length
, argument
) {
2293 var i
= argument
< 0 ? argument
+ length : argument
;
2294 for ( ; ++i
< length
; ) {
2295 matchIndexes
.push( i
);
2297 return matchIndexes
;
2302 Expr
.pseudos
[ "nth" ] = Expr
.pseudos
[ "eq" ];
2304 // Add button/input type pseudos
2305 for ( i
in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2306 Expr
.pseudos
[ i
] = createInputPseudo( i
);
2308 for ( i
in { submit: true, reset: true } ) {
2309 Expr
.pseudos
[ i
] = createButtonPseudo( i
);
2312 // Easy API for creating new setFilters
2313 function setFilters() {}
2314 setFilters
.prototype = Expr
.filters
= Expr
.pseudos
;
2315 Expr
.setFilters
= new setFilters();
2317 tokenize
= Sizzle
.tokenize = function( selector
, parseOnly
) {
2318 var matched
, match
, tokens
, type
,
2319 soFar
, groups
, preFilters
,
2320 cached
= tokenCache
[ selector
+ " " ];
2323 return parseOnly
? 0 : cached
.slice( 0 );
2328 preFilters
= Expr
.preFilter
;
2332 // Comma and first run
2333 if ( !matched
|| ( match
= rcomma
.exec( soFar
) ) ) {
2336 // Don't consume trailing commas as valid
2337 soFar
= soFar
.slice( match
[ 0 ].length
) || soFar
;
2339 groups
.push( ( tokens
= [] ) );
2345 if ( ( match
= rcombinators
.exec( soFar
) ) ) {
2346 matched
= match
.shift();
2350 // Cast descendant combinators to space
2351 type: match
[ 0 ].replace( rtrim
, " " )
2353 soFar
= soFar
.slice( matched
.length
);
2357 for ( type
in Expr
.filter
) {
2358 if ( ( match
= matchExpr
[ type
].exec( soFar
) ) && ( !preFilters
[ type
] ||
2359 ( match
= preFilters
[ type
]( match
) ) ) ) {
2360 matched
= match
.shift();
2366 soFar
= soFar
.slice( matched
.length
);
2375 // Return the length of the invalid excess
2376 // if we're just parsing
2377 // Otherwise, throw an error or return tokens
2381 Sizzle
.error( selector
) :
2384 tokenCache( selector
, groups
).slice( 0 );
2387 function toSelector( tokens
) {
2389 len
= tokens
.length
,
2391 for ( ; i
< len
; i
++ ) {
2392 selector
+= tokens
[ i
].value
;
2397 function addCombinator( matcher
, combinator
, base
) {
2398 var dir
= combinator
.dir
,
2399 skip
= combinator
.next
,
2401 checkNonElements
= base
&& key
=== "parentNode",
2404 return combinator
.first
?
2406 // Check against closest ancestor/preceding element
2407 function( elem
, context
, xml
) {
2408 while ( ( elem
= elem
[ dir
] ) ) {
2409 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2410 return matcher( elem
, context
, xml
);
2416 // Check against all ancestor/preceding elements
2417 function( elem
, context
, xml
) {
2418 var oldCache
, uniqueCache
, outerCache
,
2419 newCache
= [ dirruns
, doneName
];
2421 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2423 while ( ( elem
= elem
[ dir
] ) ) {
2424 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2425 if ( matcher( elem
, context
, xml
) ) {
2431 while ( ( elem
= elem
[ dir
] ) ) {
2432 if ( elem
.nodeType
=== 1 || checkNonElements
) {
2433 outerCache
= elem
[ expando
] || ( elem
[ expando
] = {} );
2435 // Support: IE <9 only
2436 // Defend against cloned attroperties (jQuery gh-1709)
2437 uniqueCache
= outerCache
[ elem
.uniqueID
] ||
2438 ( outerCache
[ elem
.uniqueID
] = {} );
2440 if ( skip
&& skip
=== elem
.nodeName
.toLowerCase() ) {
2441 elem
= elem
[ dir
] || elem
;
2442 } else if ( ( oldCache
= uniqueCache
[ key
] ) &&
2443 oldCache
[ 0 ] === dirruns
&& oldCache
[ 1 ] === doneName
) {
2445 // Assign to newCache so results back-propagate to previous elements
2446 return ( newCache
[ 2 ] = oldCache
[ 2 ] );
2449 // Reuse newcache so results back-propagate to previous elements
2450 uniqueCache
[ key
] = newCache
;
2452 // A match means we're done; a fail means we have to keep checking
2453 if ( ( newCache
[ 2 ] = matcher( elem
, context
, xml
) ) ) {
2464 function elementMatcher( matchers
) {
2465 return matchers
.length
> 1 ?
2466 function( elem
, context
, xml
) {
2467 var i
= matchers
.length
;
2469 if ( !matchers
[ i
]( elem
, context
, xml
) ) {
2478 function multipleContexts( selector
, contexts
, results
) {
2480 len
= contexts
.length
;
2481 for ( ; i
< len
; i
++ ) {
2482 Sizzle( selector
, contexts
[ i
], results
);
2487 function condense( unmatched
, map
, filter
, context
, xml
) {
2491 len
= unmatched
.length
,
2492 mapped
= map
!= null;
2494 for ( ; i
< len
; i
++ ) {
2495 if ( ( elem
= unmatched
[ i
] ) ) {
2496 if ( !filter
|| filter( elem
, context
, xml
) ) {
2497 newUnmatched
.push( elem
);
2505 return newUnmatched
;
2508 function setMatcher( preFilter
, selector
, matcher
, postFilter
, postFinder
, postSelector
) {
2509 if ( postFilter
&& !postFilter
[ expando
] ) {
2510 postFilter
= setMatcher( postFilter
);
2512 if ( postFinder
&& !postFinder
[ expando
] ) {
2513 postFinder
= setMatcher( postFinder
, postSelector
);
2515 return markFunction( function( seed
, results
, context
, xml
) {
2519 preexisting
= results
.length
,
2521 // Get initial elements from seed or context
2522 elems
= seed
|| multipleContexts(
2524 context
.nodeType
? [ context
] : context
,
2528 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2529 matcherIn
= preFilter
&& ( seed
|| !selector
) ?
2530 condense( elems
, preMap
, preFilter
, context
, xml
) :
2533 matcherOut
= matcher
?
2535 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2536 postFinder
|| ( seed
? preFilter : preexisting
|| postFilter
) ?
2538 // ...intermediate processing is necessary
2541 // ...otherwise use results directly
2545 // Find primary matches
2547 matcher( matcherIn
, matcherOut
, context
, xml
);
2552 temp
= condense( matcherOut
, postMap
);
2553 postFilter( temp
, [], context
, xml
);
2555 // Un-match failing elements by moving them back to matcherIn
2558 if ( ( elem
= temp
[ i
] ) ) {
2559 matcherOut
[ postMap
[ i
] ] = !( matcherIn
[ postMap
[ i
] ] = elem
);
2565 if ( postFinder
|| preFilter
) {
2568 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2570 i
= matcherOut
.length
;
2572 if ( ( elem
= matcherOut
[ i
] ) ) {
2574 // Restore matcherIn since elem is not yet a final match
2575 temp
.push( ( matcherIn
[ i
] = elem
) );
2578 postFinder( null, ( matcherOut
= [] ), temp
, xml
);
2581 // Move matched elements from seed to results to keep them synchronized
2582 i
= matcherOut
.length
;
2584 if ( ( elem
= matcherOut
[ i
] ) &&
2585 ( temp
= postFinder
? indexOf( seed
, elem
) : preMap
[ i
] ) > -1 ) {
2587 seed
[ temp
] = !( results
[ temp
] = elem
);
2592 // Add elements to results, through postFinder if defined
2594 matcherOut
= condense(
2595 matcherOut
=== results
?
2596 matcherOut
.splice( preexisting
, matcherOut
.length
) :
2600 postFinder( null, results
, matcherOut
, xml
);
2602 push
.apply( results
, matcherOut
);
2608 function matcherFromTokens( tokens
) {
2609 var checkContext
, matcher
, j
,
2610 len
= tokens
.length
,
2611 leadingRelative
= Expr
.relative
[ tokens
[ 0 ].type
],
2612 implicitRelative
= leadingRelative
|| Expr
.relative
[ " " ],
2613 i
= leadingRelative
? 1 : 0,
2615 // The foundational matcher ensures that elements are reachable from top-level context(s)
2616 matchContext
= addCombinator( function( elem
) {
2617 return elem
=== checkContext
;
2618 }, implicitRelative
, true ),
2619 matchAnyContext
= addCombinator( function( elem
) {
2620 return indexOf( checkContext
, elem
) > -1;
2621 }, implicitRelative
, true ),
2622 matchers
= [ function( elem
, context
, xml
) {
2623 var ret
= ( !leadingRelative
&& ( xml
|| context
!== outermostContext
) ) || (
2624 ( checkContext
= context
).nodeType
?
2625 matchContext( elem
, context
, xml
) :
2626 matchAnyContext( elem
, context
, xml
) );
2628 // Avoid hanging onto element (issue #299)
2629 checkContext
= null;
2633 for ( ; i
< len
; i
++ ) {
2634 if ( ( matcher
= Expr
.relative
[ tokens
[ i
].type
] ) ) {
2635 matchers
= [ addCombinator( elementMatcher( matchers
), matcher
) ];
2637 matcher
= Expr
.filter
[ tokens
[ i
].type
].apply( null, tokens
[ i
].matches
);
2639 // Return special upon seeing a positional matcher
2640 if ( matcher
[ expando
] ) {
2642 // Find the next relative operator (if any) for proper handling
2644 for ( ; j
< len
; j
++ ) {
2645 if ( Expr
.relative
[ tokens
[ j
].type
] ) {
2650 i
> 1 && elementMatcher( matchers
),
2651 i
> 1 && toSelector(
2653 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2656 .concat( { value: tokens
[ i
- 2 ].type
=== " " ? "*" : "" } )
2657 ).replace( rtrim
, "$1" ),
2659 i
< j
&& matcherFromTokens( tokens
.slice( i
, j
) ),
2660 j
< len
&& matcherFromTokens( ( tokens
= tokens
.slice( j
) ) ),
2661 j
< len
&& toSelector( tokens
)
2664 matchers
.push( matcher
);
2668 return elementMatcher( matchers
);
2671 function matcherFromGroupMatchers( elementMatchers
, setMatchers
) {
2672 var bySet
= setMatchers
.length
> 0,
2673 byElement
= elementMatchers
.length
> 0,
2674 superMatcher = function( seed
, context
, xml
, results
, outermost
) {
2675 var elem
, j
, matcher
,
2678 unmatched
= seed
&& [],
2680 contextBackup
= outermostContext
,
2682 // We must always have either seed elements or outermost context
2683 elems
= seed
|| byElement
&& Expr
.find
[ "TAG" ]( "*", outermost
),
2685 // Use integer dirruns iff this is the outermost matcher
2686 dirrunsUnique
= ( dirruns
+= contextBackup
== null ? 1 : Math
.random() || 0.1 ),
2691 // Support: IE 11+, Edge 17 - 18+
2692 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2693 // two documents; shallow comparisons work.
2694 // eslint-disable-next-line eqeqeq
2695 outermostContext
= context
== document
|| context
|| outermost
;
2698 // Add elements passing elementMatchers directly to results
2699 // Support: IE<9, Safari
2700 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2701 for ( ; i
!== len
&& ( elem
= elems
[ i
] ) != null; i
++ ) {
2702 if ( byElement
&& elem
) {
2705 // Support: IE 11+, Edge 17 - 18+
2706 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2707 // two documents; shallow comparisons work.
2708 // eslint-disable-next-line eqeqeq
2709 if ( !context
&& elem
.ownerDocument
!= document
) {
2710 setDocument( elem
);
2711 xml
= !documentIsHTML
;
2713 while ( ( matcher
= elementMatchers
[ j
++ ] ) ) {
2714 if ( matcher( elem
, context
|| document
, xml
) ) {
2715 results
.push( elem
);
2720 dirruns
= dirrunsUnique
;
2724 // Track unmatched elements for set filters
2727 // They will have gone through all possible matchers
2728 if ( ( elem
= !matcher
&& elem
) ) {
2732 // Lengthen the array for every element, matched or not
2734 unmatched
.push( elem
);
2739 // `i` is now the count of elements visited above, and adding it to `matchedCount`
2740 // makes the latter nonnegative.
2743 // Apply set filters to unmatched elements
2744 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2745 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2746 // no element matchers and no seed.
2747 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2748 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2749 // numerically zero.
2750 if ( bySet
&& i
!== matchedCount
) {
2752 while ( ( matcher
= setMatchers
[ j
++ ] ) ) {
2753 matcher( unmatched
, setMatched
, context
, xml
);
2758 // Reintegrate element matches to eliminate the need for sorting
2759 if ( matchedCount
> 0 ) {
2761 if ( !( unmatched
[ i
] || setMatched
[ i
] ) ) {
2762 setMatched
[ i
] = pop
.call( results
);
2767 // Discard index placeholder values to get only actual matches
2768 setMatched
= condense( setMatched
);
2771 // Add matches to results
2772 push
.apply( results
, setMatched
);
2774 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2775 if ( outermost
&& !seed
&& setMatched
.length
> 0 &&
2776 ( matchedCount
+ setMatchers
.length
) > 1 ) {
2778 Sizzle
.uniqueSort( results
);
2782 // Override manipulation of globals by nested matchers
2784 dirruns
= dirrunsUnique
;
2785 outermostContext
= contextBackup
;
2792 markFunction( superMatcher
) :
2796 compile
= Sizzle
.compile = function( selector
, match
/* Internal Use Only */ ) {
2799 elementMatchers
= [],
2800 cached
= compilerCache
[ selector
+ " " ];
2804 // Generate a function of recursive functions that can be used to check each element
2806 match
= tokenize( selector
);
2810 cached
= matcherFromTokens( match
[ i
] );
2811 if ( cached
[ expando
] ) {
2812 setMatchers
.push( cached
);
2814 elementMatchers
.push( cached
);
2818 // Cache the compiled function
2819 cached
= compilerCache(
2821 matcherFromGroupMatchers( elementMatchers
, setMatchers
)
2824 // Save selector and tokenization
2825 cached
.selector
= selector
;
2831 * A low-level selection function that works with Sizzle's compiled
2832 * selector functions
2833 * @param {String|Function} selector A selector or a pre-compiled
2834 * selector function built with Sizzle.compile
2835 * @param {Element} context
2836 * @param {Array} [results]
2837 * @param {Array} [seed] A set of elements to match against
2839 select
= Sizzle
.select = function( selector
, context
, results
, seed
) {
2840 var i
, tokens
, token
, type
, find
,
2841 compiled
= typeof selector
=== "function" && selector
,
2842 match
= !seed
&& tokenize( ( selector
= compiled
.selector
|| selector
) );
2844 results
= results
|| [];
2846 // Try to minimize operations if there is only one selector in the list and no seed
2847 // (the latter of which guarantees us context)
2848 if ( match
.length
=== 1 ) {
2850 // Reduce context if the leading compound selector is an ID
2851 tokens
= match
[ 0 ] = match
[ 0 ].slice( 0 );
2852 if ( tokens
.length
> 2 && ( token
= tokens
[ 0 ] ).type
=== "ID" &&
2853 context
.nodeType
=== 9 && documentIsHTML
&& Expr
.relative
[ tokens
[ 1 ].type
] ) {
2855 context
= ( Expr
.find
[ "ID" ]( token
.matches
[ 0 ]
2856 .replace( runescape
, funescape
), context
) || [] )[ 0 ];
2860 // Precompiled matchers will still verify ancestry, so step up a level
2861 } else if ( compiled
) {
2862 context
= context
.parentNode
;
2865 selector
= selector
.slice( tokens
.shift().value
.length
);
2868 // Fetch a seed set for right-to-left matching
2869 i
= matchExpr
[ "needsContext" ].test( selector
) ? 0 : tokens
.length
;
2871 token
= tokens
[ i
];
2873 // Abort if we hit a combinator
2874 if ( Expr
.relative
[ ( type
= token
.type
) ] ) {
2877 if ( ( find
= Expr
.find
[ type
] ) ) {
2879 // Search, expanding context for leading sibling combinators
2881 token
.matches
[ 0 ].replace( runescape
, funescape
),
2882 rsibling
.test( tokens
[ 0 ].type
) && testContext( context
.parentNode
) ||
2886 // If seed is empty or no tokens remain, we can return early
2887 tokens
.splice( i
, 1 );
2888 selector
= seed
.length
&& toSelector( tokens
);
2890 push
.apply( results
, seed
);
2900 // Compile and execute a filtering function if one is not provided
2901 // Provide `match` to avoid retokenization if we modified the selector above
2902 ( compiled
|| compile( selector
, match
) )(
2907 !context
|| rsibling
.test( selector
) && testContext( context
.parentNode
) || context
2912 // One-time assignments
2915 support
.sortStable
= expando
.split( "" ).sort( sortOrder
).join( "" ) === expando
;
2917 // Support: Chrome 14-35+
2918 // Always assume duplicates if they aren't passed to the comparison function
2919 support
.detectDuplicates
= !!hasDuplicate
;
2921 // Initialize against the default document
2924 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2925 // Detached nodes confoundingly follow *each other*
2926 support
.sortDetached
= assert( function( el
) {
2928 // Should return 1, but returns 4 (following)
2929 return el
.compareDocumentPosition( document
.createElement( "fieldset" ) ) & 1;
2933 // Prevent attribute/property "interpolation"
2934 // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2935 if ( !assert( function( el
) {
2936 el
.innerHTML
= "<a href='#'></a>";
2937 return el
.firstChild
.getAttribute( "href" ) === "#";
2939 addHandle( "type|href|height|width", function( elem
, name
, isXML
) {
2941 return elem
.getAttribute( name
, name
.toLowerCase() === "type" ? 1 : 2 );
2947 // Use defaultValue in place of getAttribute("value")
2948 if ( !support
.attributes
|| !assert( function( el
) {
2949 el
.innerHTML
= "<input/>";
2950 el
.firstChild
.setAttribute( "value", "" );
2951 return el
.firstChild
.getAttribute( "value" ) === "";
2953 addHandle( "value", function( elem
, _name
, isXML
) {
2954 if ( !isXML
&& elem
.nodeName
.toLowerCase() === "input" ) {
2955 return elem
.defaultValue
;
2961 // Use getAttributeNode to fetch booleans when getAttribute lies
2962 if ( !assert( function( el
) {
2963 return el
.getAttribute( "disabled" ) == null;
2965 addHandle( booleans
, function( elem
, name
, isXML
) {
2968 return elem
[ name
] === true ? name
.toLowerCase() :
2969 ( val
= elem
.getAttributeNode( name
) ) && val
.specified
?
2982 jQuery
.find
= Sizzle
;
2983 jQuery
.expr
= Sizzle
.selectors
;
2986 jQuery
.expr
[ ":" ] = jQuery
.expr
.pseudos
;
2987 jQuery
.uniqueSort
= jQuery
.unique
= Sizzle
.uniqueSort
;
2988 jQuery
.text
= Sizzle
.getText
;
2989 jQuery
.isXMLDoc
= Sizzle
.isXML
;
2990 jQuery
.contains
= Sizzle
.contains
;
2991 jQuery
.escapeSelector
= Sizzle
.escape
;
2996 var dir = function( elem
, dir
, until
) {
2998 truncate
= until
!== undefined;
3000 while ( ( elem
= elem
[ dir
] ) && elem
.nodeType
!== 9 ) {
3001 if ( elem
.nodeType
=== 1 ) {
3002 if ( truncate
&& jQuery( elem
).is( until
) ) {
3005 matched
.push( elem
);
3012 var siblings = function( n
, elem
) {
3015 for ( ; n
; n
= n
.nextSibling
) {
3016 if ( n
.nodeType
=== 1 && n
!== elem
) {
3025 var rneedsContext
= jQuery
.expr
.match
.needsContext
;
3029 function nodeName( elem
, name
) {
3031 return elem
.nodeName
&& elem
.nodeName
.toLowerCase() === name
.toLowerCase();
3034 var rsingleTag
= ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
3038 // Implement the identical functionality for filter and not
3039 function winnow( elements
, qualifier
, not
) {
3040 if ( isFunction( qualifier
) ) {
3041 return jQuery
.grep( elements
, function( elem
, i
) {
3042 return !!qualifier
.call( elem
, i
, elem
) !== not
;
3047 if ( qualifier
.nodeType
) {
3048 return jQuery
.grep( elements
, function( elem
) {
3049 return ( elem
=== qualifier
) !== not
;
3053 // Arraylike of elements (jQuery, arguments, Array)
3054 if ( typeof qualifier
!== "string" ) {
3055 return jQuery
.grep( elements
, function( elem
) {
3056 return ( indexOf
.call( qualifier
, elem
) > -1 ) !== not
;
3060 // Filtered directly for both simple and complex selectors
3061 return jQuery
.filter( qualifier
, elements
, not
);
3064 jQuery
.filter = function( expr
, elems
, not
) {
3065 var elem
= elems
[ 0 ];
3068 expr
= ":not(" + expr
+ ")";
3071 if ( elems
.length
=== 1 && elem
.nodeType
=== 1 ) {
3072 return jQuery
.find
.matchesSelector( elem
, expr
) ? [ elem
] : [];
3075 return jQuery
.find
.matches( expr
, jQuery
.grep( elems
, function( elem
) {
3076 return elem
.nodeType
=== 1;
3081 find: function( selector
) {
3086 if ( typeof selector
!== "string" ) {
3087 return this.pushStack( jQuery( selector
).filter( function() {
3088 for ( i
= 0; i
< len
; i
++ ) {
3089 if ( jQuery
.contains( self
[ i
], this ) ) {
3096 ret
= this.pushStack( [] );
3098 for ( i
= 0; i
< len
; i
++ ) {
3099 jQuery
.find( selector
, self
[ i
], ret
);
3102 return len
> 1 ? jQuery
.uniqueSort( ret
) : ret
;
3104 filter: function( selector
) {
3105 return this.pushStack( winnow( this, selector
|| [], false ) );
3107 not: function( selector
) {
3108 return this.pushStack( winnow( this, selector
|| [], true ) );
3110 is: function( selector
) {
3114 // If this is a positional/relative selector, check membership in the returned set
3115 // so $("p:first").is("p:last") won't return true for a doc with two "p".
3116 typeof selector
=== "string" && rneedsContext
.test( selector
) ?
3117 jQuery( selector
) :
3125 // Initialize a jQuery object
3128 // A central reference to the root jQuery(document)
3131 // A simple way to check for HTML strings
3132 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
3133 // Strict HTML recognition (#11290: must start with <)
3134 // Shortcut simple #id case for speed
3135 rquickExpr
= /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
3137 init
= jQuery
.fn
.init = function( selector
, context
, root
) {
3140 // HANDLE: $(""), $(null), $(undefined), $(false)
3145 // Method init() accepts an alternate rootjQuery
3146 // so migrate can support jQuery.sub (gh-2101)
3147 root
= root
|| rootjQuery
;
3149 // Handle HTML strings
3150 if ( typeof selector
=== "string" ) {
3151 if ( selector
[ 0 ] === "<" &&
3152 selector
[ selector
.length
- 1 ] === ">" &&
3153 selector
.length
>= 3 ) {
3155 // Assume that strings that start and end with <> are HTML and skip the regex check
3156 match
= [ null, selector
, null ];
3159 match
= rquickExpr
.exec( selector
);
3162 // Match html or make sure no context is specified for #id
3163 if ( match
&& ( match
[ 1 ] || !context
) ) {
3165 // HANDLE: $(html) -> $(array)
3167 context
= context
instanceof jQuery
? context
[ 0 ] : context
;
3169 // Option to run scripts is true for back-compat
3170 // Intentionally let the error be thrown if parseHTML is not present
3171 jQuery
.merge( this, jQuery
.parseHTML(
3173 context
&& context
.nodeType
? context
.ownerDocument
|| context : document
,
3177 // HANDLE: $(html, props)
3178 if ( rsingleTag
.test( match
[ 1 ] ) && jQuery
.isPlainObject( context
) ) {
3179 for ( match
in context
) {
3181 // Properties of context are called as methods if possible
3182 if ( isFunction( this[ match
] ) ) {
3183 this[ match
]( context
[ match
] );
3185 // ...and otherwise set as attributes
3187 this.attr( match
, context
[ match
] );
3196 elem
= document
.getElementById( match
[ 2 ] );
3200 // Inject the element directly into the jQuery object
3207 // HANDLE: $(expr, $(...))
3208 } else if ( !context
|| context
.jquery
) {
3209 return ( context
|| root
).find( selector
);
3211 // HANDLE: $(expr, context)
3212 // (which is just equivalent to: $(context).find(expr)
3214 return this.constructor( context
).find( selector
);
3217 // HANDLE: $(DOMElement)
3218 } else if ( selector
.nodeType
) {
3219 this[ 0 ] = selector
;
3223 // HANDLE: $(function)
3224 // Shortcut for document ready
3225 } else if ( isFunction( selector
) ) {
3226 return root
.ready
!== undefined ?
3227 root
.ready( selector
) :
3229 // Execute immediately if ready is not present
3233 return jQuery
.makeArray( selector
, this );
3236 // Give the init function the jQuery prototype for later instantiation
3237 init
.prototype = jQuery
.fn
;
3239 // Initialize central reference
3240 rootjQuery
= jQuery( document
);
3243 var rparentsprev
= /^(?:parents|prev(?:Until|All))/,
3245 // Methods guaranteed to produce a unique set when starting from a unique set
3246 guaranteedUnique
= {
3254 has: function( target
) {
3255 var targets
= jQuery( target
, this ),
3258 return this.filter( function() {
3260 for ( ; i
< l
; i
++ ) {
3261 if ( jQuery
.contains( this, targets
[ i
] ) ) {
3268 closest: function( selectors
, context
) {
3273 targets
= typeof selectors
!== "string" && jQuery( selectors
);
3275 // Positional selectors never match, since there's no _selection_ context
3276 if ( !rneedsContext
.test( selectors
) ) {
3277 for ( ; i
< l
; i
++ ) {
3278 for ( cur
= this[ i
]; cur
&& cur
!== context
; cur
= cur
.parentNode
) {
3280 // Always skip document fragments
3281 if ( cur
.nodeType
< 11 && ( targets
?
3282 targets
.index( cur
) > -1 :
3284 // Don't pass non-elements to Sizzle
3285 cur
.nodeType
=== 1 &&
3286 jQuery
.find
.matchesSelector( cur
, selectors
) ) ) {
3288 matched
.push( cur
);
3295 return this.pushStack( matched
.length
> 1 ? jQuery
.uniqueSort( matched
) : matched
);
3298 // Determine the position of an element within the set
3299 index: function( elem
) {
3301 // No argument, return index in parent
3303 return ( this[ 0 ] && this[ 0 ].parentNode
) ? this.first().prevAll().length : -1;
3306 // Index in selector
3307 if ( typeof elem
=== "string" ) {
3308 return indexOf
.call( jQuery( elem
), this[ 0 ] );
3311 // Locate the position of the desired element
3312 return indexOf
.call( this,
3314 // If it receives a jQuery object, the first element is used
3315 elem
.jquery
? elem
[ 0 ] : elem
3319 add: function( selector
, context
) {
3320 return this.pushStack(
3322 jQuery
.merge( this.get(), jQuery( selector
, context
) )
3327 addBack: function( selector
) {
3328 return this.add( selector
== null ?
3329 this.prevObject : this.prevObject
.filter( selector
)
3334 function sibling( cur
, dir
) {
3335 while ( ( cur
= cur
[ dir
] ) && cur
.nodeType
!== 1 ) {}
3340 parent: function( elem
) {
3341 var parent
= elem
.parentNode
;
3342 return parent
&& parent
.nodeType
!== 11 ? parent : null;
3344 parents: function( elem
) {
3345 return dir( elem
, "parentNode" );
3347 parentsUntil: function( elem
, _i
, until
) {
3348 return dir( elem
, "parentNode", until
);
3350 next: function( elem
) {
3351 return sibling( elem
, "nextSibling" );
3353 prev: function( elem
) {
3354 return sibling( elem
, "previousSibling" );
3356 nextAll: function( elem
) {
3357 return dir( elem
, "nextSibling" );
3359 prevAll: function( elem
) {
3360 return dir( elem
, "previousSibling" );
3362 nextUntil: function( elem
, _i
, until
) {
3363 return dir( elem
, "nextSibling", until
);
3365 prevUntil: function( elem
, _i
, until
) {
3366 return dir( elem
, "previousSibling", until
);
3368 siblings: function( elem
) {
3369 return siblings( ( elem
.parentNode
|| {} ).firstChild
, elem
);
3371 children: function( elem
) {
3372 return siblings( elem
.firstChild
);
3374 contents: function( elem
) {
3375 if ( elem
.contentDocument
!= null &&
3378 // <object> elements with no `data` attribute has an object
3379 // `contentDocument` with a `null` prototype.
3380 getProto( elem
.contentDocument
) ) {
3382 return elem
.contentDocument
;
3385 // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
3386 // Treat the template element as a regular one in browsers that
3387 // don't support it.
3388 if ( nodeName( elem
, "template" ) ) {
3389 elem
= elem
.content
|| elem
;
3392 return jQuery
.merge( [], elem
.childNodes
);
3394 }, function( name
, fn
) {
3395 jQuery
.fn
[ name
] = function( until
, selector
) {
3396 var matched
= jQuery
.map( this, fn
, until
);
3398 if ( name
.slice( -5 ) !== "Until" ) {
3402 if ( selector
&& typeof selector
=== "string" ) {
3403 matched
= jQuery
.filter( selector
, matched
);
3406 if ( this.length
> 1 ) {
3408 // Remove duplicates
3409 if ( !guaranteedUnique
[ name
] ) {
3410 jQuery
.uniqueSort( matched
);
3413 // Reverse order for parents* and prev-derivatives
3414 if ( rparentsprev
.test( name
) ) {
3419 return this.pushStack( matched
);
3422 var rnothtmlwhite
= ( /[^\x20\t\r\n\f]+/g );
3426 // Convert String-formatted options into Object-formatted ones
3427 function createOptions( options
) {
3429 jQuery
.each( options
.match( rnothtmlwhite
) || [], function( _
, flag
) {
3430 object
[ flag
] = true;
3436 * Create a callback list using the following parameters:
3438 * options: an optional list of space-separated options that will change how
3439 * the callback list behaves or a more traditional option object
3441 * By default a callback list will act like an event callback list and can be
3442 * "fired" multiple times.
3446 * once: will ensure the callback list can only be fired once (like a Deferred)
3448 * memory: will keep track of previous values and will call any callback added
3449 * after the list has been fired right away with the latest "memorized"
3450 * values (like a Deferred)
3452 * unique: will ensure a callback can only be added once (no duplicate in the list)
3454 * stopOnFalse: interrupt callings when a callback returns false
3457 jQuery
.Callbacks = function( options
) {
3459 // Convert options from String-formatted to Object-formatted if needed
3460 // (we check in cache first)
3461 options
= typeof options
=== "string" ?
3462 createOptions( options
) :
3463 jQuery
.extend( {}, options
);
3465 var // Flag to know if list is currently firing
3468 // Last fire value for non-forgettable lists
3471 // Flag to know if list was already fired
3474 // Flag to prevent firing
3477 // Actual callback list
3480 // Queue of execution data for repeatable lists
3483 // Index of currently firing callback (modified by add/remove as needed)
3489 // Enforce single-firing
3490 locked
= locked
|| options
.once
;
3492 // Execute callbacks for all pending executions,
3493 // respecting firingIndex overrides and runtime changes
3494 fired
= firing
= true;
3495 for ( ; queue
.length
; firingIndex
= -1 ) {
3496 memory
= queue
.shift();
3497 while ( ++firingIndex
< list
.length
) {
3499 // Run callback and check for early termination
3500 if ( list
[ firingIndex
].apply( memory
[ 0 ], memory
[ 1 ] ) === false &&
3501 options
.stopOnFalse
) {
3503 // Jump to end and forget the data so .add doesn't re-fire
3504 firingIndex
= list
.length
;
3510 // Forget the data if we're done with it
3511 if ( !options
.memory
) {
3517 // Clean up if we're done firing for good
3520 // Keep an empty list if we have data for future add calls
3524 // Otherwise, this object is spent
3531 // Actual Callbacks object
3534 // Add a callback or a collection of callbacks to the list
3538 // If we have memory from a past run, we should fire after adding
3539 if ( memory
&& !firing
) {
3540 firingIndex
= list
.length
- 1;
3541 queue
.push( memory
);
3544 ( function add( args
) {
3545 jQuery
.each( args
, function( _
, arg
) {
3546 if ( isFunction( arg
) ) {
3547 if ( !options
.unique
|| !self
.has( arg
) ) {
3550 } else if ( arg
&& arg
.length
&& toType( arg
) !== "string" ) {
3552 // Inspect recursively
3558 if ( memory
&& !firing
) {
3565 // Remove a callback from the list
3566 remove: function() {
3567 jQuery
.each( arguments
, function( _
, arg
) {
3569 while ( ( index
= jQuery
.inArray( arg
, list
, index
) ) > -1 ) {
3570 list
.splice( index
, 1 );
3572 // Handle firing indexes
3573 if ( index
<= firingIndex
) {
3581 // Check if a given callback is in the list.
3582 // If no argument is given, return whether or not list has callbacks attached.
3583 has: function( fn
) {
3585 jQuery
.inArray( fn
, list
) > -1 :
3589 // Remove all callbacks from the list
3597 // Disable .fire and .add
3598 // Abort any current/pending executions
3599 // Clear all callbacks and values
3600 disable: function() {
3601 locked
= queue
= [];
3605 disabled: function() {
3610 // Also disable .add unless we have memory (since it would have no effect)
3611 // Abort any pending executions
3613 locked
= queue
= [];
3614 if ( !memory
&& !firing
) {
3619 locked: function() {
3623 // Call all callbacks with the given context and arguments
3624 fireWith: function( context
, args
) {
3627 args
= [ context
, args
.slice
? args
.slice() : args
];
3636 // Call all the callbacks with the given arguments
3638 self
.fireWith( this, arguments
);
3642 // To know if the callbacks have already been called at least once
3652 function Identity( v
) {
3655 function Thrower( ex
) {
3659 function adoptValue( value
, resolve
, reject
, noValue
) {
3664 // Check for promise aspect first to privilege synchronous behavior
3665 if ( value
&& isFunction( ( method
= value
.promise
) ) ) {
3666 method
.call( value
).done( resolve
).fail( reject
);
3669 } else if ( value
&& isFunction( ( method
= value
.then
) ) ) {
3670 method
.call( value
, resolve
, reject
);
3672 // Other non-thenables
3675 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
3676 // * false: [ value ].slice( 0 ) => resolve( value )
3677 // * true: [ value ].slice( 1 ) => resolve()
3678 resolve
.apply( undefined, [ value
].slice( noValue
) );
3681 // For Promises/A+, convert exceptions into rejections
3682 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
3683 // Deferred#then to conditionally suppress rejection.
3686 // Support: Android 4.0 only
3687 // Strict mode functions invoked without .call/.apply get global-object context
3688 reject
.apply( undefined, [ value
] );
3694 Deferred: function( func
) {
3697 // action, add listener, callbacks,
3698 // ... .then handlers, argument index, [final state]
3699 [ "notify", "progress", jQuery
.Callbacks( "memory" ),
3700 jQuery
.Callbacks( "memory" ), 2 ],
3701 [ "resolve", "done", jQuery
.Callbacks( "once memory" ),
3702 jQuery
.Callbacks( "once memory" ), 0, "resolved" ],
3703 [ "reject", "fail", jQuery
.Callbacks( "once memory" ),
3704 jQuery
.Callbacks( "once memory" ), 1, "rejected" ]
3711 always: function() {
3712 deferred
.done( arguments
).fail( arguments
);
3715 "catch": function( fn
) {
3716 return promise
.then( null, fn
);
3719 // Keep pipe for back-compat
3720 pipe: function( /* fnDone, fnFail, fnProgress */ ) {
3721 var fns
= arguments
;
3723 return jQuery
.Deferred( function( newDefer
) {
3724 jQuery
.each( tuples
, function( _i
, tuple
) {
3726 // Map tuples (progress, done, fail) to arguments (done, fail, progress)
3727 var fn
= isFunction( fns
[ tuple
[ 4 ] ] ) && fns
[ tuple
[ 4 ] ];
3729 // deferred.progress(function() { bind to newDefer or newDefer.notify })
3730 // deferred.done(function() { bind to newDefer or newDefer.resolve })
3731 // deferred.fail(function() { bind to newDefer or newDefer.reject })
3732 deferred
[ tuple
[ 1 ] ]( function() {
3733 var returned
= fn
&& fn
.apply( this, arguments
);
3734 if ( returned
&& isFunction( returned
.promise
) ) {
3736 .progress( newDefer
.notify
)
3737 .done( newDefer
.resolve
)
3738 .fail( newDefer
.reject
);
3740 newDefer
[ tuple
[ 0 ] + "With" ](
3742 fn
? [ returned
] : arguments
3750 then: function( onFulfilled
, onRejected
, onProgress
) {
3752 function resolve( depth
, deferred
, handler
, special
) {
3756 mightThrow = function() {
3759 // Support: Promises/A+ section 2.3.3.3.3
3760 // https://promisesaplus.com/#point-59
3761 // Ignore double-resolution attempts
3762 if ( depth
< maxDepth
) {
3766 returned
= handler
.apply( that
, args
);
3768 // Support: Promises/A+ section 2.3.1
3769 // https://promisesaplus.com/#point-48
3770 if ( returned
=== deferred
.promise() ) {
3771 throw new TypeError( "Thenable self-resolution" );
3774 // Support: Promises/A+ sections 2.3.3.1, 3.5
3775 // https://promisesaplus.com/#point-54
3776 // https://promisesaplus.com/#point-75
3777 // Retrieve `then` only once
3780 // Support: Promises/A+ section 2.3.4
3781 // https://promisesaplus.com/#point-64
3782 // Only check objects and functions for thenability
3783 ( typeof returned
=== "object" ||
3784 typeof returned
=== "function" ) &&
3787 // Handle a returned thenable
3788 if ( isFunction( then
) ) {
3790 // Special processors (notify) just wait for resolution
3794 resolve( maxDepth
, deferred
, Identity
, special
),
3795 resolve( maxDepth
, deferred
, Thrower
, special
)
3798 // Normal processors (resolve) also hook into progress
3801 // ...and disregard older resolution values
3806 resolve( maxDepth
, deferred
, Identity
, special
),
3807 resolve( maxDepth
, deferred
, Thrower
, special
),
3808 resolve( maxDepth
, deferred
, Identity
,
3809 deferred
.notifyWith
)
3813 // Handle all other returned values
3816 // Only substitute handlers pass on context
3817 // and multiple values (non-spec behavior)
3818 if ( handler
!== Identity
) {
3820 args
= [ returned
];
3823 // Process the value(s)
3824 // Default process is resolve
3825 ( special
|| deferred
.resolveWith
)( that
, args
);
3829 // Only normal processors (resolve) catch and reject exceptions
3837 if ( jQuery
.Deferred
.exceptionHook
) {
3838 jQuery
.Deferred
.exceptionHook( e
,
3839 process
.stackTrace
);
3842 // Support: Promises/A+ section 2.3.3.3.4.1
3843 // https://promisesaplus.com/#point-61
3844 // Ignore post-resolution exceptions
3845 if ( depth
+ 1 >= maxDepth
) {
3847 // Only substitute handlers pass on context
3848 // and multiple values (non-spec behavior)
3849 if ( handler
!== Thrower
) {
3854 deferred
.rejectWith( that
, args
);
3859 // Support: Promises/A+ section 2.3.3.3.1
3860 // https://promisesaplus.com/#point-57
3861 // Re-resolve promises immediately to dodge false rejection from
3862 // subsequent errors
3867 // Call an optional hook to record the stack, in case of exception
3868 // since it's otherwise lost when execution goes async
3869 if ( jQuery
.Deferred
.getStackHook
) {
3870 process
.stackTrace
= jQuery
.Deferred
.getStackHook();
3872 window
.setTimeout( process
);
3877 return jQuery
.Deferred( function( newDefer
) {
3879 // progress_handlers.add( ... )
3880 tuples
[ 0 ][ 3 ].add(
3884 isFunction( onProgress
) ?
3891 // fulfilled_handlers.add( ... )
3892 tuples
[ 1 ][ 3 ].add(
3896 isFunction( onFulfilled
) ?
3902 // rejected_handlers.add( ... )
3903 tuples
[ 2 ][ 3 ].add(
3907 isFunction( onRejected
) ?
3915 // Get a promise for this deferred
3916 // If obj is provided, the promise aspect is added to the object
3917 promise: function( obj
) {
3918 return obj
!= null ? jQuery
.extend( obj
, promise
) : promise
;
3923 // Add list-specific methods
3924 jQuery
.each( tuples
, function( i
, tuple
) {
3925 var list
= tuple
[ 2 ],
3926 stateString
= tuple
[ 5 ];
3928 // promise.progress = list.add
3929 // promise.done = list.add
3930 // promise.fail = list.add
3931 promise
[ tuple
[ 1 ] ] = list
.add
;
3934 if ( stateString
) {
3938 // state = "resolved" (i.e., fulfilled)
3939 // state = "rejected"
3940 state
= stateString
;
3943 // rejected_callbacks.disable
3944 // fulfilled_callbacks.disable
3945 tuples
[ 3 - i
][ 2 ].disable
,
3947 // rejected_handlers.disable
3948 // fulfilled_handlers.disable
3949 tuples
[ 3 - i
][ 3 ].disable
,
3951 // progress_callbacks.lock
3952 tuples
[ 0 ][ 2 ].lock
,
3954 // progress_handlers.lock
3955 tuples
[ 0 ][ 3 ].lock
3959 // progress_handlers.fire
3960 // fulfilled_handlers.fire
3961 // rejected_handlers.fire
3962 list
.add( tuple
[ 3 ].fire
);
3964 // deferred.notify = function() { deferred.notifyWith(...) }
3965 // deferred.resolve = function() { deferred.resolveWith(...) }
3966 // deferred.reject = function() { deferred.rejectWith(...) }
3967 deferred
[ tuple
[ 0 ] ] = function() {
3968 deferred
[ tuple
[ 0 ] + "With" ]( this === deferred
? undefined : this, arguments
);
3972 // deferred.notifyWith = list.fireWith
3973 // deferred.resolveWith = list.fireWith
3974 // deferred.rejectWith = list.fireWith
3975 deferred
[ tuple
[ 0 ] + "With" ] = list
.fireWith
;
3978 // Make the deferred a promise
3979 promise
.promise( deferred
);
3981 // Call given func if any
3983 func
.call( deferred
, deferred
);
3991 when: function( singleValue
) {
3994 // count of uncompleted subordinates
3995 remaining
= arguments
.length
,
3997 // count of unprocessed arguments
4000 // subordinate fulfillment data
4001 resolveContexts
= Array( i
),
4002 resolveValues
= slice
.call( arguments
),
4004 // the primary Deferred
4005 primary
= jQuery
.Deferred(),
4007 // subordinate callback factory
4008 updateFunc = function( i
) {
4009 return function( value
) {
4010 resolveContexts
[ i
] = this;
4011 resolveValues
[ i
] = arguments
.length
> 1 ? slice
.call( arguments
) : value
;
4012 if ( !( --remaining
) ) {
4013 primary
.resolveWith( resolveContexts
, resolveValues
);
4018 // Single- and empty arguments are adopted like Promise.resolve
4019 if ( remaining
<= 1 ) {
4020 adoptValue( singleValue
, primary
.done( updateFunc( i
) ).resolve
, primary
.reject
,
4023 // Use .then() to unwrap secondary thenables (cf. gh-3000)
4024 if ( primary
.state() === "pending" ||
4025 isFunction( resolveValues
[ i
] && resolveValues
[ i
].then
) ) {
4027 return primary
.then();
4031 // Multiple arguments are aggregated like Promise.all array elements
4033 adoptValue( resolveValues
[ i
], updateFunc( i
), primary
.reject
);
4036 return primary
.promise();
4041 // These usually indicate a programmer mistake during development,
4042 // warn about them ASAP rather than swallowing them by default.
4043 var rerrorNames
= /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
4045 jQuery
.Deferred
.exceptionHook = function( error
, stack
) {
4047 // Support: IE 8 - 9 only
4048 // Console exists when dev tools are open, which can happen at any time
4049 if ( window
.console
&& window
.console
.warn
&& error
&& rerrorNames
.test( error
.name
) ) {
4050 window
.console
.warn( "jQuery.Deferred exception: " + error
.message
, error
.stack
, stack
);
4057 jQuery
.readyException = function( error
) {
4058 window
.setTimeout( function() {
4066 // The deferred used on DOM ready
4067 var readyList
= jQuery
.Deferred();
4069 jQuery
.fn
.ready = function( fn
) {
4074 // Wrap jQuery.readyException in a function so that the lookup
4075 // happens at the time of error handling instead of callback
4077 .catch( function( error
) {
4078 jQuery
.readyException( error
);
4086 // Is the DOM ready to be used? Set to true once it occurs.
4089 // A counter to track how many items to wait for before
4090 // the ready event fires. See #6781
4093 // Handle when the DOM is ready
4094 ready: function( wait
) {
4096 // Abort if there are pending holds or we're already ready
4097 if ( wait
=== true ? --jQuery
.readyWait : jQuery
.isReady
) {
4101 // Remember that the DOM is ready
4102 jQuery
.isReady
= true;
4104 // If a normal DOM Ready event fired, decrement, and wait if need be
4105 if ( wait
!== true && --jQuery
.readyWait
> 0 ) {
4109 // If there are functions bound, to execute
4110 readyList
.resolveWith( document
, [ jQuery
] );
4114 jQuery
.ready
.then
= readyList
.then
;
4116 // The ready event handler and self cleanup method
4117 function completed() {
4118 document
.removeEventListener( "DOMContentLoaded", completed
);
4119 window
.removeEventListener( "load", completed
);
4123 // Catch cases where $(document).ready() is called
4124 // after the browser event has already occurred.
4125 // Support: IE <=9 - 10 only
4126 // Older IE sometimes signals "interactive" too soon
4127 if ( document
.readyState
=== "complete" ||
4128 ( document
.readyState
!== "loading" && !document
.documentElement
.doScroll
) ) {
4130 // Handle it asynchronously to allow scripts the opportunity to delay ready
4131 window
.setTimeout( jQuery
.ready
);
4135 // Use the handy event callback
4136 document
.addEventListener( "DOMContentLoaded", completed
);
4138 // A fallback to window.onload, that will always work
4139 window
.addEventListener( "load", completed
);
4145 // Multifunctional method to get and set values of a collection
4146 // The value/s can optionally be executed if it's a function
4147 var access = function( elems
, fn
, key
, value
, chainable
, emptyGet
, raw
) {
4153 if ( toType( key
) === "object" ) {
4156 access( elems
, fn
, i
, key
[ i
], true, emptyGet
, raw
);
4160 } else if ( value
!== undefined ) {
4163 if ( !isFunction( value
) ) {
4169 // Bulk operations run against the entire set
4171 fn
.call( elems
, value
);
4174 // ...except when executing function values
4177 fn = function( elem
, _key
, value
) {
4178 return bulk
.call( jQuery( elem
), value
);
4184 for ( ; i
< len
; i
++ ) {
4186 elems
[ i
], key
, raw
?
4188 value
.call( elems
[ i
], i
, fn( elems
[ i
], key
) )
4200 return fn
.call( elems
);
4203 return len
? fn( elems
[ 0 ], key
) : emptyGet
;
4207 // Matches dashed string for camelizing
4208 var rmsPrefix
= /^-ms-/,
4209 rdashAlpha
= /-([a-z])/g;
4211 // Used by camelCase as callback to replace()
4212 function fcamelCase( _all
, letter
) {
4213 return letter
.toUpperCase();
4216 // Convert dashed to camelCase; used by the css and data modules
4217 // Support: IE <=9 - 11, Edge 12 - 15
4218 // Microsoft forgot to hump their vendor prefix (#9572)
4219 function camelCase( string
) {
4220 return string
.replace( rmsPrefix
, "ms-" ).replace( rdashAlpha
, fcamelCase
);
4222 var acceptData = function( owner
) {
4226 // - Node.ELEMENT_NODE
4227 // - Node.DOCUMENT_NODE
4230 return owner
.nodeType
=== 1 || owner
.nodeType
=== 9 || !( +owner
.nodeType
);
4237 this.expando
= jQuery
.expando
+ Data
.uid
++;
4244 cache: function( owner
) {
4246 // Check if the owner object already has a cache
4247 var value
= owner
[ this.expando
];
4249 // If not, create one
4253 // We can accept data for non-element nodes in modern browsers,
4254 // but we should not, see #8335.
4255 // Always return an empty object.
4256 if ( acceptData( owner
) ) {
4258 // If it is a node unlikely to be stringify-ed or looped over
4259 // use plain assignment
4260 if ( owner
.nodeType
) {
4261 owner
[ this.expando
] = value
;
4263 // Otherwise secure it in a non-enumerable property
4264 // configurable must be true to allow the property to be
4265 // deleted when data is removed
4267 Object
.defineProperty( owner
, this.expando
, {
4277 set: function( owner
, data
, value
) {
4279 cache
= this.cache( owner
);
4281 // Handle: [ owner, key, value ] args
4282 // Always use camelCase key (gh-2257)
4283 if ( typeof data
=== "string" ) {
4284 cache
[ camelCase( data
) ] = value
;
4286 // Handle: [ owner, { properties } ] args
4289 // Copy the properties one-by-one to the cache object
4290 for ( prop
in data
) {
4291 cache
[ camelCase( prop
) ] = data
[ prop
];
4296 get: function( owner
, key
) {
4297 return key
=== undefined ?
4298 this.cache( owner
) :
4300 // Always use camelCase key (gh-2257)
4301 owner
[ this.expando
] && owner
[ this.expando
][ camelCase( key
) ];
4303 access: function( owner
, key
, value
) {
4305 // In cases where either:
4307 // 1. No key was specified
4308 // 2. A string key was specified, but no value provided
4310 // Take the "read" path and allow the get method to determine
4311 // which value to return, respectively either:
4313 // 1. The entire cache object
4314 // 2. The data stored at the key
4316 if ( key
=== undefined ||
4317 ( ( key
&& typeof key
=== "string" ) && value
=== undefined ) ) {
4319 return this.get( owner
, key
);
4322 // When the key is not a string, or both a key and value
4323 // are specified, set or extend (existing objects) with either:
4325 // 1. An object of properties
4326 // 2. A key and value
4328 this.set( owner
, key
, value
);
4330 // Since the "set" path can have two possible entry points
4331 // return the expected data based on which path was taken[*]
4332 return value
!== undefined ? value : key
;
4334 remove: function( owner
, key
) {
4336 cache
= owner
[ this.expando
];
4338 if ( cache
=== undefined ) {
4342 if ( key
!== undefined ) {
4344 // Support array or space separated string of keys
4345 if ( Array
.isArray( key
) ) {
4347 // If key is an array of keys...
4348 // We always set camelCase keys, so remove that.
4349 key
= key
.map( camelCase
);
4351 key
= camelCase( key
);
4353 // If a key with the spaces exists, use it.
4354 // Otherwise, create an array by matching non-whitespace
4355 key
= key
in cache
?
4357 ( key
.match( rnothtmlwhite
) || [] );
4363 delete cache
[ key
[ i
] ];
4367 // Remove the expando if there's no more data
4368 if ( key
=== undefined || jQuery
.isEmptyObject( cache
) ) {
4370 // Support: Chrome <=35 - 45
4371 // Webkit & Blink performance suffers when deleting properties
4372 // from DOM nodes, so set to undefined instead
4373 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
4374 if ( owner
.nodeType
) {
4375 owner
[ this.expando
] = undefined;
4377 delete owner
[ this.expando
];
4381 hasData: function( owner
) {
4382 var cache
= owner
[ this.expando
];
4383 return cache
!== undefined && !jQuery
.isEmptyObject( cache
);
4386 var dataPriv
= new Data();
4388 var dataUser
= new Data();
4392 // Implementation Summary
4394 // 1. Enforce API surface and semantic compatibility with 1.9.x branch
4395 // 2. Improve the module's maintainability by reducing the storage
4396 // paths to a single mechanism.
4397 // 3. Use the same single mechanism to support "private" and "user" data.
4398 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
4399 // 5. Avoid exposing implementation details on user objects (eg. expando properties)
4400 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
4402 var rbrace
= /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
4403 rmultiDash
= /[A-Z]/g;
4405 function getData( data
) {
4406 if ( data
=== "true" ) {
4410 if ( data
=== "false" ) {
4414 if ( data
=== "null" ) {
4418 // Only convert to a number if it doesn't change the string
4419 if ( data
=== +data
+ "" ) {
4423 if ( rbrace
.test( data
) ) {
4424 return JSON
.parse( data
);
4430 function dataAttr( elem
, key
, data
) {
4433 // If nothing was found internally, try to fetch any
4434 // data from the HTML5 data-* attribute
4435 if ( data
=== undefined && elem
.nodeType
=== 1 ) {
4436 name
= "data-" + key
.replace( rmultiDash
, "-$&" ).toLowerCase();
4437 data
= elem
.getAttribute( name
);
4439 if ( typeof data
=== "string" ) {
4441 data
= getData( data
);
4444 // Make sure we set the data so it isn't changed later
4445 dataUser
.set( elem
, key
, data
);
4454 hasData: function( elem
) {
4455 return dataUser
.hasData( elem
) || dataPriv
.hasData( elem
);
4458 data: function( elem
, name
, data
) {
4459 return dataUser
.access( elem
, name
, data
);
4462 removeData: function( elem
, name
) {
4463 dataUser
.remove( elem
, name
);
4466 // TODO: Now that all calls to _data and _removeData have been replaced
4467 // with direct calls to dataPriv methods, these can be deprecated.
4468 _data: function( elem
, name
, data
) {
4469 return dataPriv
.access( elem
, name
, data
);
4472 _removeData: function( elem
, name
) {
4473 dataPriv
.remove( elem
, name
);
4478 data: function( key
, value
) {
4481 attrs
= elem
&& elem
.attributes
;
4484 if ( key
=== undefined ) {
4485 if ( this.length
) {
4486 data
= dataUser
.get( elem
);
4488 if ( elem
.nodeType
=== 1 && !dataPriv
.get( elem
, "hasDataAttrs" ) ) {
4492 // Support: IE 11 only
4493 // The attrs elements can be null (#14894)
4495 name
= attrs
[ i
].name
;
4496 if ( name
.indexOf( "data-" ) === 0 ) {
4497 name
= camelCase( name
.slice( 5 ) );
4498 dataAttr( elem
, name
, data
[ name
] );
4502 dataPriv
.set( elem
, "hasDataAttrs", true );
4509 // Sets multiple values
4510 if ( typeof key
=== "object" ) {
4511 return this.each( function() {
4512 dataUser
.set( this, key
);
4516 return access( this, function( value
) {
4519 // The calling jQuery object (element matches) is not empty
4520 // (and therefore has an element appears at this[ 0 ]) and the
4521 // `value` parameter was not undefined. An empty jQuery object
4522 // will result in `undefined` for elem = this[ 0 ] which will
4523 // throw an exception if an attempt to read a data cache is made.
4524 if ( elem
&& value
=== undefined ) {
4526 // Attempt to get data from the cache
4527 // The key will always be camelCased in Data
4528 data
= dataUser
.get( elem
, key
);
4529 if ( data
!== undefined ) {
4533 // Attempt to "discover" the data in
4534 // HTML5 custom data-* attrs
4535 data
= dataAttr( elem
, key
);
4536 if ( data
!== undefined ) {
4540 // We tried really hard, but the data doesn't exist.
4545 this.each( function() {
4547 // We always store the camelCased key
4548 dataUser
.set( this, key
, value
);
4550 }, null, value
, arguments
.length
> 1, null, true );
4553 removeData: function( key
) {
4554 return this.each( function() {
4555 dataUser
.remove( this, key
);
4562 queue: function( elem
, type
, data
) {
4566 type
= ( type
|| "fx" ) + "queue";
4567 queue
= dataPriv
.get( elem
, type
);
4569 // Speed up dequeue by getting out quickly if this is just a lookup
4571 if ( !queue
|| Array
.isArray( data
) ) {
4572 queue
= dataPriv
.access( elem
, type
, jQuery
.makeArray( data
) );
4581 dequeue: function( elem
, type
) {
4582 type
= type
|| "fx";
4584 var queue
= jQuery
.queue( elem
, type
),
4585 startLength
= queue
.length
,
4587 hooks
= jQuery
._queueHooks( elem
, type
),
4589 jQuery
.dequeue( elem
, type
);
4592 // If the fx queue is dequeued, always remove the progress sentinel
4593 if ( fn
=== "inprogress" ) {
4600 // Add a progress sentinel to prevent the fx queue from being
4601 // automatically dequeued
4602 if ( type
=== "fx" ) {
4603 queue
.unshift( "inprogress" );
4606 // Clear up the last queue stop function
4608 fn
.call( elem
, next
, hooks
);
4611 if ( !startLength
&& hooks
) {
4616 // Not public - generate a queueHooks object, or return the current one
4617 _queueHooks: function( elem
, type
) {
4618 var key
= type
+ "queueHooks";
4619 return dataPriv
.get( elem
, key
) || dataPriv
.access( elem
, key
, {
4620 empty: jQuery
.Callbacks( "once memory" ).add( function() {
4621 dataPriv
.remove( elem
, [ type
+ "queue", key
] );
4628 queue: function( type
, data
) {
4631 if ( typeof type
!== "string" ) {
4637 if ( arguments
.length
< setter
) {
4638 return jQuery
.queue( this[ 0 ], type
);
4641 return data
=== undefined ?
4643 this.each( function() {
4644 var queue
= jQuery
.queue( this, type
, data
);
4646 // Ensure a hooks for this queue
4647 jQuery
._queueHooks( this, type
);
4649 if ( type
=== "fx" && queue
[ 0 ] !== "inprogress" ) {
4650 jQuery
.dequeue( this, type
);
4654 dequeue: function( type
) {
4655 return this.each( function() {
4656 jQuery
.dequeue( this, type
);
4659 clearQueue: function( type
) {
4660 return this.queue( type
|| "fx", [] );
4663 // Get a promise resolved when queues of a certain type
4664 // are emptied (fx is the type by default)
4665 promise: function( type
, obj
) {
4668 defer
= jQuery
.Deferred(),
4671 resolve = function() {
4672 if ( !( --count
) ) {
4673 defer
.resolveWith( elements
, [ elements
] );
4677 if ( typeof type
!== "string" ) {
4681 type
= type
|| "fx";
4684 tmp
= dataPriv
.get( elements
[ i
], type
+ "queueHooks" );
4685 if ( tmp
&& tmp
.empty
) {
4687 tmp
.empty
.add( resolve
);
4691 return defer
.promise( obj
);
4694 var pnum
= ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source
;
4696 var rcssNum
= new RegExp( "^(?:([+-])=|)(" + pnum
+ ")([a-z%]*)$", "i" );
4699 var cssExpand
= [ "Top", "Right", "Bottom", "Left" ];
4701 var documentElement
= document
.documentElement
;
4705 var isAttached = function( elem
) {
4706 return jQuery
.contains( elem
.ownerDocument
, elem
);
4708 composed
= { composed: true };
4710 // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
4711 // Check attachment across shadow DOM boundaries when possible (gh-3504)
4712 // Support: iOS 10.0-10.2 only
4713 // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
4714 // leading to errors. We need to check for `getRootNode`.
4715 if ( documentElement
.getRootNode
) {
4716 isAttached = function( elem
) {
4717 return jQuery
.contains( elem
.ownerDocument
, elem
) ||
4718 elem
.getRootNode( composed
) === elem
.ownerDocument
;
4721 var isHiddenWithinTree = function( elem
, el
) {
4723 // isHiddenWithinTree might be called from jQuery#filter function;
4724 // in that case, element will be second argument
4727 // Inline style trumps all
4728 return elem
.style
.display
=== "none" ||
4729 elem
.style
.display
=== "" &&
4731 // Otherwise, check computed style
4732 // Support: Firefox <=43 - 45
4733 // Disconnected elements can have computed display: none, so first confirm that elem is
4735 isAttached( elem
) &&
4737 jQuery
.css( elem
, "display" ) === "none";
4742 function adjustCSS( elem
, prop
, valueParts
, tween
) {
4743 var adjusted
, scale
,
4745 currentValue
= tween
?
4750 return jQuery
.css( elem
, prop
, "" );
4752 initial
= currentValue(),
4753 unit
= valueParts
&& valueParts
[ 3 ] || ( jQuery
.cssNumber
[ prop
] ? "" : "px" ),
4755 // Starting value computation is required for potential unit mismatches
4756 initialInUnit
= elem
.nodeType
&&
4757 ( jQuery
.cssNumber
[ prop
] || unit
!== "px" && +initial
) &&
4758 rcssNum
.exec( jQuery
.css( elem
, prop
) );
4760 if ( initialInUnit
&& initialInUnit
[ 3 ] !== unit
) {
4762 // Support: Firefox <=54
4763 // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
4764 initial
= initial
/ 2;
4766 // Trust units reported by jQuery.css
4767 unit
= unit
|| initialInUnit
[ 3 ];
4769 // Iteratively approximate from a nonzero starting point
4770 initialInUnit
= +initial
|| 1;
4772 while ( maxIterations
-- ) {
4774 // Evaluate and update our best guess (doubling guesses that zero out).
4775 // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
4776 jQuery
.style( elem
, prop
, initialInUnit
+ unit
);
4777 if ( ( 1 - scale
) * ( 1 - ( scale
= currentValue() / initial
|| 0.5 ) ) <= 0 ) {
4780 initialInUnit
= initialInUnit
/ scale
;
4784 initialInUnit
= initialInUnit
* 2;
4785 jQuery
.style( elem
, prop
, initialInUnit
+ unit
);
4787 // Make sure we update the tween properties later on
4788 valueParts
= valueParts
|| [];
4792 initialInUnit
= +initialInUnit
|| +initial
|| 0;
4794 // Apply relative offset (+=/-=) if specified
4795 adjusted
= valueParts
[ 1 ] ?
4796 initialInUnit
+ ( valueParts
[ 1 ] + 1 ) * valueParts
[ 2 ] :
4800 tween
.start
= initialInUnit
;
4801 tween
.end
= adjusted
;
4808 var defaultDisplayMap
= {};
4810 function getDefaultDisplay( elem
) {
4812 doc
= elem
.ownerDocument
,
4813 nodeName
= elem
.nodeName
,
4814 display
= defaultDisplayMap
[ nodeName
];
4820 temp
= doc
.body
.appendChild( doc
.createElement( nodeName
) );
4821 display
= jQuery
.css( temp
, "display" );
4823 temp
.parentNode
.removeChild( temp
);
4825 if ( display
=== "none" ) {
4828 defaultDisplayMap
[ nodeName
] = display
;
4833 function showHide( elements
, show
) {
4837 length
= elements
.length
;
4839 // Determine new display value for elements that need to change
4840 for ( ; index
< length
; index
++ ) {
4841 elem
= elements
[ index
];
4842 if ( !elem
.style
) {
4846 display
= elem
.style
.display
;
4849 // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
4850 // check is required in this first loop unless we have a nonempty display value (either
4851 // inline or about-to-be-restored)
4852 if ( display
=== "none" ) {
4853 values
[ index
] = dataPriv
.get( elem
, "display" ) || null;
4854 if ( !values
[ index
] ) {
4855 elem
.style
.display
= "";
4858 if ( elem
.style
.display
=== "" && isHiddenWithinTree( elem
) ) {
4859 values
[ index
] = getDefaultDisplay( elem
);
4862 if ( display
!== "none" ) {
4863 values
[ index
] = "none";
4865 // Remember what we're overwriting
4866 dataPriv
.set( elem
, "display", display
);
4871 // Set the display of the elements in a second loop to avoid constant reflow
4872 for ( index
= 0; index
< length
; index
++ ) {
4873 if ( values
[ index
] != null ) {
4874 elements
[ index
].style
.display
= values
[ index
];
4883 return showHide( this, true );
4886 return showHide( this );
4888 toggle: function( state
) {
4889 if ( typeof state
=== "boolean" ) {
4890 return state
? this.show() : this.hide();
4893 return this.each( function() {
4894 if ( isHiddenWithinTree( this ) ) {
4895 jQuery( this ).show();
4897 jQuery( this ).hide();
4902 var rcheckableType
= ( /^(?:checkbox|radio)$/i );
4904 var rtagName
= ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
4906 var rscriptType
= ( /^$|^module$|\/(?:java|ecma)script/i );
4911 var fragment
= document
.createDocumentFragment(),
4912 div
= fragment
.appendChild( document
.createElement( "div" ) ),
4913 input
= document
.createElement( "input" );
4915 // Support: Android 4.0 - 4.3 only
4916 // Check state lost if the name is set (#11217)
4917 // Support: Windows Web Apps (WWA)
4918 // `name` and `type` must use .setAttribute for WWA (#14901)
4919 input
.setAttribute( "type", "radio" );
4920 input
.setAttribute( "checked", "checked" );
4921 input
.setAttribute( "name", "t" );
4923 div
.appendChild( input
);
4925 // Support: Android <=4.1 only
4926 // Older WebKit doesn't clone checked state correctly in fragments
4927 support
.checkClone
= div
.cloneNode( true ).cloneNode( true ).lastChild
.checked
;
4929 // Support: IE <=11 only
4930 // Make sure textarea (and checkbox) defaultValue is properly cloned
4931 div
.innerHTML
= "<textarea>x</textarea>";
4932 support
.noCloneChecked
= !!div
.cloneNode( true ).lastChild
.defaultValue
;
4934 // Support: IE <=9 only
4935 // IE <=9 replaces <option> tags with their contents when inserted outside of
4936 // the select element.
4937 div
.innerHTML
= "<option></option>";
4938 support
.option
= !!div
.lastChild
;
4942 // We have to close these tags to support XHTML (#13200)
4945 // XHTML parsers do not magically insert elements in the
4946 // same way that tag soup parsers do. So we cannot shorten
4947 // this by omitting <tbody> or other required elements.
4948 thead: [ 1, "<table>", "</table>" ],
4949 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
4950 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
4951 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
4953 _default: [ 0, "", "" ]
4956 wrapMap
.tbody
= wrapMap
.tfoot
= wrapMap
.colgroup
= wrapMap
.caption
= wrapMap
.thead
;
4957 wrapMap
.th
= wrapMap
.td
;
4959 // Support: IE <=9 only
4960 if ( !support
.option
) {
4961 wrapMap
.optgroup
= wrapMap
.option
= [ 1, "<select multiple='multiple'>", "</select>" ];
4965 function getAll( context
, tag
) {
4967 // Support: IE <=9 - 11 only
4968 // Use typeof to avoid zero-argument method invocation on host objects (#15151)
4971 if ( typeof context
.getElementsByTagName
!== "undefined" ) {
4972 ret
= context
.getElementsByTagName( tag
|| "*" );
4974 } else if ( typeof context
.querySelectorAll
!== "undefined" ) {
4975 ret
= context
.querySelectorAll( tag
|| "*" );
4981 if ( tag
=== undefined || tag
&& nodeName( context
, tag
) ) {
4982 return jQuery
.merge( [ context
], ret
);
4989 // Mark scripts as having already been evaluated
4990 function setGlobalEval( elems
, refElements
) {
4994 for ( ; i
< l
; i
++ ) {
4998 !refElements
|| dataPriv
.get( refElements
[ i
], "globalEval" )
5004 var rhtml
= /<|&#?\w+;/;
5006 function buildFragment( elems
, context
, scripts
, selection
, ignored
) {
5007 var elem
, tmp
, tag
, wrap
, attached
, j
,
5008 fragment
= context
.createDocumentFragment(),
5013 for ( ; i
< l
; i
++ ) {
5016 if ( elem
|| elem
=== 0 ) {
5018 // Add nodes directly
5019 if ( toType( elem
) === "object" ) {
5021 // Support: Android <=4.0 only, PhantomJS 1 only
5022 // push.apply(_, arraylike) throws on ancient WebKit
5023 jQuery
.merge( nodes
, elem
.nodeType
? [ elem
] : elem
);
5025 // Convert non-html into a text node
5026 } else if ( !rhtml
.test( elem
) ) {
5027 nodes
.push( context
.createTextNode( elem
) );
5029 // Convert html into DOM nodes
5031 tmp
= tmp
|| fragment
.appendChild( context
.createElement( "div" ) );
5033 // Deserialize a standard representation
5034 tag
= ( rtagName
.exec( elem
) || [ "", "" ] )[ 1 ].toLowerCase();
5035 wrap
= wrapMap
[ tag
] || wrapMap
._default
;
5036 tmp
.innerHTML
= wrap
[ 1 ] + jQuery
.htmlPrefilter( elem
) + wrap
[ 2 ];
5038 // Descend through wrappers to the right content
5041 tmp
= tmp
.lastChild
;
5044 // Support: Android <=4.0 only, PhantomJS 1 only
5045 // push.apply(_, arraylike) throws on ancient WebKit
5046 jQuery
.merge( nodes
, tmp
.childNodes
);
5048 // Remember the top-level container
5049 tmp
= fragment
.firstChild
;
5051 // Ensure the created nodes are orphaned (#12392)
5052 tmp
.textContent
= "";
5057 // Remove wrapper from fragment
5058 fragment
.textContent
= "";
5061 while ( ( elem
= nodes
[ i
++ ] ) ) {
5063 // Skip elements already in the context collection (trac-4087)
5064 if ( selection
&& jQuery
.inArray( elem
, selection
) > -1 ) {
5066 ignored
.push( elem
);
5071 attached
= isAttached( elem
);
5073 // Append to fragment
5074 tmp
= getAll( fragment
.appendChild( elem
), "script" );
5076 // Preserve script evaluation history
5078 setGlobalEval( tmp
);
5081 // Capture executables
5084 while ( ( elem
= tmp
[ j
++ ] ) ) {
5085 if ( rscriptType
.test( elem
.type
|| "" ) ) {
5086 scripts
.push( elem
);
5096 var rtypenamespace
= /^([^.]*)(?:\.(.+)|)/;
5098 function returnTrue() {
5102 function returnFalse() {
5106 // Support: IE <=9 - 11+
5107 // focus() and blur() are asynchronous, except when they are no-op.
5108 // So expect focus to be synchronous when the element is already active,
5109 // and blur to be synchronous when the element is not already active.
5110 // (focus and blur are always synchronous in other supported browsers,
5111 // this just defines when we can count on it).
5112 function expectSync( elem
, type
) {
5113 return ( elem
=== safeActiveElement() ) === ( type
=== "focus" );
5116 // Support: IE <=9 only
5117 // Accessing document.activeElement can throw unexpectedly
5118 // https://bugs.jquery.com/ticket/13393
5119 function safeActiveElement() {
5121 return document
.activeElement
;
5125 function on( elem
, types
, selector
, data
, fn
, one
) {
5128 // Types can be a map of types/handlers
5129 if ( typeof types
=== "object" ) {
5131 // ( types-Object, selector, data )
5132 if ( typeof selector
!== "string" ) {
5134 // ( types-Object, data )
5135 data
= data
|| selector
;
5136 selector
= undefined;
5138 for ( type
in types
) {
5139 on( elem
, type
, selector
, data
, types
[ type
], one
);
5144 if ( data
== null && fn
== null ) {
5148 data
= selector
= undefined;
5149 } else if ( fn
== null ) {
5150 if ( typeof selector
=== "string" ) {
5152 // ( types, selector, fn )
5157 // ( types, data, fn )
5160 selector
= undefined;
5163 if ( fn
=== false ) {
5171 fn = function( event
) {
5173 // Can use an empty set, since event contains the info
5174 jQuery().off( event
);
5175 return origFn
.apply( this, arguments
);
5178 // Use same guid so caller can remove using origFn
5179 fn
.guid
= origFn
.guid
|| ( origFn
.guid
= jQuery
.guid
++ );
5181 return elem
.each( function() {
5182 jQuery
.event
.add( this, types
, fn
, data
, selector
);
5187 * Helper functions for managing events -- not part of the public interface.
5188 * Props to Dean Edwards' addEvent library for many of the ideas.
5194 add: function( elem
, types
, handler
, data
, selector
) {
5196 var handleObjIn
, eventHandle
, tmp
,
5197 events
, t
, handleObj
,
5198 special
, handlers
, type
, namespaces
, origType
,
5199 elemData
= dataPriv
.get( elem
);
5201 // Only attach events to objects that accept data
5202 if ( !acceptData( elem
) ) {
5206 // Caller can pass in an object of custom data in lieu of the handler
5207 if ( handler
.handler
) {
5208 handleObjIn
= handler
;
5209 handler
= handleObjIn
.handler
;
5210 selector
= handleObjIn
.selector
;
5213 // Ensure that invalid selectors throw exceptions at attach time
5214 // Evaluate against documentElement in case elem is a non-element node (e.g., document)
5216 jQuery
.find
.matchesSelector( documentElement
, selector
);
5219 // Make sure that the handler has a unique ID, used to find/remove it later
5220 if ( !handler
.guid
) {
5221 handler
.guid
= jQuery
.guid
++;
5224 // Init the element's event structure and main handler, if this is the first
5225 if ( !( events
= elemData
.events
) ) {
5226 events
= elemData
.events
= Object
.create( null );
5228 if ( !( eventHandle
= elemData
.handle
) ) {
5229 eventHandle
= elemData
.handle = function( e
) {
5231 // Discard the second event of a jQuery.event.trigger() and
5232 // when an event is called after a page has unloaded
5233 return typeof jQuery
!== "undefined" && jQuery
.event
.triggered
!== e
.type
?
5234 jQuery
.event
.dispatch
.apply( elem
, arguments
) : undefined;
5238 // Handle multiple events separated by a space
5239 types
= ( types
|| "" ).match( rnothtmlwhite
) || [ "" ];
5242 tmp
= rtypenamespace
.exec( types
[ t
] ) || [];
5243 type
= origType
= tmp
[ 1 ];
5244 namespaces
= ( tmp
[ 2 ] || "" ).split( "." ).sort();
5246 // There *must* be a type, no attaching namespace-only handlers
5251 // If event changes its type, use the special event handlers for the changed type
5252 special
= jQuery
.event
.special
[ type
] || {};
5254 // If selector defined, determine special event api type, otherwise given type
5255 type
= ( selector
? special
.delegateType : special
.bindType
) || type
;
5257 // Update special based on newly reset type
5258 special
= jQuery
.event
.special
[ type
] || {};
5260 // handleObj is passed to all event handlers
5261 handleObj
= jQuery
.extend( {
5268 needsContext: selector
&& jQuery
.expr
.match
.needsContext
.test( selector
),
5269 namespace: namespaces
.join( "." )
5272 // Init the event handler queue if we're the first
5273 if ( !( handlers
= events
[ type
] ) ) {
5274 handlers
= events
[ type
] = [];
5275 handlers
.delegateCount
= 0;
5277 // Only use addEventListener if the special events handler returns false
5278 if ( !special
.setup
||
5279 special
.setup
.call( elem
, data
, namespaces
, eventHandle
) === false ) {
5281 if ( elem
.addEventListener
) {
5282 elem
.addEventListener( type
, eventHandle
);
5287 if ( special
.add
) {
5288 special
.add
.call( elem
, handleObj
);
5290 if ( !handleObj
.handler
.guid
) {
5291 handleObj
.handler
.guid
= handler
.guid
;
5295 // Add to the element's handler list, delegates in front
5297 handlers
.splice( handlers
.delegateCount
++, 0, handleObj
);
5299 handlers
.push( handleObj
);
5302 // Keep track of which events have ever been used, for event optimization
5303 jQuery
.event
.global
[ type
] = true;
5308 // Detach an event or set of events from an element
5309 remove: function( elem
, types
, handler
, selector
, mappedTypes
) {
5311 var j
, origCount
, tmp
,
5312 events
, t
, handleObj
,
5313 special
, handlers
, type
, namespaces
, origType
,
5314 elemData
= dataPriv
.hasData( elem
) && dataPriv
.get( elem
);
5316 if ( !elemData
|| !( events
= elemData
.events
) ) {
5320 // Once for each type.namespace in types; type may be omitted
5321 types
= ( types
|| "" ).match( rnothtmlwhite
) || [ "" ];
5324 tmp
= rtypenamespace
.exec( types
[ t
] ) || [];
5325 type
= origType
= tmp
[ 1 ];
5326 namespaces
= ( tmp
[ 2 ] || "" ).split( "." ).sort();
5328 // Unbind all events (on this namespace, if provided) for the element
5330 for ( type
in events
) {
5331 jQuery
.event
.remove( elem
, type
+ types
[ t
], handler
, selector
, true );
5336 special
= jQuery
.event
.special
[ type
] || {};
5337 type
= ( selector
? special
.delegateType : special
.bindType
) || type
;
5338 handlers
= events
[ type
] || [];
5340 new RegExp( "(^|\\.)" + namespaces
.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
5342 // Remove matching events
5343 origCount
= j
= handlers
.length
;
5345 handleObj
= handlers
[ j
];
5347 if ( ( mappedTypes
|| origType
=== handleObj
.origType
) &&
5348 ( !handler
|| handler
.guid
=== handleObj
.guid
) &&
5349 ( !tmp
|| tmp
.test( handleObj
.namespace ) ) &&
5350 ( !selector
|| selector
=== handleObj
.selector
||
5351 selector
=== "**" && handleObj
.selector
) ) {
5352 handlers
.splice( j
, 1 );
5354 if ( handleObj
.selector
) {
5355 handlers
.delegateCount
--;
5357 if ( special
.remove
) {
5358 special
.remove
.call( elem
, handleObj
);
5363 // Remove generic event handler if we removed something and no more handlers exist
5364 // (avoids potential for endless recursion during removal of special event handlers)
5365 if ( origCount
&& !handlers
.length
) {
5366 if ( !special
.teardown
||
5367 special
.teardown
.call( elem
, namespaces
, elemData
.handle
) === false ) {
5369 jQuery
.removeEvent( elem
, type
, elemData
.handle
);
5372 delete events
[ type
];
5376 // Remove data and the expando if it's no longer used
5377 if ( jQuery
.isEmptyObject( events
) ) {
5378 dataPriv
.remove( elem
, "handle events" );
5382 dispatch: function( nativeEvent
) {
5384 var i
, j
, ret
, matched
, handleObj
, handlerQueue
,
5385 args
= new Array( arguments
.length
),
5387 // Make a writable jQuery.Event from the native event object
5388 event
= jQuery
.event
.fix( nativeEvent
),
5391 dataPriv
.get( this, "events" ) || Object
.create( null )
5392 )[ event
.type
] || [],
5393 special
= jQuery
.event
.special
[ event
.type
] || {};
5395 // Use the fix-ed jQuery.Event rather than the (read-only) native event
5398 for ( i
= 1; i
< arguments
.length
; i
++ ) {
5399 args
[ i
] = arguments
[ i
];
5402 event
.delegateTarget
= this;
5404 // Call the preDispatch hook for the mapped type, and let it bail if desired
5405 if ( special
.preDispatch
&& special
.preDispatch
.call( this, event
) === false ) {
5409 // Determine handlers
5410 handlerQueue
= jQuery
.event
.handlers
.call( this, event
, handlers
);
5412 // Run delegates first; they may want to stop propagation beneath us
5414 while ( ( matched
= handlerQueue
[ i
++ ] ) && !event
.isPropagationStopped() ) {
5415 event
.currentTarget
= matched
.elem
;
5418 while ( ( handleObj
= matched
.handlers
[ j
++ ] ) &&
5419 !event
.isImmediatePropagationStopped() ) {
5421 // If the event is namespaced, then each handler is only invoked if it is
5422 // specially universal or its namespaces are a superset of the event's.
5423 if ( !event
.rnamespace
|| handleObj
.namespace === false ||
5424 event
.rnamespace
.test( handleObj
.namespace ) ) {
5426 event
.handleObj
= handleObj
;
5427 event
.data
= handleObj
.data
;
5429 ret
= ( ( jQuery
.event
.special
[ handleObj
.origType
] || {} ).handle
||
5430 handleObj
.handler
).apply( matched
.elem
, args
);
5432 if ( ret
!== undefined ) {
5433 if ( ( event
.result
= ret
) === false ) {
5434 event
.preventDefault();
5435 event
.stopPropagation();
5442 // Call the postDispatch hook for the mapped type
5443 if ( special
.postDispatch
) {
5444 special
.postDispatch
.call( this, event
);
5447 return event
.result
;
5450 handlers: function( event
, handlers
) {
5451 var i
, handleObj
, sel
, matchedHandlers
, matchedSelectors
,
5453 delegateCount
= handlers
.delegateCount
,
5456 // Find delegate handlers
5457 if ( delegateCount
&&
5460 // Black-hole SVG <use> instance trees (trac-13180)
5463 // Support: Firefox <=42
5464 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
5465 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
5466 // Support: IE 11 only
5467 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
5468 !( event
.type
=== "click" && event
.button
>= 1 ) ) {
5470 for ( ; cur
!== this; cur
= cur
.parentNode
|| this ) {
5472 // Don't check non-elements (#13208)
5473 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
5474 if ( cur
.nodeType
=== 1 && !( event
.type
=== "click" && cur
.disabled
=== true ) ) {
5475 matchedHandlers
= [];
5476 matchedSelectors
= {};
5477 for ( i
= 0; i
< delegateCount
; i
++ ) {
5478 handleObj
= handlers
[ i
];
5480 // Don't conflict with Object.prototype properties (#13203)
5481 sel
= handleObj
.selector
+ " ";
5483 if ( matchedSelectors
[ sel
] === undefined ) {
5484 matchedSelectors
[ sel
] = handleObj
.needsContext
?
5485 jQuery( sel
, this ).index( cur
) > -1 :
5486 jQuery
.find( sel
, this, null, [ cur
] ).length
;
5488 if ( matchedSelectors
[ sel
] ) {
5489 matchedHandlers
.push( handleObj
);
5492 if ( matchedHandlers
.length
) {
5493 handlerQueue
.push( { elem: cur
, handlers: matchedHandlers
} );
5499 // Add the remaining (directly-bound) handlers
5501 if ( delegateCount
< handlers
.length
) {
5502 handlerQueue
.push( { elem: cur
, handlers: handlers
.slice( delegateCount
) } );
5505 return handlerQueue
;
5508 addProp: function( name
, hook
) {
5509 Object
.defineProperty( jQuery
.Event
.prototype, name
, {
5513 get: isFunction( hook
) ?
5515 if ( this.originalEvent
) {
5516 return hook( this.originalEvent
);
5520 if ( this.originalEvent
) {
5521 return this.originalEvent
[ name
];
5525 set: function( value
) {
5526 Object
.defineProperty( this, name
, {
5536 fix: function( originalEvent
) {
5537 return originalEvent
[ jQuery
.expando
] ?
5539 new jQuery
.Event( originalEvent
);
5545 // Prevent triggered image.load events from bubbling to window.load
5550 // Utilize native event to ensure correct state for checkable inputs
5551 setup: function( data
) {
5553 // For mutual compressibility with _default, replace `this` access with a local var.
5554 // `|| data` is dead code meant only to preserve the variable through minification.
5555 var el
= this || data
;
5557 // Claim the first handler
5558 if ( rcheckableType
.test( el
.type
) &&
5559 el
.click
&& nodeName( el
, "input" ) ) {
5561 // dataPriv.set( el, "click", ... )
5562 leverageNative( el
, "click", returnTrue
);
5565 // Return false to allow normal processing in the caller
5568 trigger: function( data
) {
5570 // For mutual compressibility with _default, replace `this` access with a local var.
5571 // `|| data` is dead code meant only to preserve the variable through minification.
5572 var el
= this || data
;
5574 // Force setup before triggering a click
5575 if ( rcheckableType
.test( el
.type
) &&
5576 el
.click
&& nodeName( el
, "input" ) ) {
5578 leverageNative( el
, "click" );
5581 // Return non-false to allow normal event-path propagation
5585 // For cross-browser consistency, suppress native .click() on links
5586 // Also prevent it if we're currently inside a leveraged native-event stack
5587 _default: function( event
) {
5588 var target
= event
.target
;
5589 return rcheckableType
.test( target
.type
) &&
5590 target
.click
&& nodeName( target
, "input" ) &&
5591 dataPriv
.get( target
, "click" ) ||
5592 nodeName( target
, "a" );
5597 postDispatch: function( event
) {
5599 // Support: Firefox 20+
5600 // Firefox doesn't alert if the returnValue field is not set.
5601 if ( event
.result
!== undefined && event
.originalEvent
) {
5602 event
.originalEvent
.returnValue
= event
.result
;
5609 // Ensure the presence of an event listener that handles manually-triggered
5610 // synthetic events by interrupting progress until reinvoked in response to
5611 // *native* events that it fires directly, ensuring that state changes have
5612 // already occurred before other listeners are invoked.
5613 function leverageNative( el
, type
, expectSync
) {
5615 // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
5616 if ( !expectSync
) {
5617 if ( dataPriv
.get( el
, type
) === undefined ) {
5618 jQuery
.event
.add( el
, type
, returnTrue
);
5623 // Register the controller as a special universal handler for all event namespaces
5624 dataPriv
.set( el
, type
, false );
5625 jQuery
.event
.add( el
, type
, {
5627 handler: function( event
) {
5628 var notAsync
, result
,
5629 saved
= dataPriv
.get( this, type
);
5631 if ( ( event
.isTrigger
& 1 ) && this[ type
] ) {
5633 // Interrupt processing of the outer synthetic .trigger()ed event
5634 // Saved data should be false in such cases, but might be a leftover capture object
5635 // from an async native handler (gh-4350)
5636 if ( !saved
.length
) {
5638 // Store arguments for use when handling the inner native event
5639 // There will always be at least one argument (an event object), so this array
5640 // will not be confused with a leftover capture object.
5641 saved
= slice
.call( arguments
);
5642 dataPriv
.set( this, type
, saved
);
5644 // Trigger the native event and capture its result
5645 // Support: IE <=9 - 11+
5646 // focus() and blur() are asynchronous
5647 notAsync
= expectSync( this, type
);
5649 result
= dataPriv
.get( this, type
);
5650 if ( saved
!== result
|| notAsync
) {
5651 dataPriv
.set( this, type
, false );
5655 if ( saved
!== result
) {
5657 // Cancel the outer synthetic event
5658 event
.stopImmediatePropagation();
5659 event
.preventDefault();
5661 // Support: Chrome 86+
5662 // In Chrome, if an element having a focusout handler is blurred by
5663 // clicking outside of it, it invokes the handler synchronously. If
5664 // that handler calls `.remove()` on the element, the data is cleared,
5665 // leaving `result` undefined. We need to guard against this.
5666 return result
&& result
.value
;
5669 // If this is an inner synthetic event for an event with a bubbling surrogate
5670 // (focus or blur), assume that the surrogate already propagated from triggering the
5671 // native event and prevent that from happening again here.
5672 // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
5673 // bubbling surrogate propagates *after* the non-bubbling base), but that seems
5674 // less bad than duplication.
5675 } else if ( ( jQuery
.event
.special
[ type
] || {} ).delegateType
) {
5676 event
.stopPropagation();
5679 // If this is a native event triggered above, everything is now in order
5680 // Fire an inner synthetic event with the original arguments
5681 } else if ( saved
.length
) {
5683 // ...and capture the result
5684 dataPriv
.set( this, type
, {
5685 value: jQuery
.event
.trigger(
5687 // Support: IE <=9 - 11+
5688 // Extend with the prototype to reset the above stopImmediatePropagation()
5689 jQuery
.extend( saved
[ 0 ], jQuery
.Event
.prototype ),
5695 // Abort handling of the native event
5696 event
.stopImmediatePropagation();
5702 jQuery
.removeEvent = function( elem
, type
, handle
) {
5704 // This "if" is needed for plain objects
5705 if ( elem
.removeEventListener
) {
5706 elem
.removeEventListener( type
, handle
);
5710 jQuery
.Event = function( src
, props
) {
5712 // Allow instantiation without the 'new' keyword
5713 if ( !( this instanceof jQuery
.Event
) ) {
5714 return new jQuery
.Event( src
, props
);
5718 if ( src
&& src
.type
) {
5719 this.originalEvent
= src
;
5720 this.type
= src
.type
;
5722 // Events bubbling up the document may have been marked as prevented
5723 // by a handler lower down the tree; reflect the correct value.
5724 this.isDefaultPrevented
= src
.defaultPrevented
||
5725 src
.defaultPrevented
=== undefined &&
5727 // Support: Android <=2.3 only
5728 src
.returnValue
=== false ?
5732 // Create target properties
5733 // Support: Safari <=6 - 7 only
5734 // Target should not be a text node (#504, #13143)
5735 this.target
= ( src
.target
&& src
.target
.nodeType
=== 3 ) ?
5736 src
.target
.parentNode :
5739 this.currentTarget
= src
.currentTarget
;
5740 this.relatedTarget
= src
.relatedTarget
;
5747 // Put explicitly provided properties onto the event object
5749 jQuery
.extend( this, props
);
5752 // Create a timestamp if incoming event doesn't have one
5753 this.timeStamp
= src
&& src
.timeStamp
|| Date
.now();
5756 this[ jQuery
.expando
] = true;
5759 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
5760 // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
5761 jQuery
.Event
.prototype = {
5762 constructor: jQuery
.Event
,
5763 isDefaultPrevented: returnFalse
,
5764 isPropagationStopped: returnFalse
,
5765 isImmediatePropagationStopped: returnFalse
,
5768 preventDefault: function() {
5769 var e
= this.originalEvent
;
5771 this.isDefaultPrevented
= returnTrue
;
5773 if ( e
&& !this.isSimulated
) {
5777 stopPropagation: function() {
5778 var e
= this.originalEvent
;
5780 this.isPropagationStopped
= returnTrue
;
5782 if ( e
&& !this.isSimulated
) {
5783 e
.stopPropagation();
5786 stopImmediatePropagation: function() {
5787 var e
= this.originalEvent
;
5789 this.isImmediatePropagationStopped
= returnTrue
;
5791 if ( e
&& !this.isSimulated
) {
5792 e
.stopImmediatePropagation();
5795 this.stopPropagation();
5799 // Includes all common event props including KeyEvent and MouseEvent specific props
5804 changedTouches: true,
5828 targetTouches: true,
5832 }, jQuery
.event
.addProp
);
5834 jQuery
.each( { focus: "focusin", blur: "focusout" }, function( type
, delegateType
) {
5835 jQuery
.event
.special
[ type
] = {
5837 // Utilize native event if possible so blur/focus sequence is correct
5840 // Claim the first handler
5841 // dataPriv.set( this, "focus", ... )
5842 // dataPriv.set( this, "blur", ... )
5843 leverageNative( this, type
, expectSync
);
5845 // Return false to allow normal processing in the caller
5848 trigger: function() {
5850 // Force setup before trigger
5851 leverageNative( this, type
);
5853 // Return non-false to allow normal event-path propagation
5857 // Suppress native focus or blur as it's already being fired
5858 // in leverageNative.
5859 _default: function() {
5863 delegateType: delegateType
5867 // Create mouseenter/leave events using mouseover/out and event-time checks
5868 // so that event delegation works in jQuery.
5869 // Do the same for pointerenter/pointerleave and pointerover/pointerout
5871 // Support: Safari 7 only
5872 // Safari sends mouseenter too often; see:
5873 // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
5874 // for the description of the bug (it existed in older Chrome versions as well).
5876 mouseenter: "mouseover",
5877 mouseleave: "mouseout",
5878 pointerenter: "pointerover",
5879 pointerleave: "pointerout"
5880 }, function( orig
, fix
) {
5881 jQuery
.event
.special
[ orig
] = {
5885 handle: function( event
) {
5888 related
= event
.relatedTarget
,
5889 handleObj
= event
.handleObj
;
5891 // For mouseenter/leave call the handler if related is outside the target.
5892 // NB: No relatedTarget if the mouse left/entered the browser window
5893 if ( !related
|| ( related
!== target
&& !jQuery
.contains( target
, related
) ) ) {
5894 event
.type
= handleObj
.origType
;
5895 ret
= handleObj
.handler
.apply( this, arguments
);
5905 on: function( types
, selector
, data
, fn
) {
5906 return on( this, types
, selector
, data
, fn
);
5908 one: function( types
, selector
, data
, fn
) {
5909 return on( this, types
, selector
, data
, fn
, 1 );
5911 off: function( types
, selector
, fn
) {
5912 var handleObj
, type
;
5913 if ( types
&& types
.preventDefault
&& types
.handleObj
) {
5915 // ( event ) dispatched jQuery.Event
5916 handleObj
= types
.handleObj
;
5917 jQuery( types
.delegateTarget
).off(
5918 handleObj
.namespace ?
5919 handleObj
.origType
+ "." + handleObj
.namespace :
5926 if ( typeof types
=== "object" ) {
5928 // ( types-object [, selector] )
5929 for ( type
in types
) {
5930 this.off( type
, selector
, types
[ type
] );
5934 if ( selector
=== false || typeof selector
=== "function" ) {
5938 selector
= undefined;
5940 if ( fn
=== false ) {
5943 return this.each( function() {
5944 jQuery
.event
.remove( this, types
, fn
, selector
);
5952 // Support: IE <=10 - 11, Edge 12 - 13 only
5953 // In IE/Edge using regex groups here causes severe slowdowns.
5954 // See https://connect.microsoft.com/IE/feedback/details/1736512/
5955 rnoInnerhtml
= /<script|<style|<link/i,
5957 // checked="checked" or checked
5958 rchecked
= /checked\s*(?:[^=]|=\s*.checked.)/i,
5959 rcleanScript
= /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
5961 // Prefer a tbody over its parent table for containing new rows
5962 function manipulationTarget( elem
, content
) {
5963 if ( nodeName( elem
, "table" ) &&
5964 nodeName( content
.nodeType
!== 11 ? content : content
.firstChild
, "tr" ) ) {
5966 return jQuery( elem
).children( "tbody" )[ 0 ] || elem
;
5972 // Replace/restore the type attribute of script elements for safe DOM manipulation
5973 function disableScript( elem
) {
5974 elem
.type
= ( elem
.getAttribute( "type" ) !== null ) + "/" + elem
.type
;
5977 function restoreScript( elem
) {
5978 if ( ( elem
.type
|| "" ).slice( 0, 5 ) === "true/" ) {
5979 elem
.type
= elem
.type
.slice( 5 );
5981 elem
.removeAttribute( "type" );
5987 function cloneCopyEvent( src
, dest
) {
5988 var i
, l
, type
, pdataOld
, udataOld
, udataCur
, events
;
5990 if ( dest
.nodeType
!== 1 ) {
5994 // 1. Copy private data: events, handlers, etc.
5995 if ( dataPriv
.hasData( src
) ) {
5996 pdataOld
= dataPriv
.get( src
);
5997 events
= pdataOld
.events
;
6000 dataPriv
.remove( dest
, "handle events" );
6002 for ( type
in events
) {
6003 for ( i
= 0, l
= events
[ type
].length
; i
< l
; i
++ ) {
6004 jQuery
.event
.add( dest
, type
, events
[ type
][ i
] );
6010 // 2. Copy user data
6011 if ( dataUser
.hasData( src
) ) {
6012 udataOld
= dataUser
.access( src
);
6013 udataCur
= jQuery
.extend( {}, udataOld
);
6015 dataUser
.set( dest
, udataCur
);
6019 // Fix IE bugs, see support tests
6020 function fixInput( src
, dest
) {
6021 var nodeName
= dest
.nodeName
.toLowerCase();
6023 // Fails to persist the checked state of a cloned checkbox or radio button.
6024 if ( nodeName
=== "input" && rcheckableType
.test( src
.type
) ) {
6025 dest
.checked
= src
.checked
;
6027 // Fails to return the selected option to the default selected state when cloning options
6028 } else if ( nodeName
=== "input" || nodeName
=== "textarea" ) {
6029 dest
.defaultValue
= src
.defaultValue
;
6033 function domManip( collection
, args
, callback
, ignored
) {
6035 // Flatten any nested arrays
6036 args
= flat( args
);
6038 var fragment
, first
, scripts
, hasScripts
, node
, doc
,
6040 l
= collection
.length
,
6043 valueIsFunction
= isFunction( value
);
6045 // We can't cloneNode fragments that contain checked, in WebKit
6046 if ( valueIsFunction
||
6047 ( l
> 1 && typeof value
=== "string" &&
6048 !support
.checkClone
&& rchecked
.test( value
) ) ) {
6049 return collection
.each( function( index
) {
6050 var self
= collection
.eq( index
);
6051 if ( valueIsFunction
) {
6052 args
[ 0 ] = value
.call( this, index
, self
.html() );
6054 domManip( self
, args
, callback
, ignored
);
6059 fragment
= buildFragment( args
, collection
[ 0 ].ownerDocument
, false, collection
, ignored
);
6060 first
= fragment
.firstChild
;
6062 if ( fragment
.childNodes
.length
=== 1 ) {
6066 // Require either new content or an interest in ignored elements to invoke the callback
6067 if ( first
|| ignored
) {
6068 scripts
= jQuery
.map( getAll( fragment
, "script" ), disableScript
);
6069 hasScripts
= scripts
.length
;
6071 // Use the original fragment for the last item
6072 // instead of the first because it can end up
6073 // being emptied incorrectly in certain situations (#8070).
6074 for ( ; i
< l
; i
++ ) {
6077 if ( i
!== iNoClone
) {
6078 node
= jQuery
.clone( node
, true, true );
6080 // Keep references to cloned scripts for later restoration
6083 // Support: Android <=4.0 only, PhantomJS 1 only
6084 // push.apply(_, arraylike) throws on ancient WebKit
6085 jQuery
.merge( scripts
, getAll( node
, "script" ) );
6089 callback
.call( collection
[ i
], node
, i
);
6093 doc
= scripts
[ scripts
.length
- 1 ].ownerDocument
;
6096 jQuery
.map( scripts
, restoreScript
);
6098 // Evaluate executable scripts on first document insertion
6099 for ( i
= 0; i
< hasScripts
; i
++ ) {
6100 node
= scripts
[ i
];
6101 if ( rscriptType
.test( node
.type
|| "" ) &&
6102 !dataPriv
.access( node
, "globalEval" ) &&
6103 jQuery
.contains( doc
, node
) ) {
6105 if ( node
.src
&& ( node
.type
|| "" ).toLowerCase() !== "module" ) {
6107 // Optional AJAX dependency, but won't run scripts if not present
6108 if ( jQuery
._evalUrl
&& !node
.noModule
) {
6109 jQuery
._evalUrl( node
.src
, {
6110 nonce: node
.nonce
|| node
.getAttribute( "nonce" )
6114 DOMEval( node
.textContent
.replace( rcleanScript
, "" ), node
, doc
);
6125 function remove( elem
, selector
, keepData
) {
6127 nodes
= selector
? jQuery
.filter( selector
, elem
) : elem
,
6130 for ( ; ( node
= nodes
[ i
] ) != null; i
++ ) {
6131 if ( !keepData
&& node
.nodeType
=== 1 ) {
6132 jQuery
.cleanData( getAll( node
) );
6135 if ( node
.parentNode
) {
6136 if ( keepData
&& isAttached( node
) ) {
6137 setGlobalEval( getAll( node
, "script" ) );
6139 node
.parentNode
.removeChild( node
);
6147 htmlPrefilter: function( html
) {
6151 clone: function( elem
, dataAndEvents
, deepDataAndEvents
) {
6152 var i
, l
, srcElements
, destElements
,
6153 clone
= elem
.cloneNode( true ),
6154 inPage
= isAttached( elem
);
6156 // Fix IE cloning issues
6157 if ( !support
.noCloneChecked
&& ( elem
.nodeType
=== 1 || elem
.nodeType
=== 11 ) &&
6158 !jQuery
.isXMLDoc( elem
) ) {
6160 // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
6161 destElements
= getAll( clone
);
6162 srcElements
= getAll( elem
);
6164 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
6165 fixInput( srcElements
[ i
], destElements
[ i
] );
6169 // Copy the events from the original to the clone
6170 if ( dataAndEvents
) {
6171 if ( deepDataAndEvents
) {
6172 srcElements
= srcElements
|| getAll( elem
);
6173 destElements
= destElements
|| getAll( clone
);
6175 for ( i
= 0, l
= srcElements
.length
; i
< l
; i
++ ) {
6176 cloneCopyEvent( srcElements
[ i
], destElements
[ i
] );
6179 cloneCopyEvent( elem
, clone
);
6183 // Preserve script evaluation history
6184 destElements
= getAll( clone
, "script" );
6185 if ( destElements
.length
> 0 ) {
6186 setGlobalEval( destElements
, !inPage
&& getAll( elem
, "script" ) );
6189 // Return the cloned set
6193 cleanData: function( elems
) {
6194 var data
, elem
, type
,
6195 special
= jQuery
.event
.special
,
6198 for ( ; ( elem
= elems
[ i
] ) !== undefined; i
++ ) {
6199 if ( acceptData( elem
) ) {
6200 if ( ( data
= elem
[ dataPriv
.expando
] ) ) {
6201 if ( data
.events
) {
6202 for ( type
in data
.events
) {
6203 if ( special
[ type
] ) {
6204 jQuery
.event
.remove( elem
, type
);
6206 // This is a shortcut to avoid jQuery.event.remove's overhead
6208 jQuery
.removeEvent( elem
, type
, data
.handle
);
6213 // Support: Chrome <=35 - 45+
6214 // Assign undefined instead of using delete, see Data#remove
6215 elem
[ dataPriv
.expando
] = undefined;
6217 if ( elem
[ dataUser
.expando
] ) {
6219 // Support: Chrome <=35 - 45+
6220 // Assign undefined instead of using delete, see Data#remove
6221 elem
[ dataUser
.expando
] = undefined;
6229 detach: function( selector
) {
6230 return remove( this, selector
, true );
6233 remove: function( selector
) {
6234 return remove( this, selector
);
6237 text: function( value
) {
6238 return access( this, function( value
) {
6239 return value
=== undefined ?
6240 jQuery
.text( this ) :
6241 this.empty().each( function() {
6242 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
6243 this.textContent
= value
;
6246 }, null, value
, arguments
.length
);
6249 append: function() {
6250 return domManip( this, arguments
, function( elem
) {
6251 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
6252 var target
= manipulationTarget( this, elem
);
6253 target
.appendChild( elem
);
6258 prepend: function() {
6259 return domManip( this, arguments
, function( elem
) {
6260 if ( this.nodeType
=== 1 || this.nodeType
=== 11 || this.nodeType
=== 9 ) {
6261 var target
= manipulationTarget( this, elem
);
6262 target
.insertBefore( elem
, target
.firstChild
);
6267 before: function() {
6268 return domManip( this, arguments
, function( elem
) {
6269 if ( this.parentNode
) {
6270 this.parentNode
.insertBefore( elem
, this );
6276 return domManip( this, arguments
, function( elem
) {
6277 if ( this.parentNode
) {
6278 this.parentNode
.insertBefore( elem
, this.nextSibling
);
6287 for ( ; ( elem
= this[ i
] ) != null; i
++ ) {
6288 if ( elem
.nodeType
=== 1 ) {
6290 // Prevent memory leaks
6291 jQuery
.cleanData( getAll( elem
, false ) );
6293 // Remove any remaining nodes
6294 elem
.textContent
= "";
6301 clone: function( dataAndEvents
, deepDataAndEvents
) {
6302 dataAndEvents
= dataAndEvents
== null ? false : dataAndEvents
;
6303 deepDataAndEvents
= deepDataAndEvents
== null ? dataAndEvents : deepDataAndEvents
;
6305 return this.map( function() {
6306 return jQuery
.clone( this, dataAndEvents
, deepDataAndEvents
);
6310 html: function( value
) {
6311 return access( this, function( value
) {
6312 var elem
= this[ 0 ] || {},
6316 if ( value
=== undefined && elem
.nodeType
=== 1 ) {
6317 return elem
.innerHTML
;
6320 // See if we can take a shortcut and just use innerHTML
6321 if ( typeof value
=== "string" && !rnoInnerhtml
.test( value
) &&
6322 !wrapMap
[ ( rtagName
.exec( value
) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
6324 value
= jQuery
.htmlPrefilter( value
);
6327 for ( ; i
< l
; i
++ ) {
6328 elem
= this[ i
] || {};
6330 // Remove element nodes and prevent memory leaks
6331 if ( elem
.nodeType
=== 1 ) {
6332 jQuery
.cleanData( getAll( elem
, false ) );
6333 elem
.innerHTML
= value
;
6339 // If using innerHTML throws an exception, use the fallback method
6344 this.empty().append( value
);
6346 }, null, value
, arguments
.length
);
6349 replaceWith: function() {
6352 // Make the changes, replacing each non-ignored context element with the new content
6353 return domManip( this, arguments
, function( elem
) {
6354 var parent
= this.parentNode
;
6356 if ( jQuery
.inArray( this, ignored
) < 0 ) {
6357 jQuery
.cleanData( getAll( this ) );
6359 parent
.replaceChild( elem
, this );
6363 // Force callback invocation
6370 prependTo: "prepend",
6371 insertBefore: "before",
6372 insertAfter: "after",
6373 replaceAll: "replaceWith"
6374 }, function( name
, original
) {
6375 jQuery
.fn
[ name
] = function( selector
) {
6378 insert
= jQuery( selector
),
6379 last
= insert
.length
- 1,
6382 for ( ; i
<= last
; i
++ ) {
6383 elems
= i
=== last
? this : this.clone( true );
6384 jQuery( insert
[ i
] )[ original
]( elems
);
6386 // Support: Android <=4.0 only, PhantomJS 1 only
6387 // .get() because push.apply(_, arraylike) throws on ancient WebKit
6388 push
.apply( ret
, elems
.get() );
6391 return this.pushStack( ret
);
6394 var rnumnonpx
= new RegExp( "^(" + pnum
+ ")(?!px)[a-z%]+$", "i" );
6396 var getStyles = function( elem
) {
6398 // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
6399 // IE throws on elements created in popups
6400 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
6401 var view
= elem
.ownerDocument
.defaultView
;
6403 if ( !view
|| !view
.opener
) {
6407 return view
.getComputedStyle( elem
);
6410 var swap = function( elem
, options
, callback
) {
6414 // Remember the old values, and insert the new ones
6415 for ( name
in options
) {
6416 old
[ name
] = elem
.style
[ name
];
6417 elem
.style
[ name
] = options
[ name
];
6420 ret
= callback
.call( elem
);
6422 // Revert the old values
6423 for ( name
in options
) {
6424 elem
.style
[ name
] = old
[ name
];
6431 var rboxStyle
= new RegExp( cssExpand
.join( "|" ), "i" );
6437 // Executing both pixelPosition & boxSizingReliable tests require only one layout
6438 // so they're executed at the same time to save the second computation.
6439 function computeStyleTests() {
6441 // This is a singleton, we need to execute it only once
6446 container
.style
.cssText
= "position:absolute;left:-11111px;width:60px;" +
6447 "margin-top:1px;padding:0;border:0";
6449 "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
6450 "margin:auto;border:1px;padding:1px;" +
6452 documentElement
.appendChild( container
).appendChild( div
);
6454 var divStyle
= window
.getComputedStyle( div
);
6455 pixelPositionVal
= divStyle
.top
!== "1%";
6457 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
6458 reliableMarginLeftVal
= roundPixelMeasures( divStyle
.marginLeft
) === 12;
6460 // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
6461 // Some styles come back with percentage values, even though they shouldn't
6462 div
.style
.right
= "60%";
6463 pixelBoxStylesVal
= roundPixelMeasures( divStyle
.right
) === 36;
6465 // Support: IE 9 - 11 only
6466 // Detect misreporting of content dimensions for box-sizing:border-box elements
6467 boxSizingReliableVal
= roundPixelMeasures( divStyle
.width
) === 36;
6469 // Support: IE 9 only
6470 // Detect overflow:scroll screwiness (gh-3699)
6471 // Support: Chrome <=64
6472 // Don't get tricked when zoom affects offsetWidth (gh-4029)
6473 div
.style
.position
= "absolute";
6474 scrollboxSizeVal
= roundPixelMeasures( div
.offsetWidth
/ 3 ) === 12;
6476 documentElement
.removeChild( container
);
6478 // Nullify the div so it wouldn't be stored in the memory and
6479 // it will also be a sign that checks already performed
6483 function roundPixelMeasures( measure
) {
6484 return Math
.round( parseFloat( measure
) );
6487 var pixelPositionVal
, boxSizingReliableVal
, scrollboxSizeVal
, pixelBoxStylesVal
,
6488 reliableTrDimensionsVal
, reliableMarginLeftVal
,
6489 container
= document
.createElement( "div" ),
6490 div
= document
.createElement( "div" );
6492 // Finish early in limited (non-browser) environments
6497 // Support: IE <=9 - 11 only
6498 // Style of cloned element affects source element cloned (#8908)
6499 div
.style
.backgroundClip
= "content-box";
6500 div
.cloneNode( true ).style
.backgroundClip
= "";
6501 support
.clearCloneStyle
= div
.style
.backgroundClip
=== "content-box";
6503 jQuery
.extend( support
, {
6504 boxSizingReliable: function() {
6505 computeStyleTests();
6506 return boxSizingReliableVal
;
6508 pixelBoxStyles: function() {
6509 computeStyleTests();
6510 return pixelBoxStylesVal
;
6512 pixelPosition: function() {
6513 computeStyleTests();
6514 return pixelPositionVal
;
6516 reliableMarginLeft: function() {
6517 computeStyleTests();
6518 return reliableMarginLeftVal
;
6520 scrollboxSize: function() {
6521 computeStyleTests();
6522 return scrollboxSizeVal
;
6525 // Support: IE 9 - 11+, Edge 15 - 18+
6526 // IE/Edge misreport `getComputedStyle` of table rows with width/height
6527 // set in CSS while `offset*` properties report correct values.
6528 // Behavior in IE 9 is more subtle than in newer versions & it passes
6529 // some versions of this test; make sure not to make it pass there!
6531 // Support: Firefox 70+
6532 // Only Firefox includes border widths
6533 // in computed dimensions. (gh-4529)
6534 reliableTrDimensions: function() {
6535 var table
, tr
, trChild
, trStyle
;
6536 if ( reliableTrDimensionsVal
== null ) {
6537 table
= document
.createElement( "table" );
6538 tr
= document
.createElement( "tr" );
6539 trChild
= document
.createElement( "div" );
6541 table
.style
.cssText
= "position:absolute;left:-11111px;border-collapse:separate";
6542 tr
.style
.cssText
= "border:1px solid";
6544 // Support: Chrome 86+
6545 // Height set through cssText does not get applied.
6546 // Computed height then comes back as 0.
6547 tr
.style
.height
= "1px";
6548 trChild
.style
.height
= "9px";
6550 // Support: Android 8 Chrome 86+
6551 // In our bodyBackground.html iframe,
6552 // display for all div elements is set to "inline",
6553 // which causes a problem only in Android 8 Chrome 86.
6554 // Ensuring the div is display: block
6555 // gets around this issue.
6556 trChild
.style
.display
= "block";
6559 .appendChild( table
)
6561 .appendChild( trChild
);
6563 trStyle
= window
.getComputedStyle( tr
);
6564 reliableTrDimensionsVal
= ( parseInt( trStyle
.height
, 10 ) +
6565 parseInt( trStyle
.borderTopWidth
, 10 ) +
6566 parseInt( trStyle
.borderBottomWidth
, 10 ) ) === tr
.offsetHeight
;
6568 documentElement
.removeChild( table
);
6570 return reliableTrDimensionsVal
;
6576 function curCSS( elem
, name
, computed
) {
6577 var width
, minWidth
, maxWidth
, ret
,
6579 // Support: Firefox 51+
6580 // Retrieving style before computed somehow
6581 // fixes an issue with getting wrong values
6582 // on detached elements
6585 computed
= computed
|| getStyles( elem
);
6587 // getPropertyValue is needed for:
6588 // .css('filter') (IE 9 only, #12537)
6589 // .css('--customProperty) (#3144)
6591 ret
= computed
.getPropertyValue( name
) || computed
[ name
];
6593 if ( ret
=== "" && !isAttached( elem
) ) {
6594 ret
= jQuery
.style( elem
, name
);
6597 // A tribute to the "awesome hack by Dean Edwards"
6598 // Android Browser returns percentage for some values,
6599 // but width seems to be reliably pixels.
6600 // This is against the CSSOM draft spec:
6601 // https://drafts.csswg.org/cssom/#resolved-values
6602 if ( !support
.pixelBoxStyles() && rnumnonpx
.test( ret
) && rboxStyle
.test( name
) ) {
6604 // Remember the original values
6605 width
= style
.width
;
6606 minWidth
= style
.minWidth
;
6607 maxWidth
= style
.maxWidth
;
6609 // Put in the new values to get a computed value out
6610 style
.minWidth
= style
.maxWidth
= style
.width
= ret
;
6611 ret
= computed
.width
;
6613 // Revert the changed values
6614 style
.width
= width
;
6615 style
.minWidth
= minWidth
;
6616 style
.maxWidth
= maxWidth
;
6620 return ret
!== undefined ?
6622 // Support: IE <=9 - 11 only
6623 // IE returns zIndex value as an integer.
6629 function addGetHookIf( conditionFn
, hookFn
) {
6631 // Define the hook, we'll check on the first run if it's really needed.
6634 if ( conditionFn() ) {
6636 // Hook not needed (or it's not possible to use it due
6637 // to missing dependency), remove it.
6642 // Hook needed; redefine it so that the support test is not executed again.
6643 return ( this.get = hookFn
).apply( this, arguments
);
6649 var cssPrefixes
= [ "Webkit", "Moz", "ms" ],
6650 emptyStyle
= document
.createElement( "div" ).style
,
6653 // Return a vendor-prefixed property or undefined
6654 function vendorPropName( name
) {
6656 // Check for vendor prefixed names
6657 var capName
= name
[ 0 ].toUpperCase() + name
.slice( 1 ),
6658 i
= cssPrefixes
.length
;
6661 name
= cssPrefixes
[ i
] + capName
;
6662 if ( name
in emptyStyle
) {
6668 // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
6669 function finalPropName( name
) {
6670 var final
= jQuery
.cssProps
[ name
] || vendorProps
[ name
];
6675 if ( name
in emptyStyle
) {
6678 return vendorProps
[ name
] = vendorPropName( name
) || name
;
6684 // Swappable if display is none or starts with table
6685 // except "table", "table-cell", or "table-caption"
6686 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6687 rdisplayswap
= /^(none|table(?!-c[ea]).+)/,
6688 rcustomProp
= /^--/,
6689 cssShow
= { position: "absolute", visibility: "hidden", display: "block" },
6690 cssNormalTransform
= {
6695 function setPositiveNumber( _elem
, value
, subtract
) {
6697 // Any relative (+/-) values have already been
6698 // normalized at this point
6699 var matches
= rcssNum
.exec( value
);
6702 // Guard against undefined "subtract", e.g., when used as in cssHooks
6703 Math
.max( 0, matches
[ 2 ] - ( subtract
|| 0 ) ) + ( matches
[ 3 ] || "px" ) :
6707 function boxModelAdjustment( elem
, dimension
, box
, isBorderBox
, styles
, computedVal
) {
6708 var i
= dimension
=== "width" ? 1 : 0,
6712 // Adjustment may not be necessary
6713 if ( box
=== ( isBorderBox
? "border" : "content" ) ) {
6717 for ( ; i
< 4; i
+= 2 ) {
6719 // Both box models exclude margin
6720 if ( box
=== "margin" ) {
6721 delta
+= jQuery
.css( elem
, box
+ cssExpand
[ i
], true, styles
);
6724 // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
6725 if ( !isBorderBox
) {
6728 delta
+= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
6730 // For "border" or "margin", add border
6731 if ( box
!== "padding" ) {
6732 delta
+= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
6734 // But still keep track of it otherwise
6736 extra
+= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
6739 // If we get here with a border-box (content + padding + border), we're seeking "content" or
6740 // "padding" or "margin"
6743 // For "content", subtract padding
6744 if ( box
=== "content" ) {
6745 delta
-= jQuery
.css( elem
, "padding" + cssExpand
[ i
], true, styles
);
6748 // For "content" or "padding", subtract border
6749 if ( box
!== "margin" ) {
6750 delta
-= jQuery
.css( elem
, "border" + cssExpand
[ i
] + "Width", true, styles
);
6755 // Account for positive content-box scroll gutter when requested by providing computedVal
6756 if ( !isBorderBox
&& computedVal
>= 0 ) {
6758 // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
6759 // Assuming integer scroll gutter, subtract the rest and round down
6760 delta
+= Math
.max( 0, Math
.ceil(
6761 elem
[ "offset" + dimension
[ 0 ].toUpperCase() + dimension
.slice( 1 ) ] -
6767 // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
6768 // Use an explicit zero to avoid NaN (gh-3964)
6775 function getWidthOrHeight( elem
, dimension
, extra
) {
6777 // Start with computed style
6778 var styles
= getStyles( elem
),
6780 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
6781 // Fake content-box until we know it's needed to know the true value.
6782 boxSizingNeeded
= !support
.boxSizingReliable() || extra
,
6783 isBorderBox
= boxSizingNeeded
&&
6784 jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box",
6785 valueIsBorderBox
= isBorderBox
,
6787 val
= curCSS( elem
, dimension
, styles
),
6788 offsetProp
= "offset" + dimension
[ 0 ].toUpperCase() + dimension
.slice( 1 );
6790 // Support: Firefox <=54
6791 // Return a confounding non-pixel value or feign ignorance, as appropriate.
6792 if ( rnumnonpx
.test( val
) ) {
6800 // Support: IE 9 - 11 only
6801 // Use offsetWidth/offsetHeight for when box sizing is unreliable.
6802 // In those cases, the computed value can be trusted to be border-box.
6803 if ( ( !support
.boxSizingReliable() && isBorderBox
||
6805 // Support: IE 10 - 11+, Edge 15 - 18+
6806 // IE/Edge misreport `getComputedStyle` of table rows with width/height
6807 // set in CSS while `offset*` properties report correct values.
6808 // Interestingly, in some cases IE 9 doesn't suffer from this issue.
6809 !support
.reliableTrDimensions() && nodeName( elem
, "tr" ) ||
6811 // Fall back to offsetWidth/offsetHeight when value is "auto"
6812 // This happens for inline elements with no explicit setting (gh-3571)
6815 // Support: Android <=4.1 - 4.3 only
6816 // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
6817 !parseFloat( val
) && jQuery
.css( elem
, "display", false, styles
) === "inline" ) &&
6819 // Make sure the element is visible & connected
6820 elem
.getClientRects().length
) {
6822 isBorderBox
= jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box";
6824 // Where available, offsetWidth/offsetHeight approximate border box dimensions.
6825 // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
6826 // retrieved value as a content box dimension.
6827 valueIsBorderBox
= offsetProp
in elem
;
6828 if ( valueIsBorderBox
) {
6829 val
= elem
[ offsetProp
];
6833 // Normalize "" and auto
6834 val
= parseFloat( val
) || 0;
6836 // Adjust for the element's box model
6841 extra
|| ( isBorderBox
? "border" : "content" ),
6845 // Provide the current computed size to request scroll gutter calculation (gh-3589)
6853 // Add in style property hooks for overriding the default
6854 // behavior of getting and setting a style property
6857 get: function( elem
, computed
) {
6860 // We should always get a number back from opacity
6861 var ret
= curCSS( elem
, "opacity" );
6862 return ret
=== "" ? "1" : ret
;
6868 // Don't automatically add "px" to these possibly-unitless properties
6870 "animationIterationCount": true,
6871 "columnCount": true,
6872 "fillOpacity": true,
6878 "gridColumnEnd": true,
6879 "gridColumnStart": true,
6882 "gridRowStart": true,
6892 // Add in properties whose names you wish to fix before
6893 // setting or getting the value
6896 // Get and set the style property on a DOM Node
6897 style: function( elem
, name
, value
, extra
) {
6899 // Don't set styles on text and comment nodes
6900 if ( !elem
|| elem
.nodeType
=== 3 || elem
.nodeType
=== 8 || !elem
.style
) {
6904 // Make sure that we're working with the right name
6905 var ret
, type
, hooks
,
6906 origName
= camelCase( name
),
6907 isCustomProp
= rcustomProp
.test( name
),
6910 // Make sure that we're working with the right name. We don't
6911 // want to query the value if it is a CSS custom property
6912 // since they are user-defined.
6913 if ( !isCustomProp
) {
6914 name
= finalPropName( origName
);
6917 // Gets hook for the prefixed version, then unprefixed version
6918 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
6920 // Check if we're setting a value
6921 if ( value
!== undefined ) {
6922 type
= typeof value
;
6924 // Convert "+=" or "-=" to relative numbers (#7345)
6925 if ( type
=== "string" && ( ret
= rcssNum
.exec( value
) ) && ret
[ 1 ] ) {
6926 value
= adjustCSS( elem
, name
, ret
);
6932 // Make sure that null and NaN values aren't set (#7116)
6933 if ( value
== null || value
!== value
) {
6937 // If a number was passed in, add the unit (except for certain CSS properties)
6938 // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
6939 // "px" to a few hardcoded values.
6940 if ( type
=== "number" && !isCustomProp
) {
6941 value
+= ret
&& ret
[ 3 ] || ( jQuery
.cssNumber
[ origName
] ? "" : "px" );
6944 // background-* props affect original clone's values
6945 if ( !support
.clearCloneStyle
&& value
=== "" && name
.indexOf( "background" ) === 0 ) {
6946 style
[ name
] = "inherit";
6949 // If a hook was provided, use that value, otherwise just set the specified value
6950 if ( !hooks
|| !( "set" in hooks
) ||
6951 ( value
= hooks
.set( elem
, value
, extra
) ) !== undefined ) {
6953 if ( isCustomProp
) {
6954 style
.setProperty( name
, value
);
6956 style
[ name
] = value
;
6962 // If a hook was provided get the non-computed value from there
6963 if ( hooks
&& "get" in hooks
&&
6964 ( ret
= hooks
.get( elem
, false, extra
) ) !== undefined ) {
6969 // Otherwise just get the value from the style object
6970 return style
[ name
];
6974 css: function( elem
, name
, extra
, styles
) {
6975 var val
, num
, hooks
,
6976 origName
= camelCase( name
),
6977 isCustomProp
= rcustomProp
.test( name
);
6979 // Make sure that we're working with the right name. We don't
6980 // want to modify the value if it is a CSS custom property
6981 // since they are user-defined.
6982 if ( !isCustomProp
) {
6983 name
= finalPropName( origName
);
6986 // Try prefixed name followed by the unprefixed name
6987 hooks
= jQuery
.cssHooks
[ name
] || jQuery
.cssHooks
[ origName
];
6989 // If a hook was provided get the computed value from there
6990 if ( hooks
&& "get" in hooks
) {
6991 val
= hooks
.get( elem
, true, extra
);
6994 // Otherwise, if a way to get the computed value exists, use that
6995 if ( val
=== undefined ) {
6996 val
= curCSS( elem
, name
, styles
);
6999 // Convert "normal" to computed value
7000 if ( val
=== "normal" && name
in cssNormalTransform
) {
7001 val
= cssNormalTransform
[ name
];
7004 // Make numeric if forced or a qualifier was provided and val looks numeric
7005 if ( extra
=== "" || extra
) {
7006 num
= parseFloat( val
);
7007 return extra
=== true || isFinite( num
) ? num
|| 0 : val
;
7014 jQuery
.each( [ "height", "width" ], function( _i
, dimension
) {
7015 jQuery
.cssHooks
[ dimension
] = {
7016 get: function( elem
, computed
, extra
) {
7019 // Certain elements can have dimension info if we invisibly show them
7020 // but it must have a current display style that would benefit
7021 return rdisplayswap
.test( jQuery
.css( elem
, "display" ) ) &&
7023 // Support: Safari 8+
7024 // Table columns in Safari have non-zero offsetWidth & zero
7025 // getBoundingClientRect().width unless display is changed.
7026 // Support: IE <=11 only
7027 // Running getBoundingClientRect on a disconnected node
7028 // in IE throws an error.
7029 ( !elem
.getClientRects().length
|| !elem
.getBoundingClientRect().width
) ?
7030 swap( elem
, cssShow
, function() {
7031 return getWidthOrHeight( elem
, dimension
, extra
);
7033 getWidthOrHeight( elem
, dimension
, extra
);
7037 set: function( elem
, value
, extra
) {
7039 styles
= getStyles( elem
),
7041 // Only read styles.position if the test has a chance to fail
7042 // to avoid forcing a reflow.
7043 scrollboxSizeBuggy
= !support
.scrollboxSize() &&
7044 styles
.position
=== "absolute",
7046 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
7047 boxSizingNeeded
= scrollboxSizeBuggy
|| extra
,
7048 isBorderBox
= boxSizingNeeded
&&
7049 jQuery
.css( elem
, "boxSizing", false, styles
) === "border-box",
7060 // Account for unreliable border-box dimensions by comparing offset* to computed and
7061 // faking a content-box to get border and padding (gh-3699)
7062 if ( isBorderBox
&& scrollboxSizeBuggy
) {
7063 subtract
-= Math
.ceil(
7064 elem
[ "offset" + dimension
[ 0 ].toUpperCase() + dimension
.slice( 1 ) ] -
7065 parseFloat( styles
[ dimension
] ) -
7066 boxModelAdjustment( elem
, dimension
, "border", false, styles
) -
7071 // Convert to pixels if value adjustment is needed
7072 if ( subtract
&& ( matches
= rcssNum
.exec( value
) ) &&
7073 ( matches
[ 3 ] || "px" ) !== "px" ) {
7075 elem
.style
[ dimension
] = value
;
7076 value
= jQuery
.css( elem
, dimension
);
7079 return setPositiveNumber( elem
, value
, subtract
);
7084 jQuery
.cssHooks
.marginLeft
= addGetHookIf( support
.reliableMarginLeft
,
7085 function( elem
, computed
) {
7087 return ( parseFloat( curCSS( elem
, "marginLeft" ) ) ||
7088 elem
.getBoundingClientRect().left
-
7089 swap( elem
, { marginLeft: 0 }, function() {
7090 return elem
.getBoundingClientRect().left
;
7097 // These hooks are used by animate to expand properties
7102 }, function( prefix
, suffix
) {
7103 jQuery
.cssHooks
[ prefix
+ suffix
] = {
7104 expand: function( value
) {
7108 // Assumes a single number if not a string
7109 parts
= typeof value
=== "string" ? value
.split( " " ) : [ value
];
7111 for ( ; i
< 4; i
++ ) {
7112 expanded
[ prefix
+ cssExpand
[ i
] + suffix
] =
7113 parts
[ i
] || parts
[ i
- 2 ] || parts
[ 0 ];
7120 if ( prefix
!== "margin" ) {
7121 jQuery
.cssHooks
[ prefix
+ suffix
].set = setPositiveNumber
;
7126 css: function( name
, value
) {
7127 return access( this, function( elem
, name
, value
) {
7132 if ( Array
.isArray( name
) ) {
7133 styles
= getStyles( elem
);
7136 for ( ; i
< len
; i
++ ) {
7137 map
[ name
[ i
] ] = jQuery
.css( elem
, name
[ i
], false, styles
);
7143 return value
!== undefined ?
7144 jQuery
.style( elem
, name
, value
) :
7145 jQuery
.css( elem
, name
);
7146 }, name
, value
, arguments
.length
> 1 );
7151 function Tween( elem
, options
, prop
, end
, easing
) {
7152 return new Tween
.prototype.init( elem
, options
, prop
, end
, easing
);
7154 jQuery
.Tween
= Tween
;
7158 init: function( elem
, options
, prop
, end
, easing
, unit
) {
7161 this.easing
= easing
|| jQuery
.easing
._default
;
7162 this.options
= options
;
7163 this.start
= this.now
= this.cur();
7165 this.unit
= unit
|| ( jQuery
.cssNumber
[ prop
] ? "" : "px" );
7168 var hooks
= Tween
.propHooks
[ this.prop
];
7170 return hooks
&& hooks
.get ?
7172 Tween
.propHooks
._default
.get( this );
7174 run: function( percent
) {
7176 hooks
= Tween
.propHooks
[ this.prop
];
7178 if ( this.options
.duration
) {
7179 this.pos
= eased
= jQuery
.easing
[ this.easing
](
7180 percent
, this.options
.duration
* percent
, 0, 1, this.options
.duration
7183 this.pos
= eased
= percent
;
7185 this.now
= ( this.end
- this.start
) * eased
+ this.start
;
7187 if ( this.options
.step
) {
7188 this.options
.step
.call( this.elem
, this.now
, this );
7191 if ( hooks
&& hooks
.set ) {
7194 Tween
.propHooks
._default
.set( this );
7200 Tween
.prototype.init
.prototype = Tween
.prototype;
7204 get: function( tween
) {
7207 // Use a property on the element directly when it is not a DOM element,
7208 // or when there is no matching style property that exists.
7209 if ( tween
.elem
.nodeType
!== 1 ||
7210 tween
.elem
[ tween
.prop
] != null && tween
.elem
.style
[ tween
.prop
] == null ) {
7211 return tween
.elem
[ tween
.prop
];
7214 // Passing an empty string as a 3rd parameter to .css will automatically
7215 // attempt a parseFloat and fallback to a string if the parse fails.
7216 // Simple values such as "10px" are parsed to Float;
7217 // complex values such as "rotate(1rad)" are returned as-is.
7218 result
= jQuery
.css( tween
.elem
, tween
.prop
, "" );
7220 // Empty strings, null, undefined and "auto" are converted to 0.
7221 return !result
|| result
=== "auto" ? 0 : result
;
7223 set: function( tween
) {
7225 // Use step hook for back compat.
7226 // Use cssHook if its there.
7227 // Use .style if available and use plain properties where available.
7228 if ( jQuery
.fx
.step
[ tween
.prop
] ) {
7229 jQuery
.fx
.step
[ tween
.prop
]( tween
);
7230 } else if ( tween
.elem
.nodeType
=== 1 && (
7231 jQuery
.cssHooks
[ tween
.prop
] ||
7232 tween
.elem
.style
[ finalPropName( tween
.prop
) ] != null ) ) {
7233 jQuery
.style( tween
.elem
, tween
.prop
, tween
.now
+ tween
.unit
);
7235 tween
.elem
[ tween
.prop
] = tween
.now
;
7241 // Support: IE <=9 only
7242 // Panic based approach to setting things on disconnected nodes
7243 Tween
.propHooks
.scrollTop
= Tween
.propHooks
.scrollLeft
= {
7244 set: function( tween
) {
7245 if ( tween
.elem
.nodeType
&& tween
.elem
.parentNode
) {
7246 tween
.elem
[ tween
.prop
] = tween
.now
;
7252 linear: function( p
) {
7255 swing: function( p
) {
7256 return 0.5 - Math
.cos( p
* Math
.PI
) / 2;
7261 jQuery
.fx
= Tween
.prototype.init
;
7263 // Back compat <1.8 extension point
7264 jQuery
.fx
.step
= {};
7271 rfxtypes
= /^(?:toggle|show|hide)$/,
7272 rrun
= /queueHooks$/;
7274 function schedule() {
7276 if ( document
.hidden
=== false && window
.requestAnimationFrame
) {
7277 window
.requestAnimationFrame( schedule
);
7279 window
.setTimeout( schedule
, jQuery
.fx
.interval
);
7286 // Animations created synchronously will run synchronously
7287 function createFxNow() {
7288 window
.setTimeout( function() {
7291 return ( fxNow
= Date
.now() );
7294 // Generate parameters to create a standard animation
7295 function genFx( type
, includeWidth
) {
7298 attrs
= { height: type
};
7300 // If we include width, step value is 1 to do all cssExpand values,
7301 // otherwise step value is 2 to skip over Left and Right
7302 includeWidth
= includeWidth
? 1 : 0;
7303 for ( ; i
< 4; i
+= 2 - includeWidth
) {
7304 which
= cssExpand
[ i
];
7305 attrs
[ "margin" + which
] = attrs
[ "padding" + which
] = type
;
7308 if ( includeWidth
) {
7309 attrs
.opacity
= attrs
.width
= type
;
7315 function createTween( value
, prop
, animation
) {
7317 collection
= ( Animation
.tweeners
[ prop
] || [] ).concat( Animation
.tweeners
[ "*" ] ),
7319 length
= collection
.length
;
7320 for ( ; index
< length
; index
++ ) {
7321 if ( ( tween
= collection
[ index
].call( animation
, prop
, value
) ) ) {
7323 // We're done with this property
7329 function defaultPrefilter( elem
, props
, opts
) {
7330 var prop
, value
, toggle
, hooks
, oldfire
, propTween
, restoreDisplay
, display
,
7331 isBox
= "width" in props
|| "height" in props
,
7335 hidden
= elem
.nodeType
&& isHiddenWithinTree( elem
),
7336 dataShow
= dataPriv
.get( elem
, "fxshow" );
7338 // Queue-skipping animations hijack the fx hooks
7339 if ( !opts
.queue
) {
7340 hooks
= jQuery
._queueHooks( elem
, "fx" );
7341 if ( hooks
.unqueued
== null ) {
7343 oldfire
= hooks
.empty
.fire
;
7344 hooks
.empty
.fire = function() {
7345 if ( !hooks
.unqueued
) {
7352 anim
.always( function() {
7354 // Ensure the complete handler is called before this completes
7355 anim
.always( function() {
7357 if ( !jQuery
.queue( elem
, "fx" ).length
) {
7364 // Detect show/hide animations
7365 for ( prop
in props
) {
7366 value
= props
[ prop
];
7367 if ( rfxtypes
.test( value
) ) {
7368 delete props
[ prop
];
7369 toggle
= toggle
|| value
=== "toggle";
7370 if ( value
=== ( hidden
? "hide" : "show" ) ) {
7372 // Pretend to be hidden if this is a "show" and
7373 // there is still data from a stopped show/hide
7374 if ( value
=== "show" && dataShow
&& dataShow
[ prop
] !== undefined ) {
7377 // Ignore all other no-op show/hide data
7382 orig
[ prop
] = dataShow
&& dataShow
[ prop
] || jQuery
.style( elem
, prop
);
7386 // Bail out if this is a no-op like .hide().hide()
7387 propTween
= !jQuery
.isEmptyObject( props
);
7388 if ( !propTween
&& jQuery
.isEmptyObject( orig
) ) {
7392 // Restrict "overflow" and "display" styles during box animations
7393 if ( isBox
&& elem
.nodeType
=== 1 ) {
7395 // Support: IE <=9 - 11, Edge 12 - 15
7396 // Record all 3 overflow attributes because IE does not infer the shorthand
7397 // from identically-valued overflowX and overflowY and Edge just mirrors
7398 // the overflowX value there.
7399 opts
.overflow
= [ style
.overflow
, style
.overflowX
, style
.overflowY
];
7401 // Identify a display type, preferring old show/hide data over the CSS cascade
7402 restoreDisplay
= dataShow
&& dataShow
.display
;
7403 if ( restoreDisplay
== null ) {
7404 restoreDisplay
= dataPriv
.get( elem
, "display" );
7406 display
= jQuery
.css( elem
, "display" );
7407 if ( display
=== "none" ) {
7408 if ( restoreDisplay
) {
7409 display
= restoreDisplay
;
7412 // Get nonempty value(s) by temporarily forcing visibility
7413 showHide( [ elem
], true );
7414 restoreDisplay
= elem
.style
.display
|| restoreDisplay
;
7415 display
= jQuery
.css( elem
, "display" );
7416 showHide( [ elem
] );
7420 // Animate inline elements as inline-block
7421 if ( display
=== "inline" || display
=== "inline-block" && restoreDisplay
!= null ) {
7422 if ( jQuery
.css( elem
, "float" ) === "none" ) {
7424 // Restore the original display value at the end of pure show/hide animations
7426 anim
.done( function() {
7427 style
.display
= restoreDisplay
;
7429 if ( restoreDisplay
== null ) {
7430 display
= style
.display
;
7431 restoreDisplay
= display
=== "none" ? "" : display
;
7434 style
.display
= "inline-block";
7439 if ( opts
.overflow
) {
7440 style
.overflow
= "hidden";
7441 anim
.always( function() {
7442 style
.overflow
= opts
.overflow
[ 0 ];
7443 style
.overflowX
= opts
.overflow
[ 1 ];
7444 style
.overflowY
= opts
.overflow
[ 2 ];
7448 // Implement show/hide animations
7450 for ( prop
in orig
) {
7452 // General show/hide setup for this element animation
7455 if ( "hidden" in dataShow
) {
7456 hidden
= dataShow
.hidden
;
7459 dataShow
= dataPriv
.access( elem
, "fxshow", { display: restoreDisplay
} );
7462 // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
7464 dataShow
.hidden
= !hidden
;
7467 // Show elements before animating them
7469 showHide( [ elem
], true );
7472 /* eslint-disable no-loop-func */
7474 anim
.done( function() {
7476 /* eslint-enable no-loop-func */
7478 // The final step of a "hide" animation is actually hiding the element
7480 showHide( [ elem
] );
7482 dataPriv
.remove( elem
, "fxshow" );
7483 for ( prop
in orig
) {
7484 jQuery
.style( elem
, prop
, orig
[ prop
] );
7489 // Per-property setup
7490 propTween
= createTween( hidden
? dataShow
[ prop
] : 0, prop
, anim
);
7491 if ( !( prop
in dataShow
) ) {
7492 dataShow
[ prop
] = propTween
.start
;
7494 propTween
.end
= propTween
.start
;
7495 propTween
.start
= 0;
7501 function propFilter( props
, specialEasing
) {
7502 var index
, name
, easing
, value
, hooks
;
7504 // camelCase, specialEasing and expand cssHook pass
7505 for ( index
in props
) {
7506 name
= camelCase( index
);
7507 easing
= specialEasing
[ name
];
7508 value
= props
[ index
];
7509 if ( Array
.isArray( value
) ) {
7510 easing
= value
[ 1 ];
7511 value
= props
[ index
] = value
[ 0 ];
7514 if ( index
!== name
) {
7515 props
[ name
] = value
;
7516 delete props
[ index
];
7519 hooks
= jQuery
.cssHooks
[ name
];
7520 if ( hooks
&& "expand" in hooks
) {
7521 value
= hooks
.expand( value
);
7522 delete props
[ name
];
7524 // Not quite $.extend, this won't overwrite existing keys.
7525 // Reusing 'index' because we have the correct "name"
7526 for ( index
in value
) {
7527 if ( !( index
in props
) ) {
7528 props
[ index
] = value
[ index
];
7529 specialEasing
[ index
] = easing
;
7533 specialEasing
[ name
] = easing
;
7538 function Animation( elem
, properties
, options
) {
7542 length
= Animation
.prefilters
.length
,
7543 deferred
= jQuery
.Deferred().always( function() {
7545 // Don't match elem in the :animated selector
7552 var currentTime
= fxNow
|| createFxNow(),
7553 remaining
= Math
.max( 0, animation
.startTime
+ animation
.duration
- currentTime
),
7555 // Support: Android 2.3 only
7556 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
7557 temp
= remaining
/ animation
.duration
|| 0,
7560 length
= animation
.tweens
.length
;
7562 for ( ; index
< length
; index
++ ) {
7563 animation
.tweens
[ index
].run( percent
);
7566 deferred
.notifyWith( elem
, [ animation
, percent
, remaining
] );
7568 // If there's more to do, yield
7569 if ( percent
< 1 && length
) {
7573 // If this was an empty animation, synthesize a final progress notification
7575 deferred
.notifyWith( elem
, [ animation
, 1, 0 ] );
7578 // Resolve the animation and report its conclusion
7579 deferred
.resolveWith( elem
, [ animation
] );
7582 animation
= deferred
.promise( {
7584 props: jQuery
.extend( {}, properties
),
7585 opts: jQuery
.extend( true, {
7587 easing: jQuery
.easing
._default
7589 originalProperties: properties
,
7590 originalOptions: options
,
7591 startTime: fxNow
|| createFxNow(),
7592 duration: options
.duration
,
7594 createTween: function( prop
, end
) {
7595 var tween
= jQuery
.Tween( elem
, animation
.opts
, prop
, end
,
7596 animation
.opts
.specialEasing
[ prop
] || animation
.opts
.easing
);
7597 animation
.tweens
.push( tween
);
7600 stop: function( gotoEnd
) {
7603 // If we are going to the end, we want to run all the tweens
7604 // otherwise we skip this part
7605 length
= gotoEnd
? animation
.tweens
.length : 0;
7610 for ( ; index
< length
; index
++ ) {
7611 animation
.tweens
[ index
].run( 1 );
7614 // Resolve when we played the last frame; otherwise, reject
7616 deferred
.notifyWith( elem
, [ animation
, 1, 0 ] );
7617 deferred
.resolveWith( elem
, [ animation
, gotoEnd
] );
7619 deferred
.rejectWith( elem
, [ animation
, gotoEnd
] );
7624 props
= animation
.props
;
7626 propFilter( props
, animation
.opts
.specialEasing
);
7628 for ( ; index
< length
; index
++ ) {
7629 result
= Animation
.prefilters
[ index
].call( animation
, elem
, props
, animation
.opts
);
7631 if ( isFunction( result
.stop
) ) {
7632 jQuery
._queueHooks( animation
.elem
, animation
.opts
.queue
).stop
=
7633 result
.stop
.bind( result
);
7639 jQuery
.map( props
, createTween
, animation
);
7641 if ( isFunction( animation
.opts
.start
) ) {
7642 animation
.opts
.start
.call( elem
, animation
);
7645 // Attach callbacks from options
7647 .progress( animation
.opts
.progress
)
7648 .done( animation
.opts
.done
, animation
.opts
.complete
)
7649 .fail( animation
.opts
.fail
)
7650 .always( animation
.opts
.always
);
7653 jQuery
.extend( tick
, {
7656 queue: animation
.opts
.queue
7663 jQuery
.Animation
= jQuery
.extend( Animation
, {
7666 "*": [ function( prop
, value
) {
7667 var tween
= this.createTween( prop
, value
);
7668 adjustCSS( tween
.elem
, prop
, rcssNum
.exec( value
), tween
);
7673 tweener: function( props
, callback
) {
7674 if ( isFunction( props
) ) {
7678 props
= props
.match( rnothtmlwhite
);
7683 length
= props
.length
;
7685 for ( ; index
< length
; index
++ ) {
7686 prop
= props
[ index
];
7687 Animation
.tweeners
[ prop
] = Animation
.tweeners
[ prop
] || [];
7688 Animation
.tweeners
[ prop
].unshift( callback
);
7692 prefilters: [ defaultPrefilter
],
7694 prefilter: function( callback
, prepend
) {
7696 Animation
.prefilters
.unshift( callback
);
7698 Animation
.prefilters
.push( callback
);
7703 jQuery
.speed = function( speed
, easing
, fn
) {
7704 var opt
= speed
&& typeof speed
=== "object" ? jQuery
.extend( {}, speed
) : {
7705 complete: fn
|| !fn
&& easing
||
7706 isFunction( speed
) && speed
,
7708 easing: fn
&& easing
|| easing
&& !isFunction( easing
) && easing
7711 // Go to the end state if fx are off
7712 if ( jQuery
.fx
.off
) {
7716 if ( typeof opt
.duration
!== "number" ) {
7717 if ( opt
.duration
in jQuery
.fx
.speeds
) {
7718 opt
.duration
= jQuery
.fx
.speeds
[ opt
.duration
];
7721 opt
.duration
= jQuery
.fx
.speeds
._default
;
7726 // Normalize opt.queue - true/undefined/null -> "fx"
7727 if ( opt
.queue
== null || opt
.queue
=== true ) {
7732 opt
.old
= opt
.complete
;
7734 opt
.complete = function() {
7735 if ( isFunction( opt
.old
) ) {
7736 opt
.old
.call( this );
7740 jQuery
.dequeue( this, opt
.queue
);
7748 fadeTo: function( speed
, to
, easing
, callback
) {
7750 // Show any hidden elements after setting opacity to 0
7751 return this.filter( isHiddenWithinTree
).css( "opacity", 0 ).show()
7753 // Animate to the value specified
7754 .end().animate( { opacity: to
}, speed
, easing
, callback
);
7756 animate: function( prop
, speed
, easing
, callback
) {
7757 var empty
= jQuery
.isEmptyObject( prop
),
7758 optall
= jQuery
.speed( speed
, easing
, callback
),
7759 doAnimation = function() {
7761 // Operate on a copy of prop so per-property easing won't be lost
7762 var anim
= Animation( this, jQuery
.extend( {}, prop
), optall
);
7764 // Empty animations, or finishing resolves immediately
7765 if ( empty
|| dataPriv
.get( this, "finish" ) ) {
7770 doAnimation
.finish
= doAnimation
;
7772 return empty
|| optall
.queue
=== false ?
7773 this.each( doAnimation
) :
7774 this.queue( optall
.queue
, doAnimation
);
7776 stop: function( type
, clearQueue
, gotoEnd
) {
7777 var stopQueue = function( hooks
) {
7778 var stop
= hooks
.stop
;
7783 if ( typeof type
!== "string" ) {
7784 gotoEnd
= clearQueue
;
7789 this.queue( type
|| "fx", [] );
7792 return this.each( function() {
7794 index
= type
!= null && type
+ "queueHooks",
7795 timers
= jQuery
.timers
,
7796 data
= dataPriv
.get( this );
7799 if ( data
[ index
] && data
[ index
].stop
) {
7800 stopQueue( data
[ index
] );
7803 for ( index
in data
) {
7804 if ( data
[ index
] && data
[ index
].stop
&& rrun
.test( index
) ) {
7805 stopQueue( data
[ index
] );
7810 for ( index
= timers
.length
; index
--; ) {
7811 if ( timers
[ index
].elem
=== this &&
7812 ( type
== null || timers
[ index
].queue
=== type
) ) {
7814 timers
[ index
].anim
.stop( gotoEnd
);
7816 timers
.splice( index
, 1 );
7820 // Start the next in the queue if the last step wasn't forced.
7821 // Timers currently will call their complete callbacks, which
7822 // will dequeue but only if they were gotoEnd.
7823 if ( dequeue
|| !gotoEnd
) {
7824 jQuery
.dequeue( this, type
);
7828 finish: function( type
) {
7829 if ( type
!== false ) {
7830 type
= type
|| "fx";
7832 return this.each( function() {
7834 data
= dataPriv
.get( this ),
7835 queue
= data
[ type
+ "queue" ],
7836 hooks
= data
[ type
+ "queueHooks" ],
7837 timers
= jQuery
.timers
,
7838 length
= queue
? queue
.length : 0;
7840 // Enable finishing flag on private data
7843 // Empty the queue first
7844 jQuery
.queue( this, type
, [] );
7846 if ( hooks
&& hooks
.stop
) {
7847 hooks
.stop
.call( this, true );
7850 // Look for any active animations, and finish them
7851 for ( index
= timers
.length
; index
--; ) {
7852 if ( timers
[ index
].elem
=== this && timers
[ index
].queue
=== type
) {
7853 timers
[ index
].anim
.stop( true );
7854 timers
.splice( index
, 1 );
7858 // Look for any animations in the old queue and finish them
7859 for ( index
= 0; index
< length
; index
++ ) {
7860 if ( queue
[ index
] && queue
[ index
].finish
) {
7861 queue
[ index
].finish
.call( this );
7865 // Turn off finishing flag
7871 jQuery
.each( [ "toggle", "show", "hide" ], function( _i
, name
) {
7872 var cssFn
= jQuery
.fn
[ name
];
7873 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
7874 return speed
== null || typeof speed
=== "boolean" ?
7875 cssFn
.apply( this, arguments
) :
7876 this.animate( genFx( name
, true ), speed
, easing
, callback
);
7880 // Generate shortcuts for custom animations
7882 slideDown: genFx( "show" ),
7883 slideUp: genFx( "hide" ),
7884 slideToggle: genFx( "toggle" ),
7885 fadeIn: { opacity: "show" },
7886 fadeOut: { opacity: "hide" },
7887 fadeToggle: { opacity: "toggle" }
7888 }, function( name
, props
) {
7889 jQuery
.fn
[ name
] = function( speed
, easing
, callback
) {
7890 return this.animate( props
, speed
, easing
, callback
);
7895 jQuery
.fx
.tick = function() {
7898 timers
= jQuery
.timers
;
7902 for ( ; i
< timers
.length
; i
++ ) {
7903 timer
= timers
[ i
];
7905 // Run the timer and safely remove it when done (allowing for external removal)
7906 if ( !timer() && timers
[ i
] === timer
) {
7907 timers
.splice( i
--, 1 );
7911 if ( !timers
.length
) {
7917 jQuery
.fx
.timer = function( timer
) {
7918 jQuery
.timers
.push( timer
);
7922 jQuery
.fx
.interval
= 13;
7923 jQuery
.fx
.start = function() {
7932 jQuery
.fx
.stop = function() {
7936 jQuery
.fx
.speeds
= {
7945 // Based off of the plugin by Clint Helfers, with permission.
7946 // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
7947 jQuery
.fn
.delay = function( time
, type
) {
7948 time
= jQuery
.fx
? jQuery
.fx
.speeds
[ time
] || time : time
;
7949 type
= type
|| "fx";
7951 return this.queue( type
, function( next
, hooks
) {
7952 var timeout
= window
.setTimeout( next
, time
);
7953 hooks
.stop = function() {
7954 window
.clearTimeout( timeout
);
7961 var input
= document
.createElement( "input" ),
7962 select
= document
.createElement( "select" ),
7963 opt
= select
.appendChild( document
.createElement( "option" ) );
7965 input
.type
= "checkbox";
7967 // Support: Android <=4.3 only
7968 // Default value for a checkbox should be "on"
7969 support
.checkOn
= input
.value
!== "";
7971 // Support: IE <=11 only
7972 // Must access selectedIndex to make default options select
7973 support
.optSelected
= opt
.selected
;
7975 // Support: IE <=11 only
7976 // An input loses its value after becoming a radio
7977 input
= document
.createElement( "input" );
7979 input
.type
= "radio";
7980 support
.radioValue
= input
.value
=== "t";
7985 attrHandle
= jQuery
.expr
.attrHandle
;
7988 attr: function( name
, value
) {
7989 return access( this, jQuery
.attr
, name
, value
, arguments
.length
> 1 );
7992 removeAttr: function( name
) {
7993 return this.each( function() {
7994 jQuery
.removeAttr( this, name
);
8000 attr: function( elem
, name
, value
) {
8002 nType
= elem
.nodeType
;
8004 // Don't get/set attributes on text, comment and attribute nodes
8005 if ( nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
8009 // Fallback to prop when attributes are not supported
8010 if ( typeof elem
.getAttribute
=== "undefined" ) {
8011 return jQuery
.prop( elem
, name
, value
);
8014 // Attribute hooks are determined by the lowercase version
8015 // Grab necessary hook if one is defined
8016 if ( nType
!== 1 || !jQuery
.isXMLDoc( elem
) ) {
8017 hooks
= jQuery
.attrHooks
[ name
.toLowerCase() ] ||
8018 ( jQuery
.expr
.match
.bool
.test( name
) ? boolHook : undefined );
8021 if ( value
!== undefined ) {
8022 if ( value
=== null ) {
8023 jQuery
.removeAttr( elem
, name
);
8027 if ( hooks
&& "set" in hooks
&&
8028 ( ret
= hooks
.set( elem
, value
, name
) ) !== undefined ) {
8032 elem
.setAttribute( name
, value
+ "" );
8036 if ( hooks
&& "get" in hooks
&& ( ret
= hooks
.get( elem
, name
) ) !== null ) {
8040 ret
= jQuery
.find
.attr( elem
, name
);
8042 // Non-existent attributes return null, we normalize to undefined
8043 return ret
== null ? undefined : ret
;
8048 set: function( elem
, value
) {
8049 if ( !support
.radioValue
&& value
=== "radio" &&
8050 nodeName( elem
, "input" ) ) {
8051 var val
= elem
.value
;
8052 elem
.setAttribute( "type", value
);
8062 removeAttr: function( elem
, value
) {
8066 // Attribute names can contain non-HTML whitespace characters
8067 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
8068 attrNames
= value
&& value
.match( rnothtmlwhite
);
8070 if ( attrNames
&& elem
.nodeType
=== 1 ) {
8071 while ( ( name
= attrNames
[ i
++ ] ) ) {
8072 elem
.removeAttribute( name
);
8078 // Hooks for boolean attributes
8080 set: function( elem
, value
, name
) {
8081 if ( value
=== false ) {
8083 // Remove boolean attributes when set to false
8084 jQuery
.removeAttr( elem
, name
);
8086 elem
.setAttribute( name
, name
);
8092 jQuery
.each( jQuery
.expr
.match
.bool
.source
.match( /\w+/g ), function( _i
, name
) {
8093 var getter
= attrHandle
[ name
] || jQuery
.find
.attr
;
8095 attrHandle
[ name
] = function( elem
, name
, isXML
) {
8097 lowercaseName
= name
.toLowerCase();
8101 // Avoid an infinite loop by temporarily removing this function from the getter
8102 handle
= attrHandle
[ lowercaseName
];
8103 attrHandle
[ lowercaseName
] = ret
;
8104 ret
= getter( elem
, name
, isXML
) != null ?
8107 attrHandle
[ lowercaseName
] = handle
;
8116 var rfocusable
= /^(?:input|select|textarea|button)$/i,
8117 rclickable
= /^(?:a|area)$/i;
8120 prop: function( name
, value
) {
8121 return access( this, jQuery
.prop
, name
, value
, arguments
.length
> 1 );
8124 removeProp: function( name
) {
8125 return this.each( function() {
8126 delete this[ jQuery
.propFix
[ name
] || name
];
8132 prop: function( elem
, name
, value
) {
8134 nType
= elem
.nodeType
;
8136 // Don't get/set properties on text, comment and attribute nodes
8137 if ( nType
=== 3 || nType
=== 8 || nType
=== 2 ) {
8141 if ( nType
!== 1 || !jQuery
.isXMLDoc( elem
) ) {
8143 // Fix name and attach hooks
8144 name
= jQuery
.propFix
[ name
] || name
;
8145 hooks
= jQuery
.propHooks
[ name
];
8148 if ( value
!== undefined ) {
8149 if ( hooks
&& "set" in hooks
&&
8150 ( ret
= hooks
.set( elem
, value
, name
) ) !== undefined ) {
8154 return ( elem
[ name
] = value
);
8157 if ( hooks
&& "get" in hooks
&& ( ret
= hooks
.get( elem
, name
) ) !== null ) {
8161 return elem
[ name
];
8166 get: function( elem
) {
8168 // Support: IE <=9 - 11 only
8169 // elem.tabIndex doesn't always return the
8170 // correct value when it hasn't been explicitly set
8171 // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
8172 // Use proper attribute retrieval(#12072)
8173 var tabindex
= jQuery
.find
.attr( elem
, "tabindex" );
8176 return parseInt( tabindex
, 10 );
8180 rfocusable
.test( elem
.nodeName
) ||
8181 rclickable
.test( elem
.nodeName
) &&
8194 "class": "className"
8198 // Support: IE <=11 only
8199 // Accessing the selectedIndex property
8200 // forces the browser to respect setting selected
8202 // The getter ensures a default option is selected
8203 // when in an optgroup
8204 // eslint rule "no-unused-expressions" is disabled for this code
8205 // since it considers such accessions noop
8206 if ( !support
.optSelected
) {
8207 jQuery
.propHooks
.selected
= {
8208 get: function( elem
) {
8210 /* eslint no-unused-expressions: "off" */
8212 var parent
= elem
.parentNode
;
8213 if ( parent
&& parent
.parentNode
) {
8214 parent
.parentNode
.selectedIndex
;
8218 set: function( elem
) {
8220 /* eslint no-unused-expressions: "off" */
8222 var parent
= elem
.parentNode
;
8224 parent
.selectedIndex
;
8226 if ( parent
.parentNode
) {
8227 parent
.parentNode
.selectedIndex
;
8246 jQuery
.propFix
[ this.toLowerCase() ] = this;
8252 // Strip and collapse whitespace according to HTML spec
8253 // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
8254 function stripAndCollapse( value
) {
8255 var tokens
= value
.match( rnothtmlwhite
) || [];
8256 return tokens
.join( " " );
8260 function getClass( elem
) {
8261 return elem
.getAttribute
&& elem
.getAttribute( "class" ) || "";
8264 function classesToArray( value
) {
8265 if ( Array
.isArray( value
) ) {
8268 if ( typeof value
=== "string" ) {
8269 return value
.match( rnothtmlwhite
) || [];
8275 addClass: function( value
) {
8276 var classes
, elem
, cur
, curValue
, clazz
, j
, finalValue
,
8279 if ( isFunction( value
) ) {
8280 return this.each( function( j
) {
8281 jQuery( this ).addClass( value
.call( this, j
, getClass( this ) ) );
8285 classes
= classesToArray( value
);
8287 if ( classes
.length
) {
8288 while ( ( elem
= this[ i
++ ] ) ) {
8289 curValue
= getClass( elem
);
8290 cur
= elem
.nodeType
=== 1 && ( " " + stripAndCollapse( curValue
) + " " );
8294 while ( ( clazz
= classes
[ j
++ ] ) ) {
8295 if ( cur
.indexOf( " " + clazz
+ " " ) < 0 ) {
8300 // Only assign if different to avoid unneeded rendering.
8301 finalValue
= stripAndCollapse( cur
);
8302 if ( curValue
!== finalValue
) {
8303 elem
.setAttribute( "class", finalValue
);
8312 removeClass: function( value
) {
8313 var classes
, elem
, cur
, curValue
, clazz
, j
, finalValue
,
8316 if ( isFunction( value
) ) {
8317 return this.each( function( j
) {
8318 jQuery( this ).removeClass( value
.call( this, j
, getClass( this ) ) );
8322 if ( !arguments
.length
) {
8323 return this.attr( "class", "" );
8326 classes
= classesToArray( value
);
8328 if ( classes
.length
) {
8329 while ( ( elem
= this[ i
++ ] ) ) {
8330 curValue
= getClass( elem
);
8332 // This expression is here for better compressibility (see addClass)
8333 cur
= elem
.nodeType
=== 1 && ( " " + stripAndCollapse( curValue
) + " " );
8337 while ( ( clazz
= classes
[ j
++ ] ) ) {
8339 // Remove *all* instances
8340 while ( cur
.indexOf( " " + clazz
+ " " ) > -1 ) {
8341 cur
= cur
.replace( " " + clazz
+ " ", " " );
8345 // Only assign if different to avoid unneeded rendering.
8346 finalValue
= stripAndCollapse( cur
);
8347 if ( curValue
!== finalValue
) {
8348 elem
.setAttribute( "class", finalValue
);
8357 toggleClass: function( value
, stateVal
) {
8358 var type
= typeof value
,
8359 isValidValue
= type
=== "string" || Array
.isArray( value
);
8361 if ( typeof stateVal
=== "boolean" && isValidValue
) {
8362 return stateVal
? this.addClass( value
) : this.removeClass( value
);
8365 if ( isFunction( value
) ) {
8366 return this.each( function( i
) {
8367 jQuery( this ).toggleClass(
8368 value
.call( this, i
, getClass( this ), stateVal
),
8374 return this.each( function() {
8375 var className
, i
, self
, classNames
;
8377 if ( isValidValue
) {
8379 // Toggle individual class names
8381 self
= jQuery( this );
8382 classNames
= classesToArray( value
);
8384 while ( ( className
= classNames
[ i
++ ] ) ) {
8386 // Check each className given, space separated list
8387 if ( self
.hasClass( className
) ) {
8388 self
.removeClass( className
);
8390 self
.addClass( className
);
8394 // Toggle whole class name
8395 } else if ( value
=== undefined || type
=== "boolean" ) {
8396 className
= getClass( this );
8399 // Store className if set
8400 dataPriv
.set( this, "__className__", className
);
8403 // If the element has a class name or if we're passed `false`,
8404 // then remove the whole classname (if there was one, the above saved it).
8405 // Otherwise bring back whatever was previously saved (if anything),
8406 // falling back to the empty string if nothing was stored.
8407 if ( this.setAttribute
) {
8408 this.setAttribute( "class",
8409 className
|| value
=== false ?
8411 dataPriv
.get( this, "__className__" ) || ""
8418 hasClass: function( selector
) {
8419 var className
, elem
,
8422 className
= " " + selector
+ " ";
8423 while ( ( elem
= this[ i
++ ] ) ) {
8424 if ( elem
.nodeType
=== 1 &&
8425 ( " " + stripAndCollapse( getClass( elem
) ) + " " ).indexOf( className
) > -1 ) {
8437 var rreturn
= /\r/g;
8440 val: function( value
) {
8441 var hooks
, ret
, valueIsFunction
,
8444 if ( !arguments
.length
) {
8446 hooks
= jQuery
.valHooks
[ elem
.type
] ||
8447 jQuery
.valHooks
[ elem
.nodeName
.toLowerCase() ];
8451 ( ret
= hooks
.get( elem
, "value" ) ) !== undefined
8458 // Handle most common string cases
8459 if ( typeof ret
=== "string" ) {
8460 return ret
.replace( rreturn
, "" );
8463 // Handle cases where value is null/undef or number
8464 return ret
== null ? "" : ret
;
8470 valueIsFunction
= isFunction( value
);
8472 return this.each( function( i
) {
8475 if ( this.nodeType
!== 1 ) {
8479 if ( valueIsFunction
) {
8480 val
= value
.call( this, i
, jQuery( this ).val() );
8485 // Treat null/undefined as ""; convert numbers to string
8486 if ( val
== null ) {
8489 } else if ( typeof val
=== "number" ) {
8492 } else if ( Array
.isArray( val
) ) {
8493 val
= jQuery
.map( val
, function( value
) {
8494 return value
== null ? "" : value
+ "";
8498 hooks
= jQuery
.valHooks
[ this.type
] || jQuery
.valHooks
[ this.nodeName
.toLowerCase() ];
8500 // If set returns undefined, fall back to normal setting
8501 if ( !hooks
|| !( "set" in hooks
) || hooks
.set( this, val
, "value" ) === undefined ) {
8511 get: function( elem
) {
8513 var val
= jQuery
.find
.attr( elem
, "value" );
8514 return val
!= null ?
8517 // Support: IE <=10 - 11 only
8518 // option.text throws exceptions (#14686, #14858)
8519 // Strip and collapse whitespace
8520 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
8521 stripAndCollapse( jQuery
.text( elem
) );
8525 get: function( elem
) {
8526 var value
, option
, i
,
8527 options
= elem
.options
,
8528 index
= elem
.selectedIndex
,
8529 one
= elem
.type
=== "select-one",
8530 values
= one
? null : [],
8531 max
= one
? index
+ 1 : options
.length
;
8537 i
= one
? index : 0;
8540 // Loop through all the selected options
8541 for ( ; i
< max
; i
++ ) {
8542 option
= options
[ i
];
8544 // Support: IE <=9 only
8545 // IE8-9 doesn't update selected after form reset (#2551)
8546 if ( ( option
.selected
|| i
=== index
) &&
8548 // Don't return options that are disabled or in a disabled optgroup
8550 ( !option
.parentNode
.disabled
||
8551 !nodeName( option
.parentNode
, "optgroup" ) ) ) {
8553 // Get the specific value for the option
8554 value
= jQuery( option
).val();
8556 // We don't need an array for one selects
8561 // Multi-Selects return an array
8562 values
.push( value
);
8569 set: function( elem
, value
) {
8570 var optionSet
, option
,
8571 options
= elem
.options
,
8572 values
= jQuery
.makeArray( value
),
8576 option
= options
[ i
];
8578 /* eslint-disable no-cond-assign */
8580 if ( option
.selected
=
8581 jQuery
.inArray( jQuery
.valHooks
.option
.get( option
), values
) > -1
8586 /* eslint-enable no-cond-assign */
8589 // Force browsers to behave consistently when non-matching value is set
8591 elem
.selectedIndex
= -1;
8599 // Radios and checkboxes getter/setter
8600 jQuery
.each( [ "radio", "checkbox" ], function() {
8601 jQuery
.valHooks
[ this ] = {
8602 set: function( elem
, value
) {
8603 if ( Array
.isArray( value
) ) {
8604 return ( elem
.checked
= jQuery
.inArray( jQuery( elem
).val(), value
) > -1 );
8608 if ( !support
.checkOn
) {
8609 jQuery
.valHooks
[ this ].get = function( elem
) {
8610 return elem
.getAttribute( "value" ) === null ? "on" : elem
.value
;
8618 // Return jQuery for attributes-only inclusion
8621 support
.focusin
= "onfocusin" in window
;
8624 var rfocusMorph
= /^(?:focusinfocus|focusoutblur)$/,
8625 stopPropagationCallback = function( e
) {
8626 e
.stopPropagation();
8629 jQuery
.extend( jQuery
.event
, {
8631 trigger: function( event
, data
, elem
, onlyHandlers
) {
8633 var i
, cur
, tmp
, bubbleType
, ontype
, handle
, special
, lastElement
,
8634 eventPath
= [ elem
|| document
],
8635 type
= hasOwn
.call( event
, "type" ) ? event
.type : event
,
8636 namespaces
= hasOwn
.call( event
, "namespace" ) ? event
.namespace.split( "." ) : [];
8638 cur
= lastElement
= tmp
= elem
= elem
|| document
;
8640 // Don't do events on text and comment nodes
8641 if ( elem
.nodeType
=== 3 || elem
.nodeType
=== 8 ) {
8645 // focus/blur morphs to focusin/out; ensure we're not firing them right now
8646 if ( rfocusMorph
.test( type
+ jQuery
.event
.triggered
) ) {
8650 if ( type
.indexOf( "." ) > -1 ) {
8652 // Namespaced trigger; create a regexp to match event type in handle()
8653 namespaces
= type
.split( "." );
8654 type
= namespaces
.shift();
8657 ontype
= type
.indexOf( ":" ) < 0 && "on" + type
;
8659 // Caller can pass in a jQuery.Event object, Object, or just an event type string
8660 event
= event
[ jQuery
.expando
] ?
8662 new jQuery
.Event( type
, typeof event
=== "object" && event
);
8664 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
8665 event
.isTrigger
= onlyHandlers
? 2 : 3;
8666 event
.namespace = namespaces
.join( "." );
8667 event
.rnamespace
= event
.namespace ?
8668 new RegExp( "(^|\\.)" + namespaces
.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
8671 // Clean up the event in case it is being reused
8672 event
.result
= undefined;
8673 if ( !event
.target
) {
8674 event
.target
= elem
;
8677 // Clone any incoming data and prepend the event, creating the handler arg list
8678 data
= data
== null ?
8680 jQuery
.makeArray( data
, [ event
] );
8682 // Allow special events to draw outside the lines
8683 special
= jQuery
.event
.special
[ type
] || {};
8684 if ( !onlyHandlers
&& special
.trigger
&& special
.trigger
.apply( elem
, data
) === false ) {
8688 // Determine event propagation path in advance, per W3C events spec (#9951)
8689 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
8690 if ( !onlyHandlers
&& !special
.noBubble
&& !isWindow( elem
) ) {
8692 bubbleType
= special
.delegateType
|| type
;
8693 if ( !rfocusMorph
.test( bubbleType
+ type
) ) {
8694 cur
= cur
.parentNode
;
8696 for ( ; cur
; cur
= cur
.parentNode
) {
8697 eventPath
.push( cur
);
8701 // Only add window if we got to document (e.g., not plain obj or detached DOM)
8702 if ( tmp
=== ( elem
.ownerDocument
|| document
) ) {
8703 eventPath
.push( tmp
.defaultView
|| tmp
.parentWindow
|| window
);
8707 // Fire handlers on the event path
8709 while ( ( cur
= eventPath
[ i
++ ] ) && !event
.isPropagationStopped() ) {
8711 event
.type
= i
> 1 ?
8713 special
.bindType
|| type
;
8716 handle
= ( dataPriv
.get( cur
, "events" ) || Object
.create( null ) )[ event
.type
] &&
8717 dataPriv
.get( cur
, "handle" );
8719 handle
.apply( cur
, data
);
8723 handle
= ontype
&& cur
[ ontype
];
8724 if ( handle
&& handle
.apply
&& acceptData( cur
) ) {
8725 event
.result
= handle
.apply( cur
, data
);
8726 if ( event
.result
=== false ) {
8727 event
.preventDefault();
8733 // If nobody prevented the default action, do it now
8734 if ( !onlyHandlers
&& !event
.isDefaultPrevented() ) {
8736 if ( ( !special
._default
||
8737 special
._default
.apply( eventPath
.pop(), data
) === false ) &&
8738 acceptData( elem
) ) {
8740 // Call a native DOM method on the target with the same name as the event.
8741 // Don't do default actions on window, that's where global variables be (#6170)
8742 if ( ontype
&& isFunction( elem
[ type
] ) && !isWindow( elem
) ) {
8744 // Don't re-trigger an onFOO event when we call its FOO() method
8745 tmp
= elem
[ ontype
];
8748 elem
[ ontype
] = null;
8751 // Prevent re-triggering of the same event, since we already bubbled it above
8752 jQuery
.event
.triggered
= type
;
8754 if ( event
.isPropagationStopped() ) {
8755 lastElement
.addEventListener( type
, stopPropagationCallback
);
8760 if ( event
.isPropagationStopped() ) {
8761 lastElement
.removeEventListener( type
, stopPropagationCallback
);
8764 jQuery
.event
.triggered
= undefined;
8767 elem
[ ontype
] = tmp
;
8773 return event
.result
;
8776 // Piggyback on a donor event to simulate a different one
8777 // Used only for `focus(in | out)` events
8778 simulate: function( type
, elem
, event
) {
8779 var e
= jQuery
.extend(
8788 jQuery
.event
.trigger( e
, null, elem
);
8795 trigger: function( type
, data
) {
8796 return this.each( function() {
8797 jQuery
.event
.trigger( type
, data
, this );
8800 triggerHandler: function( type
, data
) {
8801 var elem
= this[ 0 ];
8803 return jQuery
.event
.trigger( type
, data
, elem
, true );
8809 // Support: Firefox <=44
8810 // Firefox doesn't have focus(in | out) events
8811 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
8813 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
8814 // focus(in | out) events fire after focus & blur events,
8815 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
8816 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
8817 if ( !support
.focusin
) {
8818 jQuery
.each( { focus: "focusin", blur: "focusout" }, function( orig
, fix
) {
8820 // Attach a single capturing handler on the document while someone wants focusin/focusout
8821 var handler = function( event
) {
8822 jQuery
.event
.simulate( fix
, event
.target
, jQuery
.event
.fix( event
) );
8825 jQuery
.event
.special
[ fix
] = {
8828 // Handle: regular nodes (via `this.ownerDocument`), window
8829 // (via `this.document`) & document (via `this`).
8830 var doc
= this.ownerDocument
|| this.document
|| this,
8831 attaches
= dataPriv
.access( doc
, fix
);
8834 doc
.addEventListener( orig
, handler
, true );
8836 dataPriv
.access( doc
, fix
, ( attaches
|| 0 ) + 1 );
8838 teardown: function() {
8839 var doc
= this.ownerDocument
|| this.document
|| this,
8840 attaches
= dataPriv
.access( doc
, fix
) - 1;
8843 doc
.removeEventListener( orig
, handler
, true );
8844 dataPriv
.remove( doc
, fix
);
8847 dataPriv
.access( doc
, fix
, attaches
);
8853 var location
= window
.location
;
8855 var nonce
= { guid: Date
.now() };
8857 var rquery
= ( /\?/ );
8861 // Cross-browser xml parsing
8862 jQuery
.parseXML = function( data
) {
8863 var xml
, parserErrorElem
;
8864 if ( !data
|| typeof data
!== "string" ) {
8868 // Support: IE 9 - 11 only
8869 // IE throws on parseFromString with invalid input.
8871 xml
= ( new window
.DOMParser() ).parseFromString( data
, "text/xml" );
8874 parserErrorElem
= xml
&& xml
.getElementsByTagName( "parsererror" )[ 0 ];
8875 if ( !xml
|| parserErrorElem
) {
8876 jQuery
.error( "Invalid XML: " + (
8878 jQuery
.map( parserErrorElem
.childNodes
, function( el
) {
8879 return el
.textContent
;
8891 rsubmitterTypes
= /^(?:submit|button|image|reset|file)$/i,
8892 rsubmittable
= /^(?:input|select|textarea|keygen)/i;
8894 function buildParams( prefix
, obj
, traditional
, add
) {
8897 if ( Array
.isArray( obj
) ) {
8899 // Serialize array item.
8900 jQuery
.each( obj
, function( i
, v
) {
8901 if ( traditional
|| rbracket
.test( prefix
) ) {
8903 // Treat each array item as a scalar.
8908 // Item is non-scalar (array or object), encode its numeric index.
8910 prefix
+ "[" + ( typeof v
=== "object" && v
!= null ? i : "" ) + "]",
8918 } else if ( !traditional
&& toType( obj
) === "object" ) {
8920 // Serialize object item.
8921 for ( name
in obj
) {
8922 buildParams( prefix
+ "[" + name
+ "]", obj
[ name
], traditional
, add
);
8927 // Serialize scalar item.
8932 // Serialize an array of form elements or a set of
8933 // key/values into a query string
8934 jQuery
.param = function( a
, traditional
) {
8937 add = function( key
, valueOrFunction
) {
8939 // If value is a function, invoke it and use its return value
8940 var value
= isFunction( valueOrFunction
) ?
8944 s
[ s
.length
] = encodeURIComponent( key
) + "=" +
8945 encodeURIComponent( value
== null ? "" : value
);
8952 // If an array was passed in, assume that it is an array of form elements.
8953 if ( Array
.isArray( a
) || ( a
.jquery
&& !jQuery
.isPlainObject( a
) ) ) {
8955 // Serialize the form elements
8956 jQuery
.each( a
, function() {
8957 add( this.name
, this.value
);
8962 // If traditional, encode the "old" way (the way 1.3.2 or older
8963 // did it), otherwise encode params recursively.
8964 for ( prefix
in a
) {
8965 buildParams( prefix
, a
[ prefix
], traditional
, add
);
8969 // Return the resulting serialization
8970 return s
.join( "&" );
8974 serialize: function() {
8975 return jQuery
.param( this.serializeArray() );
8977 serializeArray: function() {
8978 return this.map( function() {
8980 // Can add propHook for "elements" to filter or add form elements
8981 var elements
= jQuery
.prop( this, "elements" );
8982 return elements
? jQuery
.makeArray( elements
) : this;
8983 } ).filter( function() {
8984 var type
= this.type
;
8986 // Use .is( ":disabled" ) so that fieldset[disabled] works
8987 return this.name
&& !jQuery( this ).is( ":disabled" ) &&
8988 rsubmittable
.test( this.nodeName
) && !rsubmitterTypes
.test( type
) &&
8989 ( this.checked
|| !rcheckableType
.test( type
) );
8990 } ).map( function( _i
, elem
) {
8991 var val
= jQuery( this ).val();
8993 if ( val
== null ) {
8997 if ( Array
.isArray( val
) ) {
8998 return jQuery
.map( val
, function( val
) {
8999 return { name: elem
.name
, value: val
.replace( rCRLF
, "\r\n" ) };
9003 return { name: elem
.name
, value: val
.replace( rCRLF
, "\r\n" ) };
9012 rantiCache
= /([?&])_=[^&]*/,
9013 rheaders
= /^(.*?):[ \t]*([^\r\n]*)$/mg
,
9015 // #7653, #8125, #8152: local protocol detection
9016 rlocalProtocol
= /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
9017 rnoContent
= /^(?:GET|HEAD)$/,
9018 rprotocol
= /^\/\//,
9021 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
9022 * 2) These are called:
9023 * - BEFORE asking for a transport
9024 * - AFTER param serialization (s.data is a string if s.processData is true)
9025 * 3) key is the dataType
9026 * 4) the catchall symbol "*" can be used
9027 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
9031 /* Transports bindings
9032 * 1) key is the dataType
9033 * 2) the catchall symbol "*" can be used
9034 * 3) selection will start with transport dataType and THEN go to "*" if needed
9038 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
9039 allTypes
= "*/".concat( "*" ),
9041 // Anchor tag for parsing the document origin
9042 originAnchor
= document
.createElement( "a" );
9044 originAnchor
.href
= location
.href
;
9046 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
9047 function addToPrefiltersOrTransports( structure
) {
9049 // dataTypeExpression is optional and defaults to "*"
9050 return function( dataTypeExpression
, func
) {
9052 if ( typeof dataTypeExpression
!== "string" ) {
9053 func
= dataTypeExpression
;
9054 dataTypeExpression
= "*";
9059 dataTypes
= dataTypeExpression
.toLowerCase().match( rnothtmlwhite
) || [];
9061 if ( isFunction( func
) ) {
9063 // For each dataType in the dataTypeExpression
9064 while ( ( dataType
= dataTypes
[ i
++ ] ) ) {
9066 // Prepend if requested
9067 if ( dataType
[ 0 ] === "+" ) {
9068 dataType
= dataType
.slice( 1 ) || "*";
9069 ( structure
[ dataType
] = structure
[ dataType
] || [] ).unshift( func
);
9073 ( structure
[ dataType
] = structure
[ dataType
] || [] ).push( func
);
9080 // Base inspection function for prefilters and transports
9081 function inspectPrefiltersOrTransports( structure
, options
, originalOptions
, jqXHR
) {
9084 seekingTransport
= ( structure
=== transports
);
9086 function inspect( dataType
) {
9088 inspected
[ dataType
] = true;
9089 jQuery
.each( structure
[ dataType
] || [], function( _
, prefilterOrFactory
) {
9090 var dataTypeOrTransport
= prefilterOrFactory( options
, originalOptions
, jqXHR
);
9091 if ( typeof dataTypeOrTransport
=== "string" &&
9092 !seekingTransport
&& !inspected
[ dataTypeOrTransport
] ) {
9094 options
.dataTypes
.unshift( dataTypeOrTransport
);
9095 inspect( dataTypeOrTransport
);
9097 } else if ( seekingTransport
) {
9098 return !( selected
= dataTypeOrTransport
);
9104 return inspect( options
.dataTypes
[ 0 ] ) || !inspected
[ "*" ] && inspect( "*" );
9107 // A special extend for ajax options
9108 // that takes "flat" options (not to be deep extended)
9110 function ajaxExtend( target
, src
) {
9112 flatOptions
= jQuery
.ajaxSettings
.flatOptions
|| {};
9114 for ( key
in src
) {
9115 if ( src
[ key
] !== undefined ) {
9116 ( flatOptions
[ key
] ? target : ( deep
|| ( deep
= {} ) ) )[ key
] = src
[ key
];
9120 jQuery
.extend( true, target
, deep
);
9126 /* Handles responses to an ajax request:
9127 * - finds the right dataType (mediates between content-type and expected dataType)
9128 * - returns the corresponding response
9130 function ajaxHandleResponses( s
, jqXHR
, responses
) {
9132 var ct
, type
, finalDataType
, firstDataType
,
9133 contents
= s
.contents
,
9134 dataTypes
= s
.dataTypes
;
9136 // Remove auto dataType and get content-type in the process
9137 while ( dataTypes
[ 0 ] === "*" ) {
9139 if ( ct
=== undefined ) {
9140 ct
= s
.mimeType
|| jqXHR
.getResponseHeader( "Content-Type" );
9144 // Check if we're dealing with a known content-type
9146 for ( type
in contents
) {
9147 if ( contents
[ type
] && contents
[ type
].test( ct
) ) {
9148 dataTypes
.unshift( type
);
9154 // Check to see if we have a response for the expected dataType
9155 if ( dataTypes
[ 0 ] in responses
) {
9156 finalDataType
= dataTypes
[ 0 ];
9159 // Try convertible dataTypes
9160 for ( type
in responses
) {
9161 if ( !dataTypes
[ 0 ] || s
.converters
[ type
+ " " + dataTypes
[ 0 ] ] ) {
9162 finalDataType
= type
;
9165 if ( !firstDataType
) {
9166 firstDataType
= type
;
9170 // Or just use first one
9171 finalDataType
= finalDataType
|| firstDataType
;
9174 // If we found a dataType
9175 // We add the dataType to the list if needed
9176 // and return the corresponding response
9177 if ( finalDataType
) {
9178 if ( finalDataType
!== dataTypes
[ 0 ] ) {
9179 dataTypes
.unshift( finalDataType
);
9181 return responses
[ finalDataType
];
9185 /* Chain conversions given the request and the original response
9186 * Also sets the responseXXX fields on the jqXHR instance
9188 function ajaxConvert( s
, response
, jqXHR
, isSuccess
) {
9189 var conv2
, current
, conv
, tmp
, prev
,
9192 // Work with a copy of dataTypes in case we need to modify it for conversion
9193 dataTypes
= s
.dataTypes
.slice();
9195 // Create converters map with lowercased keys
9196 if ( dataTypes
[ 1 ] ) {
9197 for ( conv
in s
.converters
) {
9198 converters
[ conv
.toLowerCase() ] = s
.converters
[ conv
];
9202 current
= dataTypes
.shift();
9204 // Convert to each sequential dataType
9207 if ( s
.responseFields
[ current
] ) {
9208 jqXHR
[ s
.responseFields
[ current
] ] = response
;
9211 // Apply the dataFilter if provided
9212 if ( !prev
&& isSuccess
&& s
.dataFilter
) {
9213 response
= s
.dataFilter( response
, s
.dataType
);
9217 current
= dataTypes
.shift();
9221 // There's only work to do if current dataType is non-auto
9222 if ( current
=== "*" ) {
9226 // Convert response if prev dataType is non-auto and differs from current
9227 } else if ( prev
!== "*" && prev
!== current
) {
9229 // Seek a direct converter
9230 conv
= converters
[ prev
+ " " + current
] || converters
[ "* " + current
];
9232 // If none found, seek a pair
9234 for ( conv2
in converters
) {
9236 // If conv2 outputs current
9237 tmp
= conv2
.split( " " );
9238 if ( tmp
[ 1 ] === current
) {
9240 // If prev can be converted to accepted input
9241 conv
= converters
[ prev
+ " " + tmp
[ 0 ] ] ||
9242 converters
[ "* " + tmp
[ 0 ] ];
9245 // Condense equivalence converters
9246 if ( conv
=== true ) {
9247 conv
= converters
[ conv2
];
9249 // Otherwise, insert the intermediate dataType
9250 } else if ( converters
[ conv2
] !== true ) {
9252 dataTypes
.unshift( tmp
[ 1 ] );
9260 // Apply converter (if not an equivalence)
9261 if ( conv
!== true ) {
9263 // Unless errors are allowed to bubble, catch and return them
9264 if ( conv
&& s
.throws ) {
9265 response
= conv( response
);
9268 response
= conv( response
);
9271 state: "parsererror",
9272 error: conv
? e : "No conversion from " + prev
+ " to " + current
9281 return { state: "success", data: response
};
9286 // Counter for holding the number of active queries
9289 // Last-Modified header cache for next request
9296 isLocal: rlocalProtocol
.test( location
.protocol
),
9300 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
9318 xml: "application/xml, text/xml",
9319 json: "application/json, text/javascript"
9330 text: "responseText",
9331 json: "responseJSON"
9335 // Keys separate source (or catchall "*") and destination types with a single space
9338 // Convert anything to text
9341 // Text to html (true = no transformation)
9344 // Evaluate text as a json expression
9345 "text json": JSON
.parse
,
9347 // Parse text as xml
9348 "text xml": jQuery
.parseXML
9351 // For options that shouldn't be deep extended:
9352 // you can add your own custom options here if
9353 // and when you create one that shouldn't be
9354 // deep extended (see ajaxExtend)
9361 // Creates a full fledged settings object into target
9362 // with both ajaxSettings and settings fields.
9363 // If target is omitted, writes into ajaxSettings.
9364 ajaxSetup: function( target
, settings
) {
9367 // Building a settings object
9368 ajaxExtend( ajaxExtend( target
, jQuery
.ajaxSettings
), settings
) :
9370 // Extending ajaxSettings
9371 ajaxExtend( jQuery
.ajaxSettings
, target
);
9374 ajaxPrefilter: addToPrefiltersOrTransports( prefilters
),
9375 ajaxTransport: addToPrefiltersOrTransports( transports
),
9378 ajax: function( url
, options
) {
9380 // If url is an object, simulate pre-1.5 signature
9381 if ( typeof url
=== "object" ) {
9386 // Force options to be an object
9387 options
= options
|| {};
9391 // URL without anti-cache param
9395 responseHeadersString
,
9404 // Request state (becomes false upon send and true upon completion)
9407 // To know if global events are to be dispatched
9413 // uncached part of the url
9416 // Create the final options object
9417 s
= jQuery
.ajaxSetup( {}, options
),
9419 // Callbacks context
9420 callbackContext
= s
.context
|| s
,
9422 // Context for global events is callbackContext if it is a DOM node or jQuery collection
9423 globalEventContext
= s
.context
&&
9424 ( callbackContext
.nodeType
|| callbackContext
.jquery
) ?
9425 jQuery( callbackContext
) :
9429 deferred
= jQuery
.Deferred(),
9430 completeDeferred
= jQuery
.Callbacks( "once memory" ),
9432 // Status-dependent callbacks
9433 statusCode
= s
.statusCode
|| {},
9435 // Headers (they are sent all at once)
9436 requestHeaders
= {},
9437 requestHeadersNames
= {},
9439 // Default abort message
9440 strAbort
= "canceled",
9446 // Builds headers hashtable if needed
9447 getResponseHeader: function( key
) {
9450 if ( !responseHeaders
) {
9451 responseHeaders
= {};
9452 while ( ( match
= rheaders
.exec( responseHeadersString
) ) ) {
9453 responseHeaders
[ match
[ 1 ].toLowerCase() + " " ] =
9454 ( responseHeaders
[ match
[ 1 ].toLowerCase() + " " ] || [] )
9455 .concat( match
[ 2 ] );
9458 match
= responseHeaders
[ key
.toLowerCase() + " " ];
9460 return match
== null ? null : match
.join( ", " );
9464 getAllResponseHeaders: function() {
9465 return completed
? responseHeadersString : null;
9468 // Caches the header
9469 setRequestHeader: function( name
, value
) {
9470 if ( completed
== null ) {
9471 name
= requestHeadersNames
[ name
.toLowerCase() ] =
9472 requestHeadersNames
[ name
.toLowerCase() ] || name
;
9473 requestHeaders
[ name
] = value
;
9478 // Overrides response content-type header
9479 overrideMimeType: function( type
) {
9480 if ( completed
== null ) {
9486 // Status-dependent callbacks
9487 statusCode: function( map
) {
9492 // Execute the appropriate callbacks
9493 jqXHR
.always( map
[ jqXHR
.status
] );
9496 // Lazy-add the new callbacks in a way that preserves old ones
9497 for ( code
in map
) {
9498 statusCode
[ code
] = [ statusCode
[ code
], map
[ code
] ];
9505 // Cancel the request
9506 abort: function( statusText
) {
9507 var finalText
= statusText
|| strAbort
;
9509 transport
.abort( finalText
);
9511 done( 0, finalText
);
9517 deferred
.promise( jqXHR
);
9519 // Add protocol if not provided (prefilters might expect it)
9520 // Handle falsy url in the settings object (#10093: consistency with old signature)
9521 // We also use the url parameter if available
9522 s
.url
= ( ( url
|| s
.url
|| location
.href
) + "" )
9523 .replace( rprotocol
, location
.protocol
+ "//" );
9525 // Alias method option to type as per ticket #12004
9526 s
.type
= options
.method
|| options
.type
|| s
.method
|| s
.type
;
9528 // Extract dataTypes list
9529 s
.dataTypes
= ( s
.dataType
|| "*" ).toLowerCase().match( rnothtmlwhite
) || [ "" ];
9531 // A cross-domain request is in order when the origin doesn't match the current origin.
9532 if ( s
.crossDomain
== null ) {
9533 urlAnchor
= document
.createElement( "a" );
9535 // Support: IE <=8 - 11, Edge 12 - 15
9536 // IE throws exception on accessing the href property if url is malformed,
9537 // e.g. http://example.com:80x/
9539 urlAnchor
.href
= s
.url
;
9541 // Support: IE <=8 - 11 only
9542 // Anchor's host property isn't correctly set when s.url is relative
9543 urlAnchor
.href
= urlAnchor
.href
;
9544 s
.crossDomain
= originAnchor
.protocol
+ "//" + originAnchor
.host
!==
9545 urlAnchor
.protocol
+ "//" + urlAnchor
.host
;
9548 // If there is an error parsing the URL, assume it is crossDomain,
9549 // it can be rejected by the transport if it is invalid
9550 s
.crossDomain
= true;
9554 // Convert data if not already a string
9555 if ( s
.data
&& s
.processData
&& typeof s
.data
!== "string" ) {
9556 s
.data
= jQuery
.param( s
.data
, s
.traditional
);
9560 inspectPrefiltersOrTransports( prefilters
, s
, options
, jqXHR
);
9562 // If request was aborted inside a prefilter, stop there
9567 // We can fire global events as of now if asked to
9568 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
9569 fireGlobals
= jQuery
.event
&& s
.global
;
9571 // Watch for a new set of requests
9572 if ( fireGlobals
&& jQuery
.active
++ === 0 ) {
9573 jQuery
.event
.trigger( "ajaxStart" );
9576 // Uppercase the type
9577 s
.type
= s
.type
.toUpperCase();
9579 // Determine if request has content
9580 s
.hasContent
= !rnoContent
.test( s
.type
);
9582 // Save the URL in case we're toying with the If-Modified-Since
9583 // and/or If-None-Match header later on
9584 // Remove hash to simplify url manipulation
9585 cacheURL
= s
.url
.replace( rhash
, "" );
9587 // More options handling for requests with no content
9588 if ( !s
.hasContent
) {
9590 // Remember the hash so we can put it back
9591 uncached
= s
.url
.slice( cacheURL
.length
);
9593 // If data is available and should be processed, append data to url
9594 if ( s
.data
&& ( s
.processData
|| typeof s
.data
=== "string" ) ) {
9595 cacheURL
+= ( rquery
.test( cacheURL
) ? "&" : "?" ) + s
.data
;
9597 // #9682: remove data so that it's not used in an eventual retry
9601 // Add or update anti-cache param if needed
9602 if ( s
.cache
=== false ) {
9603 cacheURL
= cacheURL
.replace( rantiCache
, "$1" );
9604 uncached
= ( rquery
.test( cacheURL
) ? "&" : "?" ) + "_=" + ( nonce
.guid
++ ) +
9608 // Put hash and anti-cache on the URL that will be requested (gh-1732)
9609 s
.url
= cacheURL
+ uncached
;
9611 // Change '%20' to '+' if this is encoded form body content (gh-2658)
9612 } else if ( s
.data
&& s
.processData
&&
9613 ( s
.contentType
|| "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
9614 s
.data
= s
.data
.replace( r20
, "+" );
9617 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9618 if ( s
.ifModified
) {
9619 if ( jQuery
.lastModified
[ cacheURL
] ) {
9620 jqXHR
.setRequestHeader( "If-Modified-Since", jQuery
.lastModified
[ cacheURL
] );
9622 if ( jQuery
.etag
[ cacheURL
] ) {
9623 jqXHR
.setRequestHeader( "If-None-Match", jQuery
.etag
[ cacheURL
] );
9627 // Set the correct header, if data is being sent
9628 if ( s
.data
&& s
.hasContent
&& s
.contentType
!== false || options
.contentType
) {
9629 jqXHR
.setRequestHeader( "Content-Type", s
.contentType
);
9632 // Set the Accepts header for the server, depending on the dataType
9633 jqXHR
.setRequestHeader(
9635 s
.dataTypes
[ 0 ] && s
.accepts
[ s
.dataTypes
[ 0 ] ] ?
9636 s
.accepts
[ s
.dataTypes
[ 0 ] ] +
9637 ( s
.dataTypes
[ 0 ] !== "*" ? ", " + allTypes
+ "; q=0.01" : "" ) :
9641 // Check for headers option
9642 for ( i
in s
.headers
) {
9643 jqXHR
.setRequestHeader( i
, s
.headers
[ i
] );
9646 // Allow custom headers/mimetypes and early abort
9647 if ( s
.beforeSend
&&
9648 ( s
.beforeSend
.call( callbackContext
, jqXHR
, s
) === false || completed
) ) {
9650 // Abort if not done already and return
9651 return jqXHR
.abort();
9654 // Aborting is no longer a cancellation
9657 // Install callbacks on deferreds
9658 completeDeferred
.add( s
.complete
);
9659 jqXHR
.done( s
.success
);
9660 jqXHR
.fail( s
.error
);
9663 transport
= inspectPrefiltersOrTransports( transports
, s
, options
, jqXHR
);
9665 // If no transport, we auto-abort
9667 done( -1, "No Transport" );
9669 jqXHR
.readyState
= 1;
9671 // Send global event
9672 if ( fireGlobals
) {
9673 globalEventContext
.trigger( "ajaxSend", [ jqXHR
, s
] );
9676 // If request was aborted inside ajaxSend, stop there
9682 if ( s
.async
&& s
.timeout
> 0 ) {
9683 timeoutTimer
= window
.setTimeout( function() {
9684 jqXHR
.abort( "timeout" );
9690 transport
.send( requestHeaders
, done
);
9693 // Rethrow post-completion exceptions
9698 // Propagate others as results
9703 // Callback for when everything is done
9704 function done( status
, nativeStatusText
, responses
, headers
) {
9705 var isSuccess
, success
, error
, response
, modified
,
9706 statusText
= nativeStatusText
;
9708 // Ignore repeat invocations
9715 // Clear timeout if it exists
9716 if ( timeoutTimer
) {
9717 window
.clearTimeout( timeoutTimer
);
9720 // Dereference transport for early garbage collection
9721 // (no matter how long the jqXHR object will be used)
9722 transport
= undefined;
9724 // Cache response headers
9725 responseHeadersString
= headers
|| "";
9728 jqXHR
.readyState
= status
> 0 ? 4 : 0;
9730 // Determine if successful
9731 isSuccess
= status
>= 200 && status
< 300 || status
=== 304;
9733 // Get response data
9735 response
= ajaxHandleResponses( s
, jqXHR
, responses
);
9738 // Use a noop converter for missing script but not if jsonp
9740 jQuery
.inArray( "script", s
.dataTypes
) > -1 &&
9741 jQuery
.inArray( "json", s
.dataTypes
) < 0 ) {
9742 s
.converters
[ "text script" ] = function() {};
9745 // Convert no matter what (that way responseXXX fields are always set)
9746 response
= ajaxConvert( s
, response
, jqXHR
, isSuccess
);
9748 // If successful, handle type chaining
9751 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9752 if ( s
.ifModified
) {
9753 modified
= jqXHR
.getResponseHeader( "Last-Modified" );
9755 jQuery
.lastModified
[ cacheURL
] = modified
;
9757 modified
= jqXHR
.getResponseHeader( "etag" );
9759 jQuery
.etag
[ cacheURL
] = modified
;
9764 if ( status
=== 204 || s
.type
=== "HEAD" ) {
9765 statusText
= "nocontent";
9768 } else if ( status
=== 304 ) {
9769 statusText
= "notmodified";
9771 // If we have data, let's convert it
9773 statusText
= response
.state
;
9774 success
= response
.data
;
9775 error
= response
.error
;
9780 // Extract error from statusText and normalize for non-aborts
9782 if ( status
|| !statusText
) {
9783 statusText
= "error";
9790 // Set data for the fake xhr object
9791 jqXHR
.status
= status
;
9792 jqXHR
.statusText
= ( nativeStatusText
|| statusText
) + "";
9796 deferred
.resolveWith( callbackContext
, [ success
, statusText
, jqXHR
] );
9798 deferred
.rejectWith( callbackContext
, [ jqXHR
, statusText
, error
] );
9801 // Status-dependent callbacks
9802 jqXHR
.statusCode( statusCode
);
9803 statusCode
= undefined;
9805 if ( fireGlobals
) {
9806 globalEventContext
.trigger( isSuccess
? "ajaxSuccess" : "ajaxError",
9807 [ jqXHR
, s
, isSuccess
? success : error
] );
9811 completeDeferred
.fireWith( callbackContext
, [ jqXHR
, statusText
] );
9813 if ( fireGlobals
) {
9814 globalEventContext
.trigger( "ajaxComplete", [ jqXHR
, s
] );
9816 // Handle the global AJAX counter
9817 if ( !( --jQuery
.active
) ) {
9818 jQuery
.event
.trigger( "ajaxStop" );
9826 getJSON: function( url
, data
, callback
) {
9827 return jQuery
.get( url
, data
, callback
, "json" );
9830 getScript: function( url
, callback
) {
9831 return jQuery
.get( url
, undefined, callback
, "script" );
9835 jQuery
.each( [ "get", "post" ], function( _i
, method
) {
9836 jQuery
[ method
] = function( url
, data
, callback
, type
) {
9838 // Shift arguments if data argument was omitted
9839 if ( isFunction( data
) ) {
9840 type
= type
|| callback
;
9845 // The url can be an options object (which then must have .url)
9846 return jQuery
.ajax( jQuery
.extend( {
9852 }, jQuery
.isPlainObject( url
) && url
) );
9856 jQuery
.ajaxPrefilter( function( s
) {
9858 for ( i
in s
.headers
) {
9859 if ( i
.toLowerCase() === "content-type" ) {
9860 s
.contentType
= s
.headers
[ i
] || "";
9866 jQuery
._evalUrl = function( url
, options
, doc
) {
9867 return jQuery
.ajax( {
9870 // Make this explicit, since user can override this through ajaxSetup (#11264)
9877 // Only evaluate the response if it is successful (gh-4126)
9878 // dataFilter is not invoked for failure responses, so using it instead
9879 // of the default converter is kludgy but it works.
9881 "text script": function() {}
9883 dataFilter: function( response
) {
9884 jQuery
.globalEval( response
, options
, doc
);
9891 wrapAll: function( html
) {
9895 if ( isFunction( html
) ) {
9896 html
= html
.call( this[ 0 ] );
9899 // The elements to wrap the target around
9900 wrap
= jQuery( html
, this[ 0 ].ownerDocument
).eq( 0 ).clone( true );
9902 if ( this[ 0 ].parentNode
) {
9903 wrap
.insertBefore( this[ 0 ] );
9906 wrap
.map( function() {
9909 while ( elem
.firstElementChild
) {
9910 elem
= elem
.firstElementChild
;
9920 wrapInner: function( html
) {
9921 if ( isFunction( html
) ) {
9922 return this.each( function( i
) {
9923 jQuery( this ).wrapInner( html
.call( this, i
) );
9927 return this.each( function() {
9928 var self
= jQuery( this ),
9929 contents
= self
.contents();
9931 if ( contents
.length
) {
9932 contents
.wrapAll( html
);
9935 self
.append( html
);
9940 wrap: function( html
) {
9941 var htmlIsFunction
= isFunction( html
);
9943 return this.each( function( i
) {
9944 jQuery( this ).wrapAll( htmlIsFunction
? html
.call( this, i
) : html
);
9948 unwrap: function( selector
) {
9949 this.parent( selector
).not( "body" ).each( function() {
9950 jQuery( this ).replaceWith( this.childNodes
);
9957 jQuery
.expr
.pseudos
.hidden = function( elem
) {
9958 return !jQuery
.expr
.pseudos
.visible( elem
);
9960 jQuery
.expr
.pseudos
.visible = function( elem
) {
9961 return !!( elem
.offsetWidth
|| elem
.offsetHeight
|| elem
.getClientRects().length
);
9967 jQuery
.ajaxSettings
.xhr = function() {
9969 return new window
.XMLHttpRequest();
9973 var xhrSuccessStatus
= {
9975 // File protocol always yields status code 0, assume 200
9978 // Support: IE <=9 only
9979 // #1450: sometimes IE returns 1223 when it should be 204
9982 xhrSupported
= jQuery
.ajaxSettings
.xhr();
9984 support
.cors
= !!xhrSupported
&& ( "withCredentials" in xhrSupported
);
9985 support
.ajax
= xhrSupported
= !!xhrSupported
;
9987 jQuery
.ajaxTransport( function( options
) {
9988 var callback
, errorCallback
;
9990 // Cross domain only allowed if supported through XMLHttpRequest
9991 if ( support
.cors
|| xhrSupported
&& !options
.crossDomain
) {
9993 send: function( headers
, complete
) {
9995 xhr
= options
.xhr();
10005 // Apply custom fields if provided
10006 if ( options
.xhrFields
) {
10007 for ( i
in options
.xhrFields
) {
10008 xhr
[ i
] = options
.xhrFields
[ i
];
10012 // Override mime type if needed
10013 if ( options
.mimeType
&& xhr
.overrideMimeType
) {
10014 xhr
.overrideMimeType( options
.mimeType
);
10017 // X-Requested-With header
10018 // For cross-domain requests, seeing as conditions for a preflight are
10019 // akin to a jigsaw puzzle, we simply never set it to be sure.
10020 // (it can always be set on a per-request basis or even using ajaxSetup)
10021 // For same-domain requests, won't change header if already provided.
10022 if ( !options
.crossDomain
&& !headers
[ "X-Requested-With" ] ) {
10023 headers
[ "X-Requested-With" ] = "XMLHttpRequest";
10027 for ( i
in headers
) {
10028 xhr
.setRequestHeader( i
, headers
[ i
] );
10032 callback = function( type
) {
10033 return function() {
10035 callback
= errorCallback
= xhr
.onload
=
10036 xhr
.onerror
= xhr
.onabort
= xhr
.ontimeout
=
10037 xhr
.onreadystatechange
= null;
10039 if ( type
=== "abort" ) {
10041 } else if ( type
=== "error" ) {
10043 // Support: IE <=9 only
10044 // On a manual native abort, IE9 throws
10045 // errors on any property access that is not readyState
10046 if ( typeof xhr
.status
!== "number" ) {
10047 complete( 0, "error" );
10051 // File: protocol always yields status 0; see #8605, #14207
10058 xhrSuccessStatus
[ xhr
.status
] || xhr
.status
,
10061 // Support: IE <=9 only
10062 // IE9 has no XHR2 but throws on binary (trac-11426)
10063 // For XHR2 non-text, let the caller handle it (gh-2498)
10064 ( xhr
.responseType
|| "text" ) !== "text" ||
10065 typeof xhr
.responseText
!== "string" ?
10066 { binary: xhr
.response
} :
10067 { text: xhr
.responseText
},
10068 xhr
.getAllResponseHeaders()
10075 // Listen to events
10076 xhr
.onload
= callback();
10077 errorCallback
= xhr
.onerror
= xhr
.ontimeout
= callback( "error" );
10079 // Support: IE 9 only
10080 // Use onreadystatechange to replace onabort
10081 // to handle uncaught aborts
10082 if ( xhr
.onabort
!== undefined ) {
10083 xhr
.onabort
= errorCallback
;
10085 xhr
.onreadystatechange = function() {
10087 // Check readyState before timeout as it changes
10088 if ( xhr
.readyState
=== 4 ) {
10090 // Allow onerror to be called first,
10091 // but that will not handle a native abort
10092 // Also, save errorCallback to a variable
10093 // as xhr.onerror cannot be accessed
10094 window
.setTimeout( function() {
10103 // Create the abort callback
10104 callback
= callback( "abort" );
10108 // Do send the request (this may raise an exception)
10109 xhr
.send( options
.hasContent
&& options
.data
|| null );
10112 // #14683: Only rethrow if this hasn't been notified as an error yet
10119 abort: function() {
10131 // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
10132 jQuery
.ajaxPrefilter( function( s
) {
10133 if ( s
.crossDomain
) {
10134 s
.contents
.script
= false;
10138 // Install script dataType
10139 jQuery
.ajaxSetup( {
10141 script: "text/javascript, application/javascript, " +
10142 "application/ecmascript, application/x-ecmascript"
10145 script: /\b(?:java|ecma)script\b/
10148 "text script": function( text
) {
10149 jQuery
.globalEval( text
);
10155 // Handle cache's special case and crossDomain
10156 jQuery
.ajaxPrefilter( "script", function( s
) {
10157 if ( s
.cache
=== undefined ) {
10160 if ( s
.crossDomain
) {
10165 // Bind script tag hack transport
10166 jQuery
.ajaxTransport( "script", function( s
) {
10168 // This transport only deals with cross domain or forced-by-attrs requests
10169 if ( s
.crossDomain
|| s
.scriptAttrs
) {
10170 var script
, callback
;
10172 send: function( _
, complete
) {
10173 script
= jQuery( "<script>" )
10174 .attr( s
.scriptAttrs
|| {} )
10175 .prop( { charset: s
.scriptCharset
, src: s
.url
} )
10176 .on( "load error", callback = function( evt
) {
10180 complete( evt
.type
=== "error" ? 404 : 200, evt
.type
);
10184 // Use native DOM manipulation to avoid our domManip AJAX trickery
10185 document
.head
.appendChild( script
[ 0 ] );
10187 abort: function() {
10199 var oldCallbacks
= [],
10200 rjsonp
= /(=)\?(?=&|$)|\?\?/;
10202 // Default jsonp settings
10203 jQuery
.ajaxSetup( {
10205 jsonpCallback: function() {
10206 var callback
= oldCallbacks
.pop() || ( jQuery
.expando
+ "_" + ( nonce
.guid
++ ) );
10207 this[ callback
] = true;
10212 // Detect, normalize options and install callbacks for jsonp requests
10213 jQuery
.ajaxPrefilter( "json jsonp", function( s
, originalSettings
, jqXHR
) {
10215 var callbackName
, overwritten
, responseContainer
,
10216 jsonProp
= s
.jsonp
!== false && ( rjsonp
.test( s
.url
) ?
10218 typeof s
.data
=== "string" &&
10219 ( s
.contentType
|| "" )
10220 .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
10221 rjsonp
.test( s
.data
) && "data"
10224 // Handle iff the expected data type is "jsonp" or we have a parameter to set
10225 if ( jsonProp
|| s
.dataTypes
[ 0 ] === "jsonp" ) {
10227 // Get callback name, remembering preexisting value associated with it
10228 callbackName
= s
.jsonpCallback
= isFunction( s
.jsonpCallback
) ?
10229 s
.jsonpCallback() :
10232 // Insert callback into url or form data
10234 s
[ jsonProp
] = s
[ jsonProp
].replace( rjsonp
, "$1" + callbackName
);
10235 } else if ( s
.jsonp
!== false ) {
10236 s
.url
+= ( rquery
.test( s
.url
) ? "&" : "?" ) + s
.jsonp
+ "=" + callbackName
;
10239 // Use data converter to retrieve json after script execution
10240 s
.converters
[ "script json" ] = function() {
10241 if ( !responseContainer
) {
10242 jQuery
.error( callbackName
+ " was not called" );
10244 return responseContainer
[ 0 ];
10247 // Force json dataType
10248 s
.dataTypes
[ 0 ] = "json";
10250 // Install callback
10251 overwritten
= window
[ callbackName
];
10252 window
[ callbackName
] = function() {
10253 responseContainer
= arguments
;
10256 // Clean-up function (fires after converters)
10257 jqXHR
.always( function() {
10259 // If previous value didn't exist - remove it
10260 if ( overwritten
=== undefined ) {
10261 jQuery( window
).removeProp( callbackName
);
10263 // Otherwise restore preexisting value
10265 window
[ callbackName
] = overwritten
;
10268 // Save back as free
10269 if ( s
[ callbackName
] ) {
10271 // Make sure that re-using the options doesn't screw things around
10272 s
.jsonpCallback
= originalSettings
.jsonpCallback
;
10274 // Save the callback name for future use
10275 oldCallbacks
.push( callbackName
);
10278 // Call if it was a function and we have a response
10279 if ( responseContainer
&& isFunction( overwritten
) ) {
10280 overwritten( responseContainer
[ 0 ] );
10283 responseContainer
= overwritten
= undefined;
10286 // Delegate to script
10294 // Support: Safari 8 only
10295 // In Safari 8 documents created via document.implementation.createHTMLDocument
10296 // collapse sibling forms: the second one becomes a child of the first one.
10297 // Because of that, this security measure has to be disabled in Safari 8.
10298 // https://bugs.webkit.org/show_bug.cgi?id=137337
10299 support
.createHTMLDocument
= ( function() {
10300 var body
= document
.implementation
.createHTMLDocument( "" ).body
;
10301 body
.innerHTML
= "<form></form><form></form>";
10302 return body
.childNodes
.length
=== 2;
10306 // Argument "data" should be string of html
10307 // context (optional): If specified, the fragment will be created in this context,
10308 // defaults to document
10309 // keepScripts (optional): If true, will include scripts passed in the html string
10310 jQuery
.parseHTML = function( data
, context
, keepScripts
) {
10311 if ( typeof data
!== "string" ) {
10314 if ( typeof context
=== "boolean" ) {
10315 keepScripts
= context
;
10319 var base
, parsed
, scripts
;
10323 // Stop scripts or inline event handlers from being executed immediately
10324 // by using document.implementation
10325 if ( support
.createHTMLDocument
) {
10326 context
= document
.implementation
.createHTMLDocument( "" );
10328 // Set the base href for the created document
10329 // so any parsed elements with URLs
10330 // are based on the document's URL (gh-2965)
10331 base
= context
.createElement( "base" );
10332 base
.href
= document
.location
.href
;
10333 context
.head
.appendChild( base
);
10335 context
= document
;
10339 parsed
= rsingleTag
.exec( data
);
10340 scripts
= !keepScripts
&& [];
10344 return [ context
.createElement( parsed
[ 1 ] ) ];
10347 parsed
= buildFragment( [ data
], context
, scripts
);
10349 if ( scripts
&& scripts
.length
) {
10350 jQuery( scripts
).remove();
10353 return jQuery
.merge( [], parsed
.childNodes
);
10358 * Load a url into a page
10360 jQuery
.fn
.load = function( url
, params
, callback
) {
10361 var selector
, type
, response
,
10363 off
= url
.indexOf( " " );
10366 selector
= stripAndCollapse( url
.slice( off
) );
10367 url
= url
.slice( 0, off
);
10370 // If it's a function
10371 if ( isFunction( params
) ) {
10373 // We assume that it's the callback
10375 params
= undefined;
10377 // Otherwise, build a param string
10378 } else if ( params
&& typeof params
=== "object" ) {
10382 // If we have elements to modify, make the request
10383 if ( self
.length
> 0 ) {
10387 // If "type" variable is undefined, then "GET" method will be used.
10388 // Make value of this field explicit since
10389 // user can override it through ajaxSetup method
10390 type: type
|| "GET",
10393 } ).done( function( responseText
) {
10395 // Save response for use in complete callback
10396 response
= arguments
;
10398 self
.html( selector
?
10400 // If a selector was specified, locate the right elements in a dummy div
10401 // Exclude scripts to avoid IE 'Permission Denied' errors
10402 jQuery( "<div>" ).append( jQuery
.parseHTML( responseText
) ).find( selector
) :
10404 // Otherwise use the full result
10407 // If the request succeeds, this function gets "data", "status", "jqXHR"
10408 // but they are ignored because response was set above.
10409 // If it fails, this function gets "jqXHR", "status", "error"
10410 } ).always( callback
&& function( jqXHR
, status
) {
10411 self
.each( function() {
10412 callback
.apply( this, response
|| [ jqXHR
.responseText
, status
, jqXHR
] );
10423 jQuery
.expr
.pseudos
.animated = function( elem
) {
10424 return jQuery
.grep( jQuery
.timers
, function( fn
) {
10425 return elem
=== fn
.elem
;
10433 setOffset: function( elem
, options
, i
) {
10434 var curPosition
, curLeft
, curCSSTop
, curTop
, curOffset
, curCSSLeft
, calculatePosition
,
10435 position
= jQuery
.css( elem
, "position" ),
10436 curElem
= jQuery( elem
),
10439 // Set position first, in-case top/left are set even on static elem
10440 if ( position
=== "static" ) {
10441 elem
.style
.position
= "relative";
10444 curOffset
= curElem
.offset();
10445 curCSSTop
= jQuery
.css( elem
, "top" );
10446 curCSSLeft
= jQuery
.css( elem
, "left" );
10447 calculatePosition
= ( position
=== "absolute" || position
=== "fixed" ) &&
10448 ( curCSSTop
+ curCSSLeft
).indexOf( "auto" ) > -1;
10450 // Need to be able to calculate position if either
10451 // top or left is auto and position is either absolute or fixed
10452 if ( calculatePosition
) {
10453 curPosition
= curElem
.position();
10454 curTop
= curPosition
.top
;
10455 curLeft
= curPosition
.left
;
10458 curTop
= parseFloat( curCSSTop
) || 0;
10459 curLeft
= parseFloat( curCSSLeft
) || 0;
10462 if ( isFunction( options
) ) {
10464 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
10465 options
= options
.call( elem
, i
, jQuery
.extend( {}, curOffset
) );
10468 if ( options
.top
!= null ) {
10469 props
.top
= ( options
.top
- curOffset
.top
) + curTop
;
10471 if ( options
.left
!= null ) {
10472 props
.left
= ( options
.left
- curOffset
.left
) + curLeft
;
10475 if ( "using" in options
) {
10476 options
.using
.call( elem
, props
);
10479 curElem
.css( props
);
10484 jQuery
.fn
.extend( {
10486 // offset() relates an element's border box to the document origin
10487 offset: function( options
) {
10489 // Preserve chaining for setter
10490 if ( arguments
.length
) {
10491 return options
=== undefined ?
10493 this.each( function( i
) {
10494 jQuery
.offset
.setOffset( this, options
, i
);
10505 // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
10506 // Support: IE <=11 only
10507 // Running getBoundingClientRect on a
10508 // disconnected node in IE throws an error
10509 if ( !elem
.getClientRects().length
) {
10510 return { top: 0, left: 0 };
10513 // Get document-relative position by adding viewport scroll to viewport-relative gBCR
10514 rect
= elem
.getBoundingClientRect();
10515 win
= elem
.ownerDocument
.defaultView
;
10517 top: rect
.top
+ win
.pageYOffset
,
10518 left: rect
.left
+ win
.pageXOffset
10522 // position() relates an element's margin box to its offset parent's padding box
10523 // This corresponds to the behavior of CSS absolute positioning
10524 position: function() {
10525 if ( !this[ 0 ] ) {
10529 var offsetParent
, offset
, doc
,
10531 parentOffset
= { top: 0, left: 0 };
10533 // position:fixed elements are offset from the viewport, which itself always has zero offset
10534 if ( jQuery
.css( elem
, "position" ) === "fixed" ) {
10536 // Assume position:fixed implies availability of getBoundingClientRect
10537 offset
= elem
.getBoundingClientRect();
10540 offset
= this.offset();
10542 // Account for the *real* offset parent, which can be the document or its root element
10543 // when a statically positioned element is identified
10544 doc
= elem
.ownerDocument
;
10545 offsetParent
= elem
.offsetParent
|| doc
.documentElement
;
10546 while ( offsetParent
&&
10547 ( offsetParent
=== doc
.body
|| offsetParent
=== doc
.documentElement
) &&
10548 jQuery
.css( offsetParent
, "position" ) === "static" ) {
10550 offsetParent
= offsetParent
.parentNode
;
10552 if ( offsetParent
&& offsetParent
!== elem
&& offsetParent
.nodeType
=== 1 ) {
10554 // Incorporate borders into its offset, since they are outside its content origin
10555 parentOffset
= jQuery( offsetParent
).offset();
10556 parentOffset
.top
+= jQuery
.css( offsetParent
, "borderTopWidth", true );
10557 parentOffset
.left
+= jQuery
.css( offsetParent
, "borderLeftWidth", true );
10561 // Subtract parent offsets and element margins
10563 top: offset
.top
- parentOffset
.top
- jQuery
.css( elem
, "marginTop", true ),
10564 left: offset
.left
- parentOffset
.left
- jQuery
.css( elem
, "marginLeft", true )
10568 // This method will return documentElement in the following cases:
10569 // 1) For the element inside the iframe without offsetParent, this method will return
10570 // documentElement of the parent window
10571 // 2) For the hidden or detached element
10572 // 3) For body or html element, i.e. in case of the html node - it will return itself
10574 // but those exceptions were never presented as a real life use-cases
10575 // and might be considered as more preferable results.
10577 // This logic, however, is not guaranteed and can change at any point in the future
10578 offsetParent: function() {
10579 return this.map( function() {
10580 var offsetParent
= this.offsetParent
;
10582 while ( offsetParent
&& jQuery
.css( offsetParent
, "position" ) === "static" ) {
10583 offsetParent
= offsetParent
.offsetParent
;
10586 return offsetParent
|| documentElement
;
10591 // Create scrollLeft and scrollTop methods
10592 jQuery
.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method
, prop
) {
10593 var top
= "pageYOffset" === prop
;
10595 jQuery
.fn
[ method
] = function( val
) {
10596 return access( this, function( elem
, method
, val
) {
10598 // Coalesce documents and windows
10600 if ( isWindow( elem
) ) {
10602 } else if ( elem
.nodeType
=== 9 ) {
10603 win
= elem
.defaultView
;
10606 if ( val
=== undefined ) {
10607 return win
? win
[ prop
] : elem
[ method
];
10612 !top
? val : win
.pageXOffset
,
10613 top
? val : win
.pageYOffset
10617 elem
[ method
] = val
;
10619 }, method
, val
, arguments
.length
);
10623 // Support: Safari <=7 - 9.1, Chrome <=37 - 49
10624 // Add the top/left cssHooks using jQuery.fn.position
10625 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
10626 // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
10627 // getComputedStyle returns percent when specified for top/left/bottom/right;
10628 // rather than make the css module depend on the offset module, just check for it here
10629 jQuery
.each( [ "top", "left" ], function( _i
, prop
) {
10630 jQuery
.cssHooks
[ prop
] = addGetHookIf( support
.pixelPosition
,
10631 function( elem
, computed
) {
10633 computed
= curCSS( elem
, prop
);
10635 // If curCSS returns percentage, fallback to offset
10636 return rnumnonpx
.test( computed
) ?
10637 jQuery( elem
).position()[ prop
] + "px" :
10645 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
10646 jQuery
.each( { Height: "height", Width: "width" }, function( name
, type
) {
10648 padding: "inner" + name
,
10651 }, function( defaultExtra
, funcName
) {
10653 // Margin is only for outerHeight, outerWidth
10654 jQuery
.fn
[ funcName
] = function( margin
, value
) {
10655 var chainable
= arguments
.length
&& ( defaultExtra
|| typeof margin
!== "boolean" ),
10656 extra
= defaultExtra
|| ( margin
=== true || value
=== true ? "margin" : "border" );
10658 return access( this, function( elem
, type
, value
) {
10661 if ( isWindow( elem
) ) {
10663 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
10664 return funcName
.indexOf( "outer" ) === 0 ?
10665 elem
[ "inner" + name
] :
10666 elem
.document
.documentElement
[ "client" + name
];
10669 // Get document width or height
10670 if ( elem
.nodeType
=== 9 ) {
10671 doc
= elem
.documentElement
;
10673 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
10674 // whichever is greatest
10676 elem
.body
[ "scroll" + name
], doc
[ "scroll" + name
],
10677 elem
.body
[ "offset" + name
], doc
[ "offset" + name
],
10678 doc
[ "client" + name
]
10682 return value
=== undefined ?
10684 // Get width or height on the element, requesting but not forcing parseFloat
10685 jQuery
.css( elem
, type
, extra
) :
10687 // Set width or height on the element
10688 jQuery
.style( elem
, type
, value
, extra
);
10689 }, type
, chainable
? margin : undefined, chainable
);
10702 ], function( _i
, type
) {
10703 jQuery
.fn
[ type
] = function( fn
) {
10704 return this.on( type
, fn
);
10711 jQuery
.fn
.extend( {
10713 bind: function( types
, data
, fn
) {
10714 return this.on( types
, null, data
, fn
);
10716 unbind: function( types
, fn
) {
10717 return this.off( types
, null, fn
);
10720 delegate: function( selector
, types
, data
, fn
) {
10721 return this.on( types
, selector
, data
, fn
);
10723 undelegate: function( selector
, types
, fn
) {
10725 // ( namespace ) or ( selector, types [, fn] )
10726 return arguments
.length
=== 1 ?
10727 this.off( selector
, "**" ) :
10728 this.off( types
, selector
|| "**", fn
);
10731 hover: function( fnOver
, fnOut
) {
10732 return this.mouseenter( fnOver
).mouseleave( fnOut
|| fnOver
);
10737 ( "blur focus focusin focusout resize scroll click dblclick " +
10738 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
10739 "change select submit keydown keypress keyup contextmenu" ).split( " " ),
10740 function( _i
, name
) {
10742 // Handle event binding
10743 jQuery
.fn
[ name
] = function( data
, fn
) {
10744 return arguments
.length
> 0 ?
10745 this.on( name
, null, data
, fn
) :
10746 this.trigger( name
);
10754 // Support: Android <=4.0 only
10755 // Make sure we trim BOM and NBSP
10756 var rtrim
= /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
10758 // Bind a function to a context, optionally partially applying any
10760 // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
10761 // However, it is not slated for removal any time soon
10762 jQuery
.proxy = function( fn
, context
) {
10763 var tmp
, args
, proxy
;
10765 if ( typeof context
=== "string" ) {
10766 tmp
= fn
[ context
];
10771 // Quick check to determine if target is callable, in the spec
10772 // this throws a TypeError, but we will just return undefined.
10773 if ( !isFunction( fn
) ) {
10778 args
= slice
.call( arguments
, 2 );
10779 proxy = function() {
10780 return fn
.apply( context
|| this, args
.concat( slice
.call( arguments
) ) );
10783 // Set the guid of unique handler to the same of original handler, so it can be removed
10784 proxy
.guid
= fn
.guid
= fn
.guid
|| jQuery
.guid
++;
10789 jQuery
.holdReady = function( hold
) {
10791 jQuery
.readyWait
++;
10793 jQuery
.ready( true );
10796 jQuery
.isArray
= Array
.isArray
;
10797 jQuery
.parseJSON
= JSON
.parse
;
10798 jQuery
.nodeName
= nodeName
;
10799 jQuery
.isFunction
= isFunction
;
10800 jQuery
.isWindow
= isWindow
;
10801 jQuery
.camelCase
= camelCase
;
10802 jQuery
.type
= toType
;
10804 jQuery
.now
= Date
.now
;
10806 jQuery
.isNumeric = function( obj
) {
10808 // As of jQuery 3.0, isNumeric is limited to
10809 // strings and numbers (primitives or objects)
10810 // that can be coerced to finite numbers (gh-2662)
10811 var type
= jQuery
.type( obj
);
10812 return ( type
=== "number" || type
=== "string" ) &&
10814 // parseFloat NaNs numeric-cast false positives ("")
10815 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
10816 // subtraction forces infinities to NaN
10817 !isNaN( obj
- parseFloat( obj
) );
10820 jQuery
.trim = function( text
) {
10821 return text
== null ?
10823 ( text
+ "" ).replace( rtrim
, "" );
10828 // Register as a named AMD module, since jQuery can be concatenated with other
10829 // files that may use define, but not via a proper concatenation script that
10830 // understands anonymous AMD modules. A named AMD is safest and most robust
10831 // way to register. Lowercase jquery is used because AMD module names are
10832 // derived from file names, and jQuery is normally delivered in a lowercase
10833 // file name. Do this after creating the global so that if an AMD module wants
10834 // to call noConflict to hide this version of jQuery, it will work.
10836 // Note that for maximum portability, libraries that are not jQuery should
10837 // declare themselves as anonymous modules, and avoid setting a global if an
10838 // AMD loader is present. jQuery is a special case. For more information, see
10839 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
10841 if ( typeof define
=== "function" && define
.amd
) {
10842 define( "jquery", [], function() {
10852 // Map over jQuery in case of overwrite
10853 _jQuery
= window
.jQuery
,
10855 // Map over the $ in case of overwrite
10858 jQuery
.noConflict = function( deep
) {
10859 if ( window
.$ === jQuery
) {
10863 if ( deep
&& window
.jQuery
=== jQuery
) {
10864 window
.jQuery
= _jQuery
;
10870 // Expose jQuery and $ identifiers, even in AMD
10871 // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
10872 // and CommonJS for browser emulators (#13566)
10873 if ( typeof noGlobal
=== "undefined" ) {
10874 window
.jQuery
= window
.$ = jQuery
;