2 * jQuery JavaScript Library v3.6.2
6 * https://sizzlejs.com/
8 * Copyright OpenJS Foundation and other contributors
9 * Released under the MIT license
10 * https://jquery.org/license
12 * Date: 2022-12-13T14:56Z
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 trac-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.8
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 // `qSA` may not throw for unrecognized parts using forgiving parsing:
884 // https://drafts.csswg.org/selectors/#forgiving-selector
885 // like the `:has()` pseudo-class:
886 // https://drafts.csswg.org/selectors/#relational
887 // `CSS.supports` is still expected to return `false` then:
888 // https://drafts.csswg.org/css-conditional-4/#typedef-supports-selector-fn
889 // https://drafts.csswg.org/css-conditional-4/#dfn-support-selector
890 if ( support.cssSupportsSelector &&
892 // eslint-disable-next-line no-undef
893 !CSS.supports( "selector(" + newSelector + ")" ) ) {
896 // Throw to get to the same code path as an error directly in qSA.
897 // Note: once we only support browser supporting
898 // `CSS.supports('selector(...)')`, we can most likely drop
899 // the `try-catch`. IE doesn't implement the API.
904 newContext.querySelectorAll( newSelector )
907 } catch ( qsaError ) {
908 nonnativeSelectorCache( selector, true );
910 if ( nid === expando ) {
911 context.removeAttribute( "id" );
919 return select( selector.replace( rtrim, "$1" ), context, results, seed );
923 * Create key-value caches of limited size
924 * @returns {function(string, object)} Returns the Object data after storing it on itself with
925 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
926 * deleting the oldest entry
928 function createCache() {
931 function cache( key, value ) {
933 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
934 if ( keys.push( key + " " ) > Expr.cacheLength ) {
936 // Only keep the most recent entries
937 delete cache[ keys.shift() ];
939 return ( cache[ key + " " ] = value );
945 * Mark a function for special use by Sizzle
946 * @param {Function} fn The function to mark
948 function markFunction( fn ) {
949 fn[ expando ] = true;
954 * Support testing using an element
955 * @param {Function} fn Passed the created element and returns a boolean result
957 function assert( fn ) {
958 var el = document.createElement( "fieldset" );
966 // Remove from its parent by default
967 if ( el.parentNode ) {
968 el.parentNode.removeChild( el );
971 // release memory in IE
977 * Adds the same handler for all of the specified attrs
978 * @param {String} attrs Pipe-separated list of attributes
979 * @param {Function} handler The method that will be applied
981 function addHandle( attrs, handler ) {
982 var arr = attrs.split( "|" ),
986 Expr.attrHandle[ arr[ i ] ] = handler;
991 * Checks document order of two siblings
994 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
996 function siblingCheck( a, b ) {
998 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
999 a.sourceIndex - b.sourceIndex;
1001 // Use IE sourceIndex if available on both nodes
1006 // Check if b follows a
1008 while ( ( cur = cur.nextSibling ) ) {
1019 * Returns a function to use in pseudos for input types
1020 * @param {String} type
1022 function createInputPseudo( type ) {
1023 return function( elem ) {
1024 var name = elem.nodeName.toLowerCase();
1025 return name === "input" && elem.type === type;
1030 * Returns a function to use in pseudos for buttons
1031 * @param {String} type
1033 function createButtonPseudo( type ) {
1034 return function( elem ) {
1035 var name = elem.nodeName.toLowerCase();
1036 return ( name === "input" || name === "button" ) && elem.type === type;
1041 * Returns a function to use in pseudos for :enabled/:disabled
1042 * @param {Boolean} disabled true for :disabled; false for :enabled
1044 function createDisabledPseudo( disabled ) {
1046 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
1047 return function( elem ) {
1049 // Only certain elements can match :enabled or :disabled
1050 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
1051 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
1052 if ( "form" in elem ) {
1054 // Check for inherited disabledness on relevant non-disabled elements:
1055 // * listed form-associated elements in a disabled fieldset
1056 // https://html.spec.whatwg.org/multipage/forms.html#category-listed
1057 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
1058 // * option elements in a disabled optgroup
1059 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
1060 // All such elements have a "form" property.
1061 if ( elem.parentNode && elem.disabled === false ) {
1063 // Option elements defer to a parent optgroup if present
1064 if ( "label" in elem ) {
1065 if ( "label" in elem.parentNode ) {
1066 return elem.parentNode.disabled === disabled;
1068 return elem.disabled === disabled;
1072 // Support: IE 6 - 11
1073 // Use the isDisabled shortcut property to check for disabled fieldset ancestors
1074 return elem.isDisabled === disabled ||
1076 // Where there is no isDisabled, check manually
1078 elem.isDisabled !== !disabled &&
1079 inDisabledFieldset( elem ) === disabled;
1082 return elem.disabled === disabled;
1084 // Try to winnow out elements that can't be disabled before trusting the disabled property.
1085 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
1086 // even exist on them, let alone have a boolean value.
1087 } else if ( "label" in elem ) {
1088 return elem.disabled === disabled;
1091 // Remaining elements are neither :enabled nor :disabled
1097 * Returns a function to use in pseudos for positionals
1098 * @param {Function} fn
1100 function createPositionalPseudo( fn ) {
1101 return markFunction( function( argument ) {
1102 argument = +argument;
1103 return markFunction( function( seed, matches ) {
1105 matchIndexes = fn( [], seed.length, argument ),
1106 i = matchIndexes.length;
1108 // Match elements found at the specified indexes
1110 if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
1111 seed[ j ] = !( matches[ j ] = seed[ j ] );
1119 * Checks a node for validity as a Sizzle context
1120 * @param {Element|Object=} context
1121 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
1123 function testContext( context ) {
1124 return context && typeof context.getElementsByTagName !== "undefined" && context;
1127 // Expose support vars for convenience
1128 support = Sizzle.support = {};
1132 * @param {Element|Object} elem An element or a document
1133 * @returns {Boolean} True iff elem is a non-HTML XML node
1135 isXML = Sizzle.isXML = function( elem ) {
1136 var namespace = elem && elem.namespaceURI,
1137 docElem = elem && ( elem.ownerDocument || elem ).documentElement;
1140 // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
1141 // https://bugs.jquery.com/ticket/4833
1142 return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
1146 * Sets document-related variables once based on the current document
1147 * @param {Element|Object} [doc] An element or document object to use to set the document
1148 * @returns {Object} Returns the current document
1150 setDocument = Sizzle.setDocument = function( node ) {
1151 var hasCompare, subWindow,
1152 doc = node ? node.ownerDocument || node : preferredDoc;
1154 // Return early if doc is invalid or already selected
1155 // Support: IE 11+, Edge 17 - 18+
1156 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1157 // two documents; shallow comparisons work.
1158 // eslint-disable-next-line eqeqeq
1159 if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
1163 // Update global variables
1165 docElem = document.documentElement;
1166 documentIsHTML = !isXML( document );
1168 // Support: IE 9 - 11+, Edge 12 - 18+
1169 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
1170 // Support: IE 11+, Edge 17 - 18+
1171 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1172 // two documents; shallow comparisons work.
1173 // eslint-disable-next-line eqeqeq
1174 if ( preferredDoc != document &&
1175 ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
1177 // Support: IE 11, Edge
1178 if ( subWindow.addEventListener ) {
1179 subWindow.addEventListener( "unload", unloadHandler, false );
1181 // Support: IE 9 - 10 only
1182 } else if ( subWindow.attachEvent ) {
1183 subWindow.attachEvent( "onunload", unloadHandler );
1187 // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only,
1188 // Safari 4 - 5 only, Opera <=11.6 - 12.x only
1189 // IE/Edge & older browsers don't support the :scope pseudo-class.
1190 // Support: Safari 6.0 only
1191 // Safari 6.0 supports :scope but it's an alias of :root there.
1192 support.scope = assert( function( el ) {
1193 docElem.appendChild( el ).appendChild( document.createElement( "div" ) );
1194 return typeof el.querySelectorAll !== "undefined" &&
1195 !el.querySelectorAll( ":scope fieldset div" ).length;
1198 // Support: Chrome 105+, Firefox 104+, Safari 15.4+
1199 // Make sure forgiving mode is not used in `CSS.supports( "selector(...)" )`.
1201 // `:is()` uses a forgiving selector list as an argument and is widely
1202 // implemented, so it's a good one to test against.
1203 support.cssSupportsSelector = assert( function() {
1204 /* eslint-disable no-undef */
1206 return CSS.supports( "selector(*)" ) &&
1208 // Support: Firefox 78-81 only
1209 // In old Firefox, `:is()` didn't use forgiving parsing. In that case,
1210 // fail this test as there's no selector to test against that.
1211 // `CSS.supports` uses unforgiving parsing
1212 document.querySelectorAll( ":is(:jqfake)" ) &&
1214 // `*` is needed as Safari & newer Chrome implemented something in between
1215 // for `:has()` - it throws in `qSA` if it only contains an unsupported
1216 // argument but multiple ones, one of which is supported, are fine.
1217 // We want to play safe in case `:is()` gets the same treatment.
1218 !CSS.supports( "selector(:is(*,:jqfake))" );
1224 ---------------------------------------------------------------------- */
1227 // Verify that getAttribute really returns attributes and not properties
1228 // (excepting IE8 booleans)
1229 support.attributes = assert( function( el ) {
1231 return !el.getAttribute( "className" );
1235 ---------------------------------------------------------------------- */
1237 // Check if getElementsByTagName("*") returns only elements
1238 support.getElementsByTagName = assert( function( el ) {
1239 el.appendChild( document.createComment( "" ) );
1240 return !el.getElementsByTagName( "*" ).length;
1244 support.getElementsByClassName = rnative.test( document.getElementsByClassName );
1247 // Check if getElementById returns elements by name
1248 // The broken getElementById methods don't pick up programmatically-set names,
1249 // so use a roundabout getElementsByName test
1250 support.getById = assert( function( el ) {
1251 docElem.appendChild( el ).id = expando;
1252 return !document.getElementsByName || !document.getElementsByName( expando ).length;
1255 // ID filter and find
1256 if ( support.getById ) {
1257 Expr.filter[ "ID" ] = function( id ) {
1258 var attrId = id.replace( runescape, funescape );
1259 return function( elem ) {
1260 return elem.getAttribute( "id" ) === attrId;
1263 Expr.find[ "ID" ] = function( id, context ) {
1264 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1265 var elem = context.getElementById( id );
1266 return elem ? [ elem ] : [];
1270 Expr.filter[ "ID" ] = function( id ) {
1271 var attrId = id.replace( runescape, funescape );
1272 return function( elem ) {
1273 var node = typeof elem.getAttributeNode !== "undefined" &&
1274 elem.getAttributeNode( "id" );
1275 return node && node.value === attrId;
1279 // Support: IE 6 - 7 only
1280 // getElementById is not reliable as a find shortcut
1281 Expr.find[ "ID" ] = function( id, context ) {
1282 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
1284 elem = context.getElementById( id );
1288 // Verify the id attribute
1289 node = elem.getAttributeNode( "id" );
1290 if ( node && node.value === id ) {
1294 // Fall back on getElementsByName
1295 elems = context.getElementsByName( id );
1297 while ( ( elem = elems[ i++ ] ) ) {
1298 node = elem.getAttributeNode( "id" );
1299 if ( node && node.value === id ) {
1311 Expr.find[ "TAG" ] = support.getElementsByTagName ?
1312 function( tag, context ) {
1313 if ( typeof context.getElementsByTagName !== "undefined" ) {
1314 return context.getElementsByTagName( tag );
1316 // DocumentFragment nodes don't have gEBTN
1317 } else if ( support.qsa ) {
1318 return context.querySelectorAll( tag );
1322 function( tag, context ) {
1327 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
1328 results = context.getElementsByTagName( tag );
1330 // Filter out possible comments
1331 if ( tag === "*" ) {
1332 while ( ( elem = results[ i++ ] ) ) {
1333 if ( elem.nodeType === 1 ) {
1344 Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) {
1345 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
1346 return context.getElementsByClassName( className );
1350 /* QSA/matchesSelector
1351 ---------------------------------------------------------------------- */
1353 // QSA and matchesSelector support
1355 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
1358 // qSa(:focus) reports false when true (Chrome 21)
1359 // We allow this because of a bug in IE8/9 that throws an error
1360 // whenever `document.activeElement` is accessed on an iframe
1361 // So, we allow :focus to pass through QSA all the time to avoid the IE error
1362 // See https://bugs.jquery.com/ticket/13378
1365 if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) {
1368 // Regex strategy adopted from Diego Perini
1369 assert( function( el ) {
1373 // Select is set to empty string on purpose
1374 // This is to test IE's treatment of not explicitly
1375 // setting a boolean content attribute,
1376 // since its presence should be enough
1377 // https://bugs.jquery.com/ticket/12359
1378 docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
1379 "<select id='" + expando + "-\r\\' msallowcapture=''>" +
1380 "<option selected=''></option></select>";
1382 // Support: IE8, Opera 11-12.16
1383 // Nothing should be selected when empty strings follow ^= or $= or *=
1384 // The test attribute must be unknown in Opera but "safe" for WinRT
1385 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
1386 if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) {
1387 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
1391 // Boolean attributes and "value" are not treated correctly
1392 if ( !el.querySelectorAll( "[selected]" ).length ) {
1393 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
1396 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
1397 if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
1398 rbuggyQSA.push( "~=" );
1401 // Support: IE 11+, Edge 15 - 18+
1402 // IE 11/Edge don't find elements on a `[name='']` query in some cases.
1403 // Adding a temporary attribute to the document before the selection works
1404 // around the issue.
1405 // Interestingly, IE 10 & older don't seem to have the issue.
1406 input = document.createElement( "input" );
1407 input.setAttribute( "name", "" );
1408 el.appendChild( input );
1409 if ( !el.querySelectorAll( "[name='']" ).length ) {
1410 rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
1411 whitespace + "*(?:''|\"\")" );
1414 // Webkit/Opera - :checked should return selected option elements
1415 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1416 // IE8 throws error here and will not see later tests
1417 if ( !el.querySelectorAll( ":checked" ).length ) {
1418 rbuggyQSA.push( ":checked" );
1421 // Support: Safari 8+, iOS 8+
1422 // https://bugs.webkit.org/show_bug.cgi?id=136851
1423 // In-page `selector#id sibling-combinator selector` fails
1424 if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
1425 rbuggyQSA.push( ".#.+[+~]" );
1428 // Support: Firefox <=3.6 - 5 only
1429 // Old Firefox doesn't throw on a badly-escaped identifier.
1430 el.querySelectorAll( "\\\f" );
1431 rbuggyQSA.push( "[\\r\\n\\f]" );
1434 assert( function( el ) {
1435 el.innerHTML = "<a href='' disabled='disabled'></a>" +
1436 "<select disabled='disabled'><option/></select>";
1438 // Support: Windows 8 Native Apps
1439 // The type and name attributes are restricted during .innerHTML assignment
1440 var input = document.createElement( "input" );
1441 input.setAttribute( "type", "hidden" );
1442 el.appendChild( input ).setAttribute( "name", "D" );
1445 // Enforce case-sensitivity of name attribute
1446 if ( el.querySelectorAll( "[name=d]" ).length ) {
1447 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
1450 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
1451 // IE8 throws error here and will not see later tests
1452 if ( el.querySelectorAll( ":enabled" ).length !== 2 ) {
1453 rbuggyQSA.push( ":enabled", ":disabled" );
1457 // IE's :disabled selector does not pick up the children of disabled fieldsets
1458 docElem.appendChild( el ).disabled = true;
1459 if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
1460 rbuggyQSA.push( ":enabled", ":disabled" );
1463 // Support: Opera 10 - 11 only
1464 // Opera 10-11 does not throw on post-comma invalid pseudos
1465 el.querySelectorAll( "*,:x" );
1466 rbuggyQSA.push( ",.*:" );
1470 if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches ||
1471 docElem.webkitMatchesSelector ||
1472 docElem.mozMatchesSelector ||
1473 docElem.oMatchesSelector ||
1474 docElem.msMatchesSelector ) ) ) ) {
1476 assert( function( el ) {
1478 // Check to see if it's possible to do matchesSelector
1479 // on a disconnected node (IE 9)
1480 support.disconnectedMatch = matches.call( el, "*" );
1482 // This should fail with an exception
1483 // Gecko does not error, returns false instead
1484 matches.call( el, "[s!='']:x" );
1485 rbuggyMatches.push( "!=", pseudos );
1489 if ( !support.cssSupportsSelector ) {
1491 // Support: Chrome 105+, Safari 15.4+
1492 // `:has()` uses a forgiving selector list as an argument so our regular
1493 // `try-catch` mechanism fails to catch `:has()` with arguments not supported
1494 // natively like `:has(:contains("Foo"))`. Where supported & spec-compliant,
1495 // we now use `CSS.supports("selector(SELECTOR_TO_BE_TESTED)")` but outside
1496 // that, let's mark `:has` as buggy to always use jQuery traversal for
1498 rbuggyQSA.push( ":has" );
1501 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
1502 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) );
1505 ---------------------------------------------------------------------- */
1506 hasCompare = rnative.test( docElem.compareDocumentPosition );
1508 // Element contains another
1509 // Purposefully self-exclusive
1510 // As in, an element does not contain itself
1511 contains = hasCompare || rnative.test( docElem.contains ) ?
1514 // Support: IE <9 only
1515 // IE doesn't have `contains` on `document` so we need to check for
1516 // `documentElement` presence.
1517 // We need to fall back to `a` when `documentElement` is missing
1518 // as `ownerDocument` of elements within `<template/>` may have
1519 // a null one - a default behavior of all modern browsers.
1520 var adown = a.nodeType === 9 && a.documentElement || a,
1521 bup = b && b.parentNode;
1522 return a === bup || !!( bup && bup.nodeType === 1 && (
1524 adown.contains( bup ) :
1525 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1530 while ( ( b = b.parentNode ) ) {
1540 ---------------------------------------------------------------------- */
1542 // Document order sorting
1543 sortOrder = hasCompare ?
1546 // Flag for duplicate removal
1548 hasDuplicate = true;
1552 // Sort on method existence if only one input has compareDocumentPosition
1553 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1558 // Calculate position if both inputs belong to the same document
1559 // Support: IE 11+, Edge 17 - 18+
1560 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1561 // two documents; shallow comparisons work.
1562 // eslint-disable-next-line eqeqeq
1563 compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
1564 a.compareDocumentPosition( b ) :
1566 // Otherwise we know they are disconnected
1569 // Disconnected nodes
1571 ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
1573 // Choose the first element that is related to our preferred document
1574 // Support: IE 11+, Edge 17 - 18+
1575 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1576 // two documents; shallow comparisons work.
1577 // eslint-disable-next-line eqeqeq
1578 if ( a == document || a.ownerDocument == preferredDoc &&
1579 contains( preferredDoc, a ) ) {
1583 // Support: IE 11+, Edge 17 - 18+
1584 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1585 // two documents; shallow comparisons work.
1586 // eslint-disable-next-line eqeqeq
1587 if ( b == document || b.ownerDocument == preferredDoc &&
1588 contains( preferredDoc, b ) ) {
1592 // Maintain original order
1594 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1598 return compare & 4 ? -1 : 1;
1602 // Exit early if the nodes are identical
1604 hasDuplicate = true;
1615 // Parentless nodes are either documents or disconnected
1616 if ( !aup || !bup ) {
1618 // Support: IE 11+, Edge 17 - 18+
1619 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1620 // two documents; shallow comparisons work.
1621 /* eslint-disable eqeqeq */
1622 return a == document ? -1 :
1624 /* eslint-enable eqeqeq */
1628 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1631 // If the nodes are siblings, we can do a quick check
1632 } else if ( aup === bup ) {
1633 return siblingCheck( a, b );
1636 // Otherwise we need full lists of their ancestors for comparison
1638 while ( ( cur = cur.parentNode ) ) {
1642 while ( ( cur = cur.parentNode ) ) {
1646 // Walk down the tree looking for a discrepancy
1647 while ( ap[ i ] === bp[ i ] ) {
1653 // Do a sibling check if the nodes have a common ancestor
1654 siblingCheck( ap[ i ], bp[ i ] ) :
1656 // Otherwise nodes in our document sort first
1657 // Support: IE 11+, Edge 17 - 18+
1658 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1659 // two documents; shallow comparisons work.
1660 /* eslint-disable eqeqeq */
1661 ap[ i ] == preferredDoc ? -1 :
1662 bp[ i ] == preferredDoc ? 1 :
1663 /* eslint-enable eqeqeq */
1670 Sizzle.matches = function( expr, elements ) {
1671 return Sizzle( expr, null, null, elements );
1674 Sizzle.matchesSelector = function( elem, expr ) {
1675 setDocument( elem );
1677 if ( support.matchesSelector && documentIsHTML &&
1678 !nonnativeSelectorCache[ expr + " " ] &&
1679 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1680 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1683 var ret = matches.call( elem, expr );
1685 // IE 9's matchesSelector returns false on disconnected nodes
1686 if ( ret || support.disconnectedMatch ||
1688 // As well, disconnected nodes are said to be in a document
1690 elem.document && elem.document.nodeType !== 11 ) {
1694 nonnativeSelectorCache( expr, true );
1698 return Sizzle( expr, document, null, [ elem ] ).length > 0;
1701 Sizzle.contains = function( context, elem ) {
1703 // Set document vars if needed
1704 // Support: IE 11+, Edge 17 - 18+
1705 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1706 // two documents; shallow comparisons work.
1707 // eslint-disable-next-line eqeqeq
1708 if ( ( context.ownerDocument || context ) != document ) {
1709 setDocument( context );
1711 return contains( context, elem );
1714 Sizzle.attr = function( elem, name ) {
1716 // Set document vars if needed
1717 // Support: IE 11+, Edge 17 - 18+
1718 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1719 // two documents; shallow comparisons work.
1720 // eslint-disable-next-line eqeqeq
1721 if ( ( elem.ownerDocument || elem ) != document ) {
1722 setDocument( elem );
1725 var fn = Expr.attrHandle[ name.toLowerCase() ],
1727 // Don't get fooled by Object.prototype properties (jQuery #13807)
1728 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1729 fn( elem, name, !documentIsHTML ) :
1732 return val !== undefined ?
1734 support.attributes || !documentIsHTML ?
1735 elem.getAttribute( name ) :
1736 ( val = elem.getAttributeNode( name ) ) && val.specified ?
1741 Sizzle.escape = function( sel ) {
1742 return ( sel + "" ).replace( rcssescape, fcssescape );
1745 Sizzle.error = function( msg ) {
1746 throw new Error( "Syntax error, unrecognized expression: " + msg );
1750 * Document sorting and removing duplicates
1751 * @param {ArrayLike} results
1753 Sizzle.uniqueSort = function( results ) {
1759 // Unless we *know* we can detect duplicates, assume their presence
1760 hasDuplicate = !support.detectDuplicates;
1761 sortInput = !support.sortStable && results.slice( 0 );
1762 results.sort( sortOrder );
1764 if ( hasDuplicate ) {
1765 while ( ( elem = results[ i++ ] ) ) {
1766 if ( elem === results[ i ] ) {
1767 j = duplicates.push( i );
1771 results.splice( duplicates[ j ], 1 );
1775 // Clear input after sorting to release objects
1776 // See https://github.com/jquery/sizzle/pull/225
1783 * Utility function for retrieving the text value of an array of DOM nodes
1784 * @param {Array|Element} elem
1786 getText = Sizzle.getText = function( elem ) {
1790 nodeType = elem.nodeType;
1794 // If no nodeType, this is expected to be an array
1795 while ( ( node = elem[ i++ ] ) ) {
1797 // Do not traverse comment nodes
1798 ret += getText( node );
1800 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1802 // Use textContent for elements
1803 // innerText usage removed for consistency of new lines (jQuery #11153)
1804 if ( typeof elem.textContent === "string" ) {
1805 return elem.textContent;
1808 // Traverse its children
1809 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1810 ret += getText( elem );
1813 } else if ( nodeType === 3 || nodeType === 4 ) {
1814 return elem.nodeValue;
1817 // Do not include comment or processing instruction nodes
1822 Expr = Sizzle.selectors = {
1824 // Can be adjusted by the user
1827 createPseudo: markFunction,
1836 ">": { dir: "parentNode", first: true },
1837 " ": { dir: "parentNode" },
1838 "+": { dir: "previousSibling", first: true },
1839 "~": { dir: "previousSibling" }
1843 "ATTR": function( match ) {
1844 match[ 1 ] = match[ 1 ].replace( runescape, funescape );
1846 // Move the given value to match[3] whether quoted or unquoted
1847 match[ 3 ] = ( match[ 3 ] || match[ 4 ] ||
1848 match[ 5 ] || "" ).replace( runescape, funescape );
1850 if ( match[ 2 ] === "~=" ) {
1851 match[ 3 ] = " " + match[ 3 ] + " ";
1854 return match.slice( 0, 4 );
1857 "CHILD": function( match ) {
1859 /* matches from matchExpr["CHILD"]
1860 1 type (only|nth|...)
1861 2 what (child|of-type)
1862 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1863 4 xn-component of xn+y argument ([+-]?\d*n|)
1864 5 sign of xn-component
1866 7 sign of y-component
1869 match[ 1 ] = match[ 1 ].toLowerCase();
1871 if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
1873 // nth-* requires argument
1874 if ( !match[ 3 ] ) {
1875 Sizzle.error( match[ 0 ] );
1878 // numeric x and y parameters for Expr.filter.CHILD
1879 // remember that false/true cast respectively to 0/1
1880 match[ 4 ] = +( match[ 4 ] ?
1881 match[ 5 ] + ( match[ 6 ] || 1 ) :
1882 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) );
1883 match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
1885 // other types prohibit arguments
1886 } else if ( match[ 3 ] ) {
1887 Sizzle.error( match[ 0 ] );
1893 "PSEUDO": function( match ) {
1895 unquoted = !match[ 6 ] && match[ 2 ];
1897 if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) {
1901 // Accept quoted arguments as-is
1903 match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
1905 // Strip excess characters from unquoted arguments
1906 } else if ( unquoted && rpseudo.test( unquoted ) &&
1908 // Get excess from tokenize (recursively)
1909 ( excess = tokenize( unquoted, true ) ) &&
1911 // advance to the next closing parenthesis
1912 ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
1914 // excess is a negative index
1915 match[ 0 ] = match[ 0 ].slice( 0, excess );
1916 match[ 2 ] = unquoted.slice( 0, excess );
1919 // Return only captures needed by the pseudo filter method (type and argument)
1920 return match.slice( 0, 3 );
1926 "TAG": function( nodeNameSelector ) {
1927 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1928 return nodeNameSelector === "*" ?
1933 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1937 "CLASS": function( className ) {
1938 var pattern = classCache[ className + " " ];
1941 ( pattern = new RegExp( "(^|" + whitespace +
1942 ")" + className + "(" + whitespace + "|$)" ) ) && classCache(
1943 className, function( elem ) {
1944 return pattern.test(
1945 typeof elem.className === "string" && elem.className ||
1946 typeof elem.getAttribute !== "undefined" &&
1947 elem.getAttribute( "class" ) ||
1953 "ATTR": function( name, operator, check ) {
1954 return function( elem ) {
1955 var result = Sizzle.attr( elem, name );
1957 if ( result == null ) {
1958 return operator === "!=";
1966 /* eslint-disable max-len */
1968 return operator === "=" ? result === check :
1969 operator === "!=" ? result !== check :
1970 operator === "^=" ? check && result.indexOf( check ) === 0 :
1971 operator === "*=" ? check && result.indexOf( check ) > -1 :
1972 operator === "$=" ? check && result.slice( -check.length ) === check :
1973 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
1974 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1976 /* eslint-enable max-len */
1981 "CHILD": function( type, what, _argument, first, last ) {
1982 var simple = type.slice( 0, 3 ) !== "nth",
1983 forward = type.slice( -4 ) !== "last",
1984 ofType = what === "of-type";
1986 return first === 1 && last === 0 ?
1988 // Shortcut for :nth-*(n)
1990 return !!elem.parentNode;
1993 function( elem, _context, xml ) {
1994 var cache, uniqueCache, outerCache, node, nodeIndex, start,
1995 dir = simple !== forward ? "nextSibling" : "previousSibling",
1996 parent = elem.parentNode,
1997 name = ofType && elem.nodeName.toLowerCase(),
1998 useCache = !xml && !ofType,
2003 // :(first|last|only)-(child|of-type)
2007 while ( ( node = node[ dir ] ) ) {
2009 node.nodeName.toLowerCase() === name :
2010 node.nodeType === 1 ) {
2016 // Reverse direction for :only-* (if we haven't yet done so)
2017 start = dir = type === "only" && !start && "nextSibling";
2022 start = [ forward ? parent.firstChild : parent.lastChild ];
2024 // non-xml :nth-child(...) stores cache data on `parent`
2025 if ( forward && useCache ) {
2027 // Seek `elem` from a previously-cached index
2029 // ...in a gzip-friendly way
2031 outerCache = node[ expando ] || ( node[ expando ] = {} );
2033 // Support: IE <9 only
2034 // Defend against cloned attroperties (jQuery gh-1709)
2035 uniqueCache = outerCache[ node.uniqueID ] ||
2036 ( outerCache[ node.uniqueID ] = {} );
2038 cache = uniqueCache[ type ] || [];
2039 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
2040 diff = nodeIndex && cache[ 2 ];
2041 node = nodeIndex && parent.childNodes[ nodeIndex ];
2043 while ( ( node = ++nodeIndex && node && node[ dir ] ||
2045 // Fallback to seeking `elem` from the start
2046 ( diff = nodeIndex = 0 ) || start.pop() ) ) {
2048 // When found, cache indexes on `parent` and break
2049 if ( node.nodeType === 1 && ++diff && node === elem ) {
2050 uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
2057 // Use previously-cached element index if available
2060 // ...in a gzip-friendly way
2062 outerCache = node[ expando ] || ( node[ expando ] = {} );
2064 // Support: IE <9 only
2065 // Defend against cloned attroperties (jQuery gh-1709)
2066 uniqueCache = outerCache[ node.uniqueID ] ||
2067 ( outerCache[ node.uniqueID ] = {} );
2069 cache = uniqueCache[ type ] || [];
2070 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
2074 // xml :nth-child(...)
2075 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
2076 if ( diff === false ) {
2078 // Use the same loop as above to seek `elem` from the start
2079 while ( ( node = ++nodeIndex && node && node[ dir ] ||
2080 ( diff = nodeIndex = 0 ) || start.pop() ) ) {
2083 node.nodeName.toLowerCase() === name :
2084 node.nodeType === 1 ) &&
2087 // Cache the index of each encountered element
2089 outerCache = node[ expando ] ||
2090 ( node[ expando ] = {} );
2092 // Support: IE <9 only
2093 // Defend against cloned attroperties (jQuery gh-1709)
2094 uniqueCache = outerCache[ node.uniqueID ] ||
2095 ( outerCache[ node.uniqueID ] = {} );
2097 uniqueCache[ type ] = [ dirruns, diff ];
2100 if ( node === elem ) {
2108 // Incorporate the offset, then check against cycle size
2110 return diff === first || ( diff % first === 0 && diff / first >= 0 );
2115 "PSEUDO": function( pseudo, argument ) {
2117 // pseudo-class names are case-insensitive
2118 // http://www.w3.org/TR/selectors/#pseudo-classes
2119 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
2120 // Remember that setFilters inherits from pseudos
2122 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
2123 Sizzle.error( "unsupported pseudo: " + pseudo );
2125 // The user may use createPseudo to indicate that
2126 // arguments are needed to create the filter function
2127 // just as Sizzle does
2128 if ( fn[ expando ] ) {
2129 return fn( argument );
2132 // But maintain support for old signatures
2133 if ( fn.length > 1 ) {
2134 args = [ pseudo, pseudo, "", argument ];
2135 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
2136 markFunction( function( seed, matches ) {
2138 matched = fn( seed, argument ),
2141 idx = indexOf( seed, matched[ i ] );
2142 seed[ idx ] = !( matches[ idx ] = matched[ i ] );
2146 return fn( elem, 0, args );
2156 // Potentially complex pseudos
2157 "not": markFunction( function( selector ) {
2159 // Trim the selector passed to compile
2160 // to avoid treating leading and trailing
2161 // spaces as combinators
2164 matcher = compile( selector.replace( rtrim, "$1" ) );
2166 return matcher[ expando ] ?
2167 markFunction( function( seed, matches, _context, xml ) {
2169 unmatched = matcher( seed, null, xml, [] ),
2172 // Match elements unmatched by `matcher`
2174 if ( ( elem = unmatched[ i ] ) ) {
2175 seed[ i ] = !( matches[ i ] = elem );
2179 function( elem, _context, xml ) {
2181 matcher( input, null, xml, results );
2183 // Don't keep the element (issue #299)
2185 return !results.pop();
2189 "has": markFunction( function( selector ) {
2190 return function( elem ) {
2191 return Sizzle( selector, elem ).length > 0;
2195 "contains": markFunction( function( text ) {
2196 text = text.replace( runescape, funescape );
2197 return function( elem ) {
2198 return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
2202 // "Whether an element is represented by a :lang() selector
2203 // is based solely on the element's language value
2204 // being equal to the identifier C,
2205 // or beginning with the identifier C immediately followed by "-".
2206 // The matching of C against the element's language value is performed case-insensitively.
2207 // The identifier C does not have to be a valid language name."
2208 // http://www.w3.org/TR/selectors/#lang-pseudo
2209 "lang": markFunction( function( lang ) {
2211 // lang value must be a valid identifier
2212 if ( !ridentifier.test( lang || "" ) ) {
2213 Sizzle.error( "unsupported lang: " + lang );
2215 lang = lang.replace( runescape, funescape ).toLowerCase();
2216 return function( elem ) {
2219 if ( ( elemLang = documentIsHTML ?
2221 elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
2223 elemLang = elemLang.toLowerCase();
2224 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
2226 } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
2232 "target": function( elem ) {
2233 var hash = window.location && window.location.hash;
2234 return hash && hash.slice( 1 ) === elem.id;
2237 "root": function( elem ) {
2238 return elem === docElem;
2241 "focus": function( elem ) {
2242 return elem === document.activeElement &&
2243 ( !document.hasFocus || document.hasFocus() ) &&
2244 !!( elem.type || elem.href || ~elem.tabIndex );
2247 // Boolean properties
2248 "enabled": createDisabledPseudo( false ),
2249 "disabled": createDisabledPseudo( true ),
2251 "checked": function( elem ) {
2253 // In CSS3, :checked should return both checked and selected elements
2254 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
2255 var nodeName = elem.nodeName.toLowerCase();
2256 return ( nodeName === "input" && !!elem.checked ) ||
2257 ( nodeName === "option" && !!elem.selected );
2260 "selected": function( elem ) {
2262 // Accessing this property makes selected-by-default
2263 // options in Safari work properly
2264 if ( elem.parentNode ) {
2265 // eslint-disable-next-line no-unused-expressions
2266 elem.parentNode.selectedIndex;
2269 return elem.selected === true;
2273 "empty": function( elem ) {
2275 // http://www.w3.org/TR/selectors/#empty-pseudo
2276 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
2277 // but not by others (comment: 8; processing instruction: 7; etc.)
2278 // nodeType < 6 works because attributes (2) do not appear as children
2279 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
2280 if ( elem.nodeType < 6 ) {
2287 "parent": function( elem ) {
2288 return !Expr.pseudos[ "empty" ]( elem );
2291 // Element/input types
2292 "header": function( elem ) {
2293 return rheader.test( elem.nodeName );
2296 "input": function( elem ) {
2297 return rinputs.test( elem.nodeName );
2300 "button": function( elem ) {
2301 var name = elem.nodeName.toLowerCase();
2302 return name === "input" && elem.type === "button" || name === "button";
2305 "text": function( elem ) {
2307 return elem.nodeName.toLowerCase() === "input" &&
2308 elem.type === "text" &&
2310 // Support: IE <10 only
2311 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
2312 ( ( attr = elem.getAttribute( "type" ) ) == null ||
2313 attr.toLowerCase() === "text" );
2316 // Position-in-collection
2317 "first": createPositionalPseudo( function() {
2321 "last": createPositionalPseudo( function( _matchIndexes, length ) {
2322 return [ length - 1 ];
2325 "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) {
2326 return [ argument < 0 ? argument + length : argument ];
2329 "even": createPositionalPseudo( function( matchIndexes, length ) {
2331 for ( ; i < length; i += 2 ) {
2332 matchIndexes.push( i );
2334 return matchIndexes;
2337 "odd": createPositionalPseudo( function( matchIndexes, length ) {
2339 for ( ; i < length; i += 2 ) {
2340 matchIndexes.push( i );
2342 return matchIndexes;
2345 "lt": createPositionalPseudo( function( matchIndexes, length, argument ) {
2346 var i = argument < 0 ?
2351 for ( ; --i >= 0; ) {
2352 matchIndexes.push( i );
2354 return matchIndexes;
2357 "gt": createPositionalPseudo( function( matchIndexes, length, argument ) {
2358 var i = argument < 0 ? argument + length : argument;
2359 for ( ; ++i < length; ) {
2360 matchIndexes.push( i );
2362 return matchIndexes;
2367 Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ];
2369 // Add button/input type pseudos
2370 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
2371 Expr.pseudos[ i ] = createInputPseudo( i );
2373 for ( i in { submit: true, reset: true } ) {
2374 Expr.pseudos[ i ] = createButtonPseudo( i );
2377 // Easy API for creating new setFilters
2378 function setFilters() {}
2379 setFilters.prototype = Expr.filters = Expr.pseudos;
2380 Expr.setFilters = new setFilters();
2382 tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
2383 var matched, match, tokens, type,
2384 soFar, groups, preFilters,
2385 cached = tokenCache[ selector + " " ];
2388 return parseOnly ? 0 : cached.slice( 0 );
2393 preFilters = Expr.preFilter;
2397 // Comma and first run
2398 if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
2401 // Don't consume trailing commas as valid
2402 soFar = soFar.slice( match[ 0 ].length ) || soFar;
2404 groups.push( ( tokens = [] ) );
2410 if ( ( match = rcombinators.exec( soFar ) ) ) {
2411 matched = match.shift();
2415 // Cast descendant combinators to space
2416 type: match[ 0 ].replace( rtrim, " " )
2418 soFar = soFar.slice( matched.length );
2422 for ( type in Expr.filter ) {
2423 if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
2424 ( match = preFilters[ type ]( match ) ) ) ) {
2425 matched = match.shift();
2431 soFar = soFar.slice( matched.length );
2440 // Return the length of the invalid excess
2441 // if we're just parsing
2442 // Otherwise, throw an error or return tokens
2446 Sizzle.error( selector ) :
2449 tokenCache( selector, groups ).slice( 0 );
2452 function toSelector( tokens ) {
2454 len = tokens.length,
2456 for ( ; i < len; i++ ) {
2457 selector += tokens[ i ].value;
2462 function addCombinator( matcher, combinator, base ) {
2463 var dir = combinator.dir,
2464 skip = combinator.next,
2466 checkNonElements = base && key === "parentNode",
2469 return combinator.first ?
2471 // Check against closest ancestor/preceding element
2472 function( elem, context, xml ) {
2473 while ( ( elem = elem[ dir ] ) ) {
2474 if ( elem.nodeType === 1 || checkNonElements ) {
2475 return matcher( elem, context, xml );
2481 // Check against all ancestor/preceding elements
2482 function( elem, context, xml ) {
2483 var oldCache, uniqueCache, outerCache,
2484 newCache = [ dirruns, doneName ];
2486 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
2488 while ( ( elem = elem[ dir ] ) ) {
2489 if ( elem.nodeType === 1 || checkNonElements ) {
2490 if ( matcher( elem, context, xml ) ) {
2496 while ( ( elem = elem[ dir ] ) ) {
2497 if ( elem.nodeType === 1 || checkNonElements ) {
2498 outerCache = elem[ expando ] || ( elem[ expando ] = {} );
2500 // Support: IE <9 only
2501 // Defend against cloned attroperties (jQuery gh-1709)
2502 uniqueCache = outerCache[ elem.uniqueID ] ||
2503 ( outerCache[ elem.uniqueID ] = {} );
2505 if ( skip && skip === elem.nodeName.toLowerCase() ) {
2506 elem = elem[ dir ] || elem;
2507 } else if ( ( oldCache = uniqueCache[ key ] ) &&
2508 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
2510 // Assign to newCache so results back-propagate to previous elements
2511 return ( newCache[ 2 ] = oldCache[ 2 ] );
2514 // Reuse newcache so results back-propagate to previous elements
2515 uniqueCache[ key ] = newCache;
2517 // A match means we're done; a fail means we have to keep checking
2518 if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
2529 function elementMatcher( matchers ) {
2530 return matchers.length > 1 ?
2531 function( elem, context, xml ) {
2532 var i = matchers.length;
2534 if ( !matchers[ i ]( elem, context, xml ) ) {
2543 function multipleContexts( selector, contexts, results ) {
2545 len = contexts.length;
2546 for ( ; i < len; i++ ) {
2547 Sizzle( selector, contexts[ i ], results );
2552 function condense( unmatched, map, filter, context, xml ) {
2556 len = unmatched.length,
2557 mapped = map != null;
2559 for ( ; i < len; i++ ) {
2560 if ( ( elem = unmatched[ i ] ) ) {
2561 if ( !filter || filter( elem, context, xml ) ) {
2562 newUnmatched.push( elem );
2570 return newUnmatched;
2573 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2574 if ( postFilter && !postFilter[ expando ] ) {
2575 postFilter = setMatcher( postFilter );
2577 if ( postFinder && !postFinder[ expando ] ) {
2578 postFinder = setMatcher( postFinder, postSelector );
2580 return markFunction( function( seed, results, context, xml ) {
2584 preexisting = results.length,
2586 // Get initial elements from seed or context
2587 elems = seed || multipleContexts(
2589 context.nodeType ? [ context ] : context,
2593 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2594 matcherIn = preFilter && ( seed || !selector ) ?
2595 condense( elems, preMap, preFilter, context, xml ) :
2598 matcherOut = matcher ?
2600 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2601 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2603 // ...intermediate processing is necessary
2606 // ...otherwise use results directly
2610 // Find primary matches
2612 matcher( matcherIn, matcherOut, context, xml );
2617 temp = condense( matcherOut, postMap );
2618 postFilter( temp, [], context, xml );
2620 // Un-match failing elements by moving them back to matcherIn
2623 if ( ( elem = temp[ i ] ) ) {
2624 matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
2630 if ( postFinder || preFilter ) {
2633 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2635 i = matcherOut.length;
2637 if ( ( elem = matcherOut[ i ] ) ) {
2639 // Restore matcherIn since elem is not yet a final match
2640 temp.push( ( matcherIn[ i ] = elem ) );
2643 postFinder( null, ( matcherOut = [] ), temp, xml );
2646 // Move matched elements from seed to results to keep them synchronized
2647 i = matcherOut.length;
2649 if ( ( elem = matcherOut[ i ] ) &&
2650 ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) {
2652 seed[ temp ] = !( results[ temp ] = elem );
2657 // Add elements to results, through postFinder if defined
2659 matcherOut = condense(
2660 matcherOut === results ?
2661 matcherOut.splice( preexisting, matcherOut.length ) :
2665 postFinder( null, results, matcherOut, xml );
2667 push.apply( results, matcherOut );
2673 function matcherFromTokens( tokens ) {
2674 var checkContext, matcher, j,
2675 len = tokens.length,
2676 leadingRelative = Expr.relative[ tokens[ 0 ].type ],
2677 implicitRelative = leadingRelative || Expr.relative[ " " ],
2678 i = leadingRelative ? 1 : 0,
2680 // The foundational matcher ensures that elements are reachable from top-level context(s)
2681 matchContext = addCombinator( function( elem ) {
2682 return elem === checkContext;
2683 }, implicitRelative, true ),
2684 matchAnyContext = addCombinator( function( elem ) {
2685 return indexOf( checkContext, elem ) > -1;
2686 }, implicitRelative, true ),
2687 matchers = [ function( elem, context, xml ) {
2688 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2689 ( checkContext = context ).nodeType ?
2690 matchContext( elem, context, xml ) :
2691 matchAnyContext( elem, context, xml ) );
2693 // Avoid hanging onto element (issue #299)
2694 checkContext = null;
2698 for ( ; i < len; i++ ) {
2699 if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
2700 matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
2702 matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
2704 // Return special upon seeing a positional matcher
2705 if ( matcher[ expando ] ) {
2707 // Find the next relative operator (if any) for proper handling
2709 for ( ; j < len; j++ ) {
2710 if ( Expr.relative[ tokens[ j ].type ] ) {
2715 i > 1 && elementMatcher( matchers ),
2716 i > 1 && toSelector(
2718 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2721 .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
2722 ).replace( rtrim, "$1" ),
2724 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2725 j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
2726 j < len && toSelector( tokens )
2729 matchers.push( matcher );
2733 return elementMatcher( matchers );
2736 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2737 var bySet = setMatchers.length > 0,
2738 byElement = elementMatchers.length > 0,
2739 superMatcher = function( seed, context, xml, results, outermost ) {
2740 var elem, j, matcher,
2743 unmatched = seed && [],
2745 contextBackup = outermostContext,
2747 // We must always have either seed elements or outermost context
2748 elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ),
2750 // Use integer dirruns iff this is the outermost matcher
2751 dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
2756 // Support: IE 11+, Edge 17 - 18+
2757 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2758 // two documents; shallow comparisons work.
2759 // eslint-disable-next-line eqeqeq
2760 outermostContext = context == document || context || outermost;
2763 // Add elements passing elementMatchers directly to results
2764 // Support: IE<9, Safari
2765 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2766 for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
2767 if ( byElement && elem ) {
2770 // Support: IE 11+, Edge 17 - 18+
2771 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2772 // two documents; shallow comparisons work.
2773 // eslint-disable-next-line eqeqeq
2774 if ( !context && elem.ownerDocument != document ) {
2775 setDocument( elem );
2776 xml = !documentIsHTML;
2778 while ( ( matcher = elementMatchers[ j++ ] ) ) {
2779 if ( matcher( elem, context || document, xml ) ) {
2780 results.push( elem );
2785 dirruns = dirrunsUnique;
2789 // Track unmatched elements for set filters
2792 // They will have gone through all possible matchers
2793 if ( ( elem = !matcher && elem ) ) {
2797 // Lengthen the array for every element, matched or not
2799 unmatched.push( elem );
2804 // `i` is now the count of elements visited above, and adding it to `matchedCount`
2805 // makes the latter nonnegative.
2808 // Apply set filters to unmatched elements
2809 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2810 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2811 // no element matchers and no seed.
2812 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2813 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2814 // numerically zero.
2815 if ( bySet && i !== matchedCount ) {
2817 while ( ( matcher = setMatchers[ j++ ] ) ) {
2818 matcher( unmatched, setMatched, context, xml );
2823 // Reintegrate element matches to eliminate the need for sorting
2824 if ( matchedCount > 0 ) {
2826 if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
2827 setMatched[ i ] = pop.call( results );
2832 // Discard index placeholder values to get only actual matches
2833 setMatched = condense( setMatched );
2836 // Add matches to results
2837 push.apply( results, setMatched );
2839 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2840 if ( outermost && !seed && setMatched.length > 0 &&
2841 ( matchedCount + setMatchers.length ) > 1 ) {
2843 Sizzle.uniqueSort( results );
2847 // Override manipulation of globals by nested matchers
2849 dirruns = dirrunsUnique;
2850 outermostContext = contextBackup;
2857 markFunction( superMatcher ) :
2861 compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
2864 elementMatchers = [],
2865 cached = compilerCache[ selector + " " ];
2869 // Generate a function of recursive functions that can be used to check each element
2871 match = tokenize( selector );
2875 cached = matcherFromTokens( match[ i ] );
2876 if ( cached[ expando ] ) {
2877 setMatchers.push( cached );
2879 elementMatchers.push( cached );
2883 // Cache the compiled function
2884 cached = compilerCache(
2886 matcherFromGroupMatchers( elementMatchers, setMatchers )
2889 // Save selector and tokenization
2890 cached.selector = selector;
2896 * A low-level selection function that works with Sizzle's compiled
2897 * selector functions
2898 * @param {String|Function} selector A selector or a pre-compiled
2899 * selector function built with Sizzle.compile
2900 * @param {Element} context
2901 * @param {Array} [results]
2902 * @param {Array} [seed] A set of elements to match against
2904 select = Sizzle.select = function( selector, context, results, seed ) {
2905 var i, tokens, token, type, find,
2906 compiled = typeof selector === "function" && selector,
2907 match = !seed && tokenize( ( selector = compiled.selector || selector ) );
2909 results = results || [];
2911 // Try to minimize operations if there is only one selector in the list and no seed
2912 // (the latter of which guarantees us context)
2913 if ( match.length === 1 ) {
2915 // Reduce context if the leading compound selector is an ID
2916 tokens = match[ 0 ] = match[ 0 ].slice( 0 );
2917 if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
2918 context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
2920 context = ( Expr.find[ "ID" ]( token.matches[ 0 ]
2921 .replace( runescape, funescape ), context ) || [] )[ 0 ];
2925 // Precompiled matchers will still verify ancestry, so step up a level
2926 } else if ( compiled ) {
2927 context = context.parentNode;
2930 selector = selector.slice( tokens.shift().value.length );
2933 // Fetch a seed set for right-to-left matching
2934 i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length;
2936 token = tokens[ i ];
2938 // Abort if we hit a combinator
2939 if ( Expr.relative[ ( type = token.type ) ] ) {
2942 if ( ( find = Expr.find[ type ] ) ) {
2944 // Search, expanding context for leading sibling combinators
2946 token.matches[ 0 ].replace( runescape, funescape ),
2947 rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) ||
2951 // If seed is empty or no tokens remain, we can return early
2952 tokens.splice( i, 1 );
2953 selector = seed.length && toSelector( tokens );
2955 push.apply( results, seed );
2965 // Compile and execute a filtering function if one is not provided
2966 // Provide `match` to avoid retokenization if we modified the selector above
2967 ( compiled || compile( selector, match ) )(
2972 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
2977 // One-time assignments
2980 support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
2982 // Support: Chrome 14-35+
2983 // Always assume duplicates if they aren't passed to the comparison function
2984 support.detectDuplicates = !!hasDuplicate;
2986 // Initialize against the default document
2989 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2990 // Detached nodes confoundingly follow *each other*
2991 support.sortDetached = assert( function( el ) {
2993 // Should return 1, but returns 4 (following)
2994 return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
2998 // Prevent attribute/property "interpolation"
2999 // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
3000 if ( !assert( function( el ) {
3001 el.innerHTML = "<a href='#'></a>";
3002 return el.firstChild.getAttribute( "href" ) === "#";
3004 addHandle( "type|href|height|width", function( elem, name, isXML ) {
3006 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
3012 // Use defaultValue in place of getAttribute("value")
3013 if ( !support.attributes || !assert( function( el ) {
3014 el.innerHTML = "<input/>";
3015 el.firstChild.setAttribute( "value", "" );
3016 return el.firstChild.getAttribute( "value" ) === "";
3018 addHandle( "value", function( elem, _name, isXML ) {
3019 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
3020 return elem.defaultValue;
3026 // Use getAttributeNode to fetch booleans when getAttribute lies
3027 if ( !assert( function( el ) {
3028 return el.getAttribute( "disabled" ) == null;
3030 addHandle( booleans, function( elem, name, isXML ) {
3033 return elem[ name ] === true ? name.toLowerCase() :
3034 ( val = elem.getAttributeNode( name ) ) && val.specified ?
3047 jQuery.find = Sizzle;
3048 jQuery.expr = Sizzle.selectors;
3051 jQuery.expr[ ":" ] = jQuery.expr.pseudos;
3052 jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
3053 jQuery.text = Sizzle.getText;
3054 jQuery.isXMLDoc = Sizzle.isXML;
3055 jQuery.contains = Sizzle.contains;
3056 jQuery.escapeSelector = Sizzle.escape;
3061 var dir = function( elem, dir, until ) {
3063 truncate = until !== undefined;
3065 while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
3066 if ( elem.nodeType === 1 ) {
3067 if ( truncate && jQuery( elem ).is( until ) ) {
3070 matched.push( elem );
3077 var siblings = function( n, elem ) {
3080 for ( ; n; n = n.nextSibling ) {
3081 if ( n.nodeType === 1 && n !== elem ) {
3090 var rneedsContext = jQuery.expr.match.needsContext;
3094 function nodeName( elem, name ) {
3096 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
3099 var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
3103 // Implement the identical functionality for filter and not
3104 function winnow( elements, qualifier, not ) {
3105 if ( isFunction( qualifier ) ) {
3106 return jQuery.grep( elements, function( elem, i ) {
3107 return !!qualifier.call( elem, i, elem ) !== not;
3112 if ( qualifier.nodeType ) {
3113 return jQuery.grep( elements, function( elem ) {
3114 return ( elem === qualifier ) !== not;
3118 // Arraylike of elements (jQuery, arguments, Array)
3119 if ( typeof qualifier !== "string" ) {
3120 return jQuery.grep( elements, function( elem ) {
3121 return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
3125 // Filtered directly for both simple and complex selectors
3126 return jQuery.filter( qualifier, elements, not );
3129 jQuery.filter = function( expr, elems, not ) {
3130 var elem = elems[ 0 ];
3133 expr = ":not(" + expr + ")";
3136 if ( elems.length === 1 && elem.nodeType === 1 ) {
3137 return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
3140 return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
3141 return elem.nodeType === 1;
3146 find: function( selector ) {
3151 if ( typeof selector !== "string" ) {
3152 return this.pushStack( jQuery( selector ).filter( function() {
3153 for ( i = 0; i < len; i++ ) {
3154 if ( jQuery.contains( self[ i ], this ) ) {
3161 ret = this.pushStack( [] );
3163 for ( i = 0; i < len; i++ ) {
3164 jQuery.find( selector, self[ i ], ret );
3167 return len > 1 ? jQuery.uniqueSort( ret ) : ret;
3169 filter: function( selector ) {
3170 return this.pushStack( winnow( this, selector || [], false ) );
3172 not: function( selector ) {
3173 return this.pushStack( winnow( this, selector || [], true ) );
3175 is: function( selector ) {
3179 // If this is a positional/relative selector, check membership in the returned set
3180 // so $("p:first").is("p:last") won't return true for a doc with two "p".
3181 typeof selector === "string" && rneedsContext.test( selector ) ?
3182 jQuery( selector ) :
3190 // Initialize a jQuery object
3193 // A central reference to the root jQuery(document)
3196 // A simple way to check for HTML strings
3197 // Prioritize #id over <tag> to avoid XSS via location.hash (trac-9521)
3198 // Strict HTML recognition (trac-11290: must start with <)
3199 // Shortcut simple #id case for speed
3200 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
3202 init = jQuery.fn.init = function( selector, context, root ) {
3205 // HANDLE: $(""), $(null), $(undefined), $(false)
3210 // Method init() accepts an alternate rootjQuery
3211 // so migrate can support jQuery.sub (gh-2101)
3212 root = root || rootjQuery;
3214 // Handle HTML strings
3215 if ( typeof selector === "string" ) {
3216 if ( selector[ 0 ] === "<" &&
3217 selector[ selector.length - 1 ] === ">" &&
3218 selector.length >= 3 ) {
3220 // Assume that strings that start and end with <> are HTML and skip the regex check
3221 match = [ null, selector, null ];
3224 match = rquickExpr.exec( selector );
3227 // Match html or make sure no context is specified for #id
3228 if ( match && ( match[ 1 ] || !context ) ) {
3230 // HANDLE: $(html) -> $(array)
3232 context = context instanceof jQuery ? context[ 0 ] : context;
3234 // Option to run scripts is true for back-compat
3235 // Intentionally let the error be thrown if parseHTML is not present
3236 jQuery.merge( this, jQuery.parseHTML(
3238 context && context.nodeType ? context.ownerDocument || context : document,
3242 // HANDLE: $(html, props)
3243 if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
3244 for ( match in context ) {
3246 // Properties of context are called as methods if possible
3247 if ( isFunction( this[ match ] ) ) {
3248 this[ match ]( context[ match ] );
3250 // ...and otherwise set as attributes
3252 this.attr( match, context[ match ] );
3261 elem = document.getElementById( match[ 2 ] );
3265 // Inject the element directly into the jQuery object
3272 // HANDLE: $(expr, $(...))
3273 } else if ( !context || context.jquery ) {
3274 return ( context || root ).find( selector );
3276 // HANDLE: $(expr, context)
3277 // (which is just equivalent to: $(context).find(expr)
3279 return this.constructor( context ).find( selector );
3282 // HANDLE: $(DOMElement)
3283 } else if ( selector.nodeType ) {
3284 this[ 0 ] = selector;
3288 // HANDLE: $(function)
3289 // Shortcut for document ready
3290 } else if ( isFunction( selector ) ) {
3291 return root.ready !== undefined ?
3292 root.ready( selector ) :
3294 // Execute immediately if ready is not present
3298 return jQuery.makeArray( selector, this );
3301 // Give the init function the jQuery prototype for later instantiation
3302 init.prototype = jQuery.fn;
3304 // Initialize central reference
3305 rootjQuery = jQuery( document );
3308 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
3310 // Methods guaranteed to produce a unique set when starting from a unique set
3311 guaranteedUnique = {
3319 has: function( target ) {
3320 var targets = jQuery( target, this ),
3323 return this.filter( function() {
3325 for ( ; i < l; i++ ) {
3326 if ( jQuery.contains( this, targets[ i ] ) ) {
3333 closest: function( selectors, context ) {
3338 targets = typeof selectors !== "string" && jQuery( selectors );
3340 // Positional selectors never match, since there's no _selection_ context
3341 if ( !rneedsContext.test( selectors ) ) {
3342 for ( ; i < l; i++ ) {
3343 for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
3345 // Always skip document fragments
3346 if ( cur.nodeType < 11 && ( targets ?
3347 targets.index( cur ) > -1 :
3349 // Don't pass non-elements to Sizzle
3350 cur.nodeType === 1 &&
3351 jQuery.find.matchesSelector( cur, selectors ) ) ) {
3353 matched.push( cur );
3360 return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
3363 // Determine the position of an element within the set
3364 index: function( elem ) {
3366 // No argument, return index in parent
3368 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
3371 // Index in selector
3372 if ( typeof elem === "string" ) {
3373 return indexOf.call( jQuery( elem ), this[ 0 ] );
3376 // Locate the position of the desired element
3377 return indexOf.call( this,
3379 // If it receives a jQuery object, the first element is used
3380 elem.jquery ? elem[ 0 ] : elem
3384 add: function( selector, context ) {
3385 return this.pushStack(
3387 jQuery.merge( this.get(), jQuery( selector, context ) )
3392 addBack: function( selector ) {
3393 return this.add( selector == null ?
3394 this.prevObject : this.prevObject.filter( selector )
3399 function sibling( cur, dir ) {
3400 while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
3405 parent: function( elem ) {
3406 var parent = elem.parentNode;
3407 return parent && parent.nodeType !== 11 ? parent : null;
3409 parents: function( elem ) {
3410 return dir( elem, "parentNode" );
3412 parentsUntil: function( elem, _i, until ) {
3413 return dir( elem, "parentNode", until );
3415 next: function( elem ) {
3416 return sibling( elem, "nextSibling" );
3418 prev: function( elem ) {
3419 return sibling( elem, "previousSibling" );
3421 nextAll: function( elem ) {
3422 return dir( elem, "nextSibling" );
3424 prevAll: function( elem ) {
3425 return dir( elem, "previousSibling" );
3427 nextUntil: function( elem, _i, until ) {
3428 return dir( elem, "nextSibling", until );
3430 prevUntil: function( elem, _i, until ) {
3431 return dir( elem, "previousSibling", until );
3433 siblings: function( elem ) {
3434 return siblings( ( elem.parentNode || {} ).firstChild, elem );
3436 children: function( elem ) {
3437 return siblings( elem.firstChild );
3439 contents: function( elem ) {
3440 if ( elem.contentDocument != null &&
3443 // <object> elements with no `data` attribute has an object
3444 // `contentDocument` with a `null` prototype.
3445 getProto( elem.contentDocument ) ) {
3447 return elem.contentDocument;
3450 // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
3451 // Treat the template element as a regular one in browsers that
3452 // don't support it.
3453 if ( nodeName( elem, "template" ) ) {
3454 elem = elem.content || elem;
3457 return jQuery.merge( [], elem.childNodes );
3459 }, function( name, fn ) {
3460 jQuery.fn[ name ] = function( until, selector ) {
3461 var matched = jQuery.map( this, fn, until );
3463 if ( name.slice( -5 ) !== "Until" ) {
3467 if ( selector && typeof selector === "string" ) {
3468 matched = jQuery.filter( selector, matched );
3471 if ( this.length > 1 ) {
3473 // Remove duplicates
3474 if ( !guaranteedUnique[ name ] ) {
3475 jQuery.uniqueSort( matched );
3478 // Reverse order for parents* and prev-derivatives
3479 if ( rparentsprev.test( name ) ) {
3484 return this.pushStack( matched );
3487 var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
3491 // Convert String-formatted options into Object-formatted ones
3492 function createOptions( options ) {
3494 jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
3495 object[ flag ] = true;
3501 * Create a callback list using the following parameters:
3503 * options: an optional list of space-separated options that will change how
3504 * the callback list behaves or a more traditional option object
3506 * By default a callback list will act like an event callback list and can be
3507 * "fired" multiple times.
3511 * once: will ensure the callback list can only be fired once (like a Deferred)
3513 * memory: will keep track of previous values and will call any callback added
3514 * after the list has been fired right away with the latest "memorized"
3515 * values (like a Deferred)
3517 * unique: will ensure a callback can only be added once (no duplicate in the list)
3519 * stopOnFalse: interrupt callings when a callback returns false
3522 jQuery.Callbacks = function( options ) {
3524 // Convert options from String-formatted to Object-formatted if needed
3525 // (we check in cache first)
3526 options = typeof options === "string" ?
3527 createOptions( options ) :
3528 jQuery.extend( {}, options );
3530 var // Flag to know if list is currently firing
3533 // Last fire value for non-forgettable lists
3536 // Flag to know if list was already fired
3539 // Flag to prevent firing
3542 // Actual callback list
3545 // Queue of execution data for repeatable lists
3548 // Index of currently firing callback (modified by add/remove as needed)
3554 // Enforce single-firing
3555 locked = locked || options.once;
3557 // Execute callbacks for all pending executions,
3558 // respecting firingIndex overrides and runtime changes
3559 fired = firing = true;
3560 for ( ; queue.length; firingIndex = -1 ) {
3561 memory = queue.shift();
3562 while ( ++firingIndex < list.length ) {
3564 // Run callback and check for early termination
3565 if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
3566 options.stopOnFalse ) {
3568 // Jump to end and forget the data so .add doesn't re-fire
3569 firingIndex = list.length;
3575 // Forget the data if we're done with it
3576 if ( !options.memory ) {
3582 // Clean up if we're done firing for good
3585 // Keep an empty list if we have data for future add calls
3589 // Otherwise, this object is spent
3596 // Actual Callbacks object
3599 // Add a callback or a collection of callbacks to the list
3603 // If we have memory from a past run, we should fire after adding
3604 if ( memory && !firing ) {
3605 firingIndex = list.length - 1;
3606 queue.push( memory );
3609 ( function add( args ) {
3610 jQuery.each( args, function( _, arg ) {
3611 if ( isFunction( arg ) ) {
3612 if ( !options.unique || !self.has( arg ) ) {
3615 } else if ( arg && arg.length && toType( arg ) !== "string" ) {
3617 // Inspect recursively
3623 if ( memory && !firing ) {
3630 // Remove a callback from the list
3631 remove: function() {
3632 jQuery.each( arguments, function( _, arg ) {
3634 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
3635 list.splice( index, 1 );
3637 // Handle firing indexes
3638 if ( index <= firingIndex ) {
3646 // Check if a given callback is in the list.
3647 // If no argument is given, return whether or not list has callbacks attached.
3648 has: function( fn ) {
3650 jQuery.inArray( fn, list ) > -1 :
3654 // Remove all callbacks from the list
3662 // Disable .fire and .add
3663 // Abort any current/pending executions
3664 // Clear all callbacks and values
3665 disable: function() {
3666 locked = queue = [];
3670 disabled: function() {
3675 // Also disable .add unless we have memory (since it would have no effect)
3676 // Abort any pending executions
3678 locked = queue = [];
3679 if ( !memory && !firing ) {
3684 locked: function() {
3688 // Call all callbacks with the given context and arguments
3689 fireWith: function( context, args ) {
3692 args = [ context, args.slice ? args.slice() : args ];
3701 // Call all the callbacks with the given arguments
3703 self.fireWith( this, arguments );
3707 // To know if the callbacks have already been called at least once
3717 function Identity( v ) {
3720 function Thrower( ex ) {
3724 function adoptValue( value, resolve, reject, noValue ) {
3729 // Check for promise aspect first to privilege synchronous behavior
3730 if ( value && isFunction( ( method = value.promise ) ) ) {
3731 method.call( value ).done( resolve ).fail( reject );
3734 } else if ( value && isFunction( ( method = value.then ) ) ) {
3735 method.call( value, resolve, reject );
3737 // Other non-thenables
3740 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
3741 // * false: [ value ].slice( 0 ) => resolve( value )
3742 // * true: [ value ].slice( 1 ) => resolve()
3743 resolve.apply( undefined, [ value ].slice( noValue ) );
3746 // For Promises/A+, convert exceptions into rejections
3747 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
3748 // Deferred#then to conditionally suppress rejection.
3751 // Support: Android 4.0 only
3752 // Strict mode functions invoked without .call/.apply get global-object context
3753 reject.apply( undefined, [ value ] );
3759 Deferred: function( func ) {
3762 // action, add listener, callbacks,
3763 // ... .then handlers, argument index, [final state]
3764 [ "notify", "progress", jQuery.Callbacks( "memory" ),
3765 jQuery.Callbacks( "memory" ), 2 ],
3766 [ "resolve", "done", jQuery.Callbacks( "once memory" ),
3767 jQuery.Callbacks( "once memory" ), 0, "resolved" ],
3768 [ "reject", "fail", jQuery.Callbacks( "once memory" ),
3769 jQuery.Callbacks( "once memory" ), 1, "rejected" ]
3776 always: function() {
3777 deferred.done( arguments ).fail( arguments );
3780 "catch": function( fn ) {
3781 return promise.then( null, fn );
3784 // Keep pipe for back-compat
3785 pipe: function( /* fnDone, fnFail, fnProgress */ ) {
3786 var fns = arguments;
3788 return jQuery.Deferred( function( newDefer ) {
3789 jQuery.each( tuples, function( _i, tuple ) {
3791 // Map tuples (progress, done, fail) to arguments (done, fail, progress)
3792 var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
3794 // deferred.progress(function() { bind to newDefer or newDefer.notify })
3795 // deferred.done(function() { bind to newDefer or newDefer.resolve })
3796 // deferred.fail(function() { bind to newDefer or newDefer.reject })
3797 deferred[ tuple[ 1 ] ]( function() {
3798 var returned = fn && fn.apply( this, arguments );
3799 if ( returned && isFunction( returned.promise ) ) {
3801 .progress( newDefer.notify )
3802 .done( newDefer.resolve )
3803 .fail( newDefer.reject );
3805 newDefer[ tuple[ 0 ] + "With" ](
3807 fn ? [ returned ] : arguments
3815 then: function( onFulfilled, onRejected, onProgress ) {
3817 function resolve( depth, deferred, handler, special ) {
3821 mightThrow = function() {
3824 // Support: Promises/A+ section 2.3.3.3.3
3825 // https://promisesaplus.com/#point-59
3826 // Ignore double-resolution attempts
3827 if ( depth < maxDepth ) {
3831 returned = handler.apply( that, args );
3833 // Support: Promises/A+ section 2.3.1
3834 // https://promisesaplus.com/#point-48
3835 if ( returned === deferred.promise() ) {
3836 throw new TypeError( "Thenable self-resolution" );
3839 // Support: Promises/A+ sections 2.3.3.1, 3.5
3840 // https://promisesaplus.com/#point-54
3841 // https://promisesaplus.com/#point-75
3842 // Retrieve `then` only once
3845 // Support: Promises/A+ section 2.3.4
3846 // https://promisesaplus.com/#point-64
3847 // Only check objects and functions for thenability
3848 ( typeof returned === "object" ||
3849 typeof returned === "function" ) &&
3852 // Handle a returned thenable
3853 if ( isFunction( then ) ) {
3855 // Special processors (notify) just wait for resolution
3859 resolve( maxDepth, deferred, Identity, special ),
3860 resolve( maxDepth, deferred, Thrower, special )
3863 // Normal processors (resolve) also hook into progress
3866 // ...and disregard older resolution values
3871 resolve( maxDepth, deferred, Identity, special ),
3872 resolve( maxDepth, deferred, Thrower, special ),
3873 resolve( maxDepth, deferred, Identity,
3874 deferred.notifyWith )
3878 // Handle all other returned values
3881 // Only substitute handlers pass on context
3882 // and multiple values (non-spec behavior)
3883 if ( handler !== Identity ) {
3885 args = [ returned ];
3888 // Process the value(s)
3889 // Default process is resolve
3890 ( special || deferred.resolveWith )( that, args );
3894 // Only normal processors (resolve) catch and reject exceptions
3902 if ( jQuery.Deferred.exceptionHook ) {
3903 jQuery.Deferred.exceptionHook( e,
3904 process.stackTrace );
3907 // Support: Promises/A+ section 2.3.3.3.4.1
3908 // https://promisesaplus.com/#point-61
3909 // Ignore post-resolution exceptions
3910 if ( depth + 1 >= maxDepth ) {
3912 // Only substitute handlers pass on context
3913 // and multiple values (non-spec behavior)
3914 if ( handler !== Thrower ) {
3919 deferred.rejectWith( that, args );
3924 // Support: Promises/A+ section 2.3.3.3.1
3925 // https://promisesaplus.com/#point-57
3926 // Re-resolve promises immediately to dodge false rejection from
3927 // subsequent errors
3932 // Call an optional hook to record the stack, in case of exception
3933 // since it's otherwise lost when execution goes async
3934 if ( jQuery.Deferred.getStackHook ) {
3935 process.stackTrace = jQuery.Deferred.getStackHook();
3937 window.setTimeout( process );
3942 return jQuery.Deferred( function( newDefer ) {
3944 // progress_handlers.add( ... )
3945 tuples[ 0 ][ 3 ].add(
3949 isFunction( onProgress ) ?
3956 // fulfilled_handlers.add( ... )
3957 tuples[ 1 ][ 3 ].add(
3961 isFunction( onFulfilled ) ?
3967 // rejected_handlers.add( ... )
3968 tuples[ 2 ][ 3 ].add(
3972 isFunction( onRejected ) ?
3980 // Get a promise for this deferred
3981 // If obj is provided, the promise aspect is added to the object
3982 promise: function( obj ) {
3983 return obj != null ? jQuery.extend( obj, promise ) : promise;
3988 // Add list-specific methods
3989 jQuery.each( tuples, function( i, tuple ) {
3990 var list = tuple[ 2 ],
3991 stateString = tuple[ 5 ];
3993 // promise.progress = list.add
3994 // promise.done = list.add
3995 // promise.fail = list.add
3996 promise[ tuple[ 1 ] ] = list.add;
3999 if ( stateString ) {
4003 // state = "resolved" (i.e., fulfilled)
4004 // state = "rejected"
4005 state = stateString;
4008 // rejected_callbacks.disable
4009 // fulfilled_callbacks.disable
4010 tuples[ 3 - i ][ 2 ].disable,
4012 // rejected_handlers.disable
4013 // fulfilled_handlers.disable
4014 tuples[ 3 - i ][ 3 ].disable,
4016 // progress_callbacks.lock
4017 tuples[ 0 ][ 2 ].lock,
4019 // progress_handlers.lock
4020 tuples[ 0 ][ 3 ].lock
4024 // progress_handlers.fire
4025 // fulfilled_handlers.fire
4026 // rejected_handlers.fire
4027 list.add( tuple[ 3 ].fire );
4029 // deferred.notify = function() { deferred.notifyWith(...) }
4030 // deferred.resolve = function() { deferred.resolveWith(...) }
4031 // deferred.reject = function() { deferred.rejectWith(...) }
4032 deferred[ tuple[ 0 ] ] = function() {
4033 deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
4037 // deferred.notifyWith = list.fireWith
4038 // deferred.resolveWith = list.fireWith
4039 // deferred.rejectWith = list.fireWith
4040 deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
4043 // Make the deferred a promise
4044 promise.promise( deferred );
4046 // Call given func if any
4048 func.call( deferred, deferred );
4056 when: function( singleValue ) {
4059 // count of uncompleted subordinates
4060 remaining = arguments.length,
4062 // count of unprocessed arguments
4065 // subordinate fulfillment data
4066 resolveContexts = Array( i ),
4067 resolveValues = slice.call( arguments ),
4069 // the primary Deferred
4070 primary = jQuery.Deferred(),
4072 // subordinate callback factory
4073 updateFunc = function( i ) {
4074 return function( value ) {
4075 resolveContexts[ i ] = this;
4076 resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
4077 if ( !( --remaining ) ) {
4078 primary.resolveWith( resolveContexts, resolveValues );
4083 // Single- and empty arguments are adopted like Promise.resolve
4084 if ( remaining <= 1 ) {
4085 adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject,
4088 // Use .then() to unwrap secondary thenables (cf. gh-3000)
4089 if ( primary.state() === "pending" ||
4090 isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
4092 return primary.then();
4096 // Multiple arguments are aggregated like Promise.all array elements
4098 adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject );
4101 return primary.promise();
4106 // These usually indicate a programmer mistake during development,
4107 // warn about them ASAP rather than swallowing them by default.
4108 var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
4110 jQuery.Deferred.exceptionHook = function( error, stack ) {
4112 // Support: IE 8 - 9 only
4113 // Console exists when dev tools are open, which can happen at any time
4114 if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
4115 window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
4122 jQuery.readyException = function( error ) {
4123 window.setTimeout( function() {
4131 // The deferred used on DOM ready
4132 var readyList = jQuery.Deferred();
4134 jQuery.fn.ready = function( fn ) {
4139 // Wrap jQuery.readyException in a function so that the lookup
4140 // happens at the time of error handling instead of callback
4142 .catch( function( error ) {
4143 jQuery.readyException( error );
4151 // Is the DOM ready to be used? Set to true once it occurs.
4154 // A counter to track how many items to wait for before
4155 // the ready event fires. See trac-6781
4158 // Handle when the DOM is ready
4159 ready: function( wait ) {
4161 // Abort if there are pending holds or we're already ready
4162 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
4166 // Remember that the DOM is ready
4167 jQuery.isReady = true;
4169 // If a normal DOM Ready event fired, decrement, and wait if need be
4170 if ( wait !== true && --jQuery.readyWait > 0 ) {
4174 // If there are functions bound, to execute
4175 readyList.resolveWith( document, [ jQuery ] );
4179 jQuery.ready.then = readyList.then;
4181 // The ready event handler and self cleanup method
4182 function completed() {
4183 document.removeEventListener( "DOMContentLoaded", completed );
4184 window.removeEventListener( "load", completed );
4188 // Catch cases where $(document).ready() is called
4189 // after the browser event has already occurred.
4190 // Support: IE <=9 - 10 only
4191 // Older IE sometimes signals "interactive" too soon
4192 if ( document.readyState === "complete" ||
4193 ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
4195 // Handle it asynchronously to allow scripts the opportunity to delay ready
4196 window.setTimeout( jQuery.ready );
4200 // Use the handy event callback
4201 document.addEventListener( "DOMContentLoaded", completed );
4203 // A fallback to window.onload, that will always work
4204 window.addEventListener( "load", completed );
4210 // Multifunctional method to get and set values of a collection
4211 // The value/s can optionally be executed if it's a function
4212 var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
4218 if ( toType( key ) === "object" ) {
4221 access( elems, fn, i, key[ i ], true, emptyGet, raw );
4225 } else if ( value !== undefined ) {
4228 if ( !isFunction( value ) ) {
4234 // Bulk operations run against the entire set
4236 fn.call( elems, value );
4239 // ...except when executing function values
4242 fn = function( elem, _key, value ) {
4243 return bulk.call( jQuery( elem ), value );
4249 for ( ; i < len; i++ ) {
4251 elems[ i ], key, raw ?
4253 value.call( elems[ i ], i, fn( elems[ i ], key ) )
4265 return fn.call( elems );
4268 return len ? fn( elems[ 0 ], key ) : emptyGet;
4272 // Matches dashed string for camelizing
4273 var rmsPrefix = /^-ms-/,
4274 rdashAlpha = /-([a-z])/g;
4276 // Used by camelCase as callback to replace()
4277 function fcamelCase( _all, letter ) {
4278 return letter.toUpperCase();
4281 // Convert dashed to camelCase; used by the css and data modules
4282 // Support: IE <=9 - 11, Edge 12 - 15
4283 // Microsoft forgot to hump their vendor prefix (trac-9572)
4284 function camelCase( string ) {
4285 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
4287 var acceptData = function( owner ) {
4291 // - Node.ELEMENT_NODE
4292 // - Node.DOCUMENT_NODE
4295 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
4302 this.expando = jQuery.expando + Data.uid++;
4309 cache: function( owner ) {
4311 // Check if the owner object already has a cache
4312 var value = owner[ this.expando ];
4314 // If not, create one
4318 // We can accept data for non-element nodes in modern browsers,
4319 // but we should not, see trac-8335.
4320 // Always return an empty object.
4321 if ( acceptData( owner ) ) {
4323 // If it is a node unlikely to be stringify-ed or looped over
4324 // use plain assignment
4325 if ( owner.nodeType ) {
4326 owner[ this.expando ] = value;
4328 // Otherwise secure it in a non-enumerable property
4329 // configurable must be true to allow the property to be
4330 // deleted when data is removed
4332 Object.defineProperty( owner, this.expando, {
4342 set: function( owner, data, value ) {
4344 cache = this.cache( owner );
4346 // Handle: [ owner, key, value ] args
4347 // Always use camelCase key (gh-2257)
4348 if ( typeof data === "string" ) {
4349 cache[ camelCase( data ) ] = value;
4351 // Handle: [ owner, { properties } ] args
4354 // Copy the properties one-by-one to the cache object
4355 for ( prop in data ) {
4356 cache[ camelCase( prop ) ] = data[ prop ];
4361 get: function( owner, key ) {
4362 return key === undefined ?
4363 this.cache( owner ) :
4365 // Always use camelCase key (gh-2257)
4366 owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
4368 access: function( owner, key, value ) {
4370 // In cases where either:
4372 // 1. No key was specified
4373 // 2. A string key was specified, but no value provided
4375 // Take the "read" path and allow the get method to determine
4376 // which value to return, respectively either:
4378 // 1. The entire cache object
4379 // 2. The data stored at the key
4381 if ( key === undefined ||
4382 ( ( key && typeof key === "string" ) && value === undefined ) ) {
4384 return this.get( owner, key );
4387 // When the key is not a string, or both a key and value
4388 // are specified, set or extend (existing objects) with either:
4390 // 1. An object of properties
4391 // 2. A key and value
4393 this.set( owner, key, value );
4395 // Since the "set" path can have two possible entry points
4396 // return the expected data based on which path was taken[*]
4397 return value !== undefined ? value : key;
4399 remove: function( owner, key ) {
4401 cache = owner[ this.expando ];
4403 if ( cache === undefined ) {
4407 if ( key !== undefined ) {
4409 // Support array or space separated string of keys
4410 if ( Array.isArray( key ) ) {
4412 // If key is an array of keys...
4413 // We always set camelCase keys, so remove that.
4414 key = key.map( camelCase );
4416 key = camelCase( key );
4418 // If a key with the spaces exists, use it.
4419 // Otherwise, create an array by matching non-whitespace
4420 key = key in cache ?
4422 ( key.match( rnothtmlwhite ) || [] );
4428 delete cache[ key[ i ] ];
4432 // Remove the expando if there's no more data
4433 if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
4435 // Support: Chrome <=35 - 45
4436 // Webkit & Blink performance suffers when deleting properties
4437 // from DOM nodes, so set to undefined instead
4438 // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
4439 if ( owner.nodeType ) {
4440 owner[ this.expando ] = undefined;
4442 delete owner[ this.expando ];
4446 hasData: function( owner ) {
4447 var cache = owner[ this.expando ];
4448 return cache !== undefined && !jQuery.isEmptyObject( cache );
4451 var dataPriv = new Data();
4453 var dataUser = new Data();
4457 // Implementation Summary
4459 // 1. Enforce API surface and semantic compatibility with 1.9.x branch
4460 // 2. Improve the module's maintainability by reducing the storage
4461 // paths to a single mechanism.
4462 // 3. Use the same single mechanism to support "private" and "user" data.
4463 // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
4464 // 5. Avoid exposing implementation details on user objects (eg. expando properties)
4465 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
4467 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
4468 rmultiDash = /[A-Z]/g;
4470 function getData( data ) {
4471 if ( data === "true" ) {
4475 if ( data === "false" ) {
4479 if ( data === "null" ) {
4483 // Only convert to a number if it doesn't change the string
4484 if ( data === +data + "" ) {
4488 if ( rbrace.test( data ) ) {
4489 return JSON.parse( data );
4495 function dataAttr( elem, key, data ) {
4498 // If nothing was found internally, try to fetch any
4499 // data from the HTML5 data-* attribute
4500 if ( data === undefined && elem.nodeType === 1 ) {
4501 name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
4502 data = elem.getAttribute( name );
4504 if ( typeof data === "string" ) {
4506 data = getData( data );
4509 // Make sure we set the data so it isn't changed later
4510 dataUser.set( elem, key, data );
4519 hasData: function( elem ) {
4520 return dataUser.hasData( elem ) || dataPriv.hasData( elem );
4523 data: function( elem, name, data ) {
4524 return dataUser.access( elem, name, data );
4527 removeData: function( elem, name ) {
4528 dataUser.remove( elem, name );
4531 // TODO: Now that all calls to _data and _removeData have been replaced
4532 // with direct calls to dataPriv methods, these can be deprecated.
4533 _data: function( elem, name, data ) {
4534 return dataPriv.access( elem, name, data );
4537 _removeData: function( elem, name ) {
4538 dataPriv.remove( elem, name );
4543 data: function( key, value ) {
4546 attrs = elem && elem.attributes;
4549 if ( key === undefined ) {
4550 if ( this.length ) {
4551 data = dataUser.get( elem );
4553 if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
4557 // Support: IE 11 only
4558 // The attrs elements can be null (trac-14894)
4560 name = attrs[ i ].name;
4561 if ( name.indexOf( "data-" ) === 0 ) {
4562 name = camelCase( name.slice( 5 ) );
4563 dataAttr( elem, name, data[ name ] );
4567 dataPriv.set( elem, "hasDataAttrs", true );
4574 // Sets multiple values
4575 if ( typeof key === "object" ) {
4576 return this.each( function() {
4577 dataUser.set( this, key );
4581 return access( this, function( value ) {
4584 // The calling jQuery object (element matches) is not empty
4585 // (and therefore has an element appears at this[ 0 ]) and the
4586 // `value` parameter was not undefined. An empty jQuery object
4587 // will result in `undefined` for elem = this[ 0 ] which will
4588 // throw an exception if an attempt to read a data cache is made.
4589 if ( elem && value === undefined ) {
4591 // Attempt to get data from the cache
4592 // The key will always be camelCased in Data
4593 data = dataUser.get( elem, key );
4594 if ( data !== undefined ) {
4598 // Attempt to "discover" the data in
4599 // HTML5 custom data-* attrs
4600 data = dataAttr( elem, key );
4601 if ( data !== undefined ) {
4605 // We tried really hard, but the data doesn't exist.
4610 this.each( function() {
4612 // We always store the camelCased key
4613 dataUser.set( this, key, value );
4615 }, null, value, arguments.length > 1, null, true );
4618 removeData: function( key ) {
4619 return this.each( function() {
4620 dataUser.remove( this, key );
4627 queue: function( elem, type, data ) {
4631 type = ( type || "fx" ) + "queue";
4632 queue = dataPriv.get( elem, type );
4634 // Speed up dequeue by getting out quickly if this is just a lookup
4636 if ( !queue || Array.isArray( data ) ) {
4637 queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
4646 dequeue: function( elem, type ) {
4647 type = type || "fx";
4649 var queue = jQuery.queue( elem, type ),
4650 startLength = queue.length,
4652 hooks = jQuery._queueHooks( elem, type ),
4654 jQuery.dequeue( elem, type );
4657 // If the fx queue is dequeued, always remove the progress sentinel
4658 if ( fn === "inprogress" ) {
4665 // Add a progress sentinel to prevent the fx queue from being
4666 // automatically dequeued
4667 if ( type === "fx" ) {
4668 queue.unshift( "inprogress" );
4671 // Clear up the last queue stop function
4673 fn.call( elem, next, hooks );
4676 if ( !startLength && hooks ) {
4681 // Not public - generate a queueHooks object, or return the current one
4682 _queueHooks: function( elem, type ) {
4683 var key = type + "queueHooks";
4684 return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
4685 empty: jQuery.Callbacks( "once memory" ).add( function() {
4686 dataPriv.remove( elem, [ type + "queue", key ] );
4693 queue: function( type, data ) {
4696 if ( typeof type !== "string" ) {
4702 if ( arguments.length < setter ) {
4703 return jQuery.queue( this[ 0 ], type );
4706 return data === undefined ?
4708 this.each( function() {
4709 var queue = jQuery.queue( this, type, data );
4711 // Ensure a hooks for this queue
4712 jQuery._queueHooks( this, type );
4714 if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
4715 jQuery.dequeue( this, type );
4719 dequeue: function( type ) {
4720 return this.each( function() {
4721 jQuery.dequeue( this, type );
4724 clearQueue: function( type ) {
4725 return this.queue( type || "fx", [] );
4728 // Get a promise resolved when queues of a certain type
4729 // are emptied (fx is the type by default)
4730 promise: function( type, obj ) {
4733 defer = jQuery.Deferred(),
4736 resolve = function() {
4737 if ( !( --count ) ) {
4738 defer.resolveWith( elements, [ elements ] );
4742 if ( typeof type !== "string" ) {
4746 type = type || "fx";
4749 tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
4750 if ( tmp && tmp.empty ) {
4752 tmp.empty.add( resolve );
4756 return defer.promise( obj );
4759 var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
4761 var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
4764 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
4766 var documentElement = document.documentElement;
4770 var isAttached = function( elem ) {
4771 return jQuery.contains( elem.ownerDocument, elem );
4773 composed = { composed: true };
4775 // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
4776 // Check attachment across shadow DOM boundaries when possible (gh-3504)
4777 // Support: iOS 10.0-10.2 only
4778 // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
4779 // leading to errors. We need to check for `getRootNode`.
4780 if ( documentElement.getRootNode ) {
4781 isAttached = function( elem ) {
4782 return jQuery.contains( elem.ownerDocument, elem ) ||
4783 elem.getRootNode( composed ) === elem.ownerDocument;
4786 var isHiddenWithinTree = function( elem, el ) {
4788 // isHiddenWithinTree might be called from jQuery#filter function;
4789 // in that case, element will be second argument
4792 // Inline style trumps all
4793 return elem.style.display === "none" ||
4794 elem.style.display === "" &&
4796 // Otherwise, check computed style
4797 // Support: Firefox <=43 - 45
4798 // Disconnected elements can have computed display: none, so first confirm that elem is
4800 isAttached( elem ) &&
4802 jQuery.css( elem, "display" ) === "none";
4807 function adjustCSS( elem, prop, valueParts, tween ) {
4808 var adjusted, scale,
4810 currentValue = tween ?
4815 return jQuery.css( elem, prop, "" );
4817 initial = currentValue(),
4818 unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
4820 // Starting value computation is required for potential unit mismatches
4821 initialInUnit = elem.nodeType &&
4822 ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
4823 rcssNum.exec( jQuery.css( elem, prop ) );
4825 if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
4827 // Support: Firefox <=54
4828 // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
4829 initial = initial / 2;
4831 // Trust units reported by jQuery.css
4832 unit = unit || initialInUnit[ 3 ];
4834 // Iteratively approximate from a nonzero starting point
4835 initialInUnit = +initial || 1;
4837 while ( maxIterations-- ) {
4839 // Evaluate and update our best guess (doubling guesses that zero out).
4840 // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
4841 jQuery.style( elem, prop, initialInUnit + unit );
4842 if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
4845 initialInUnit = initialInUnit / scale;
4849 initialInUnit = initialInUnit * 2;
4850 jQuery.style( elem, prop, initialInUnit + unit );
4852 // Make sure we update the tween properties later on
4853 valueParts = valueParts || [];
4857 initialInUnit = +initialInUnit || +initial || 0;
4859 // Apply relative offset (+=/-=) if specified
4860 adjusted = valueParts[ 1 ] ?
4861 initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
4865 tween.start = initialInUnit;
4866 tween.end = adjusted;
4873 var defaultDisplayMap = {};
4875 function getDefaultDisplay( elem ) {
4877 doc = elem.ownerDocument,
4878 nodeName = elem.nodeName,
4879 display = defaultDisplayMap[ nodeName ];
4885 temp = doc.body.appendChild( doc.createElement( nodeName ) );
4886 display = jQuery.css( temp, "display" );
4888 temp.parentNode.removeChild( temp );
4890 if ( display === "none" ) {
4893 defaultDisplayMap[ nodeName ] = display;
4898 function showHide( elements, show ) {
4902 length = elements.length;
4904 // Determine new display value for elements that need to change
4905 for ( ; index < length; index++ ) {
4906 elem = elements[ index ];
4907 if ( !elem.style ) {
4911 display = elem.style.display;
4914 // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
4915 // check is required in this first loop unless we have a nonempty display value (either
4916 // inline or about-to-be-restored)
4917 if ( display === "none" ) {
4918 values[ index ] = dataPriv.get( elem, "display" ) || null;
4919 if ( !values[ index ] ) {
4920 elem.style.display = "";
4923 if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
4924 values[ index ] = getDefaultDisplay( elem );
4927 if ( display !== "none" ) {
4928 values[ index ] = "none";
4930 // Remember what we're overwriting
4931 dataPriv.set( elem, "display", display );
4936 // Set the display of the elements in a second loop to avoid constant reflow
4937 for ( index = 0; index < length; index++ ) {
4938 if ( values[ index ] != null ) {
4939 elements[ index ].style.display = values[ index ];
4948 return showHide( this, true );
4951 return showHide( this );
4953 toggle: function( state ) {
4954 if ( typeof state === "boolean" ) {
4955 return state ? this.show() : this.hide();
4958 return this.each( function() {
4959 if ( isHiddenWithinTree( this ) ) {
4960 jQuery( this ).show();
4962 jQuery( this ).hide();
4967 var rcheckableType = ( /^(?:checkbox|radio)$/i );
4969 var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
4971 var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
4976 var fragment = document.createDocumentFragment(),
4977 div = fragment.appendChild( document.createElement( "div" ) ),
4978 input = document.createElement( "input" );
4980 // Support: Android 4.0 - 4.3 only
4981 // Check state lost if the name is set (trac-11217)
4982 // Support: Windows Web Apps (WWA)
4983 // `name` and `type` must use .setAttribute for WWA (trac-14901)
4984 input.setAttribute( "type", "radio" );
4985 input.setAttribute( "checked", "checked" );
4986 input.setAttribute( "name", "t" );
4988 div.appendChild( input );
4990 // Support: Android <=4.1 only
4991 // Older WebKit doesn't clone checked state correctly in fragments
4992 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
4994 // Support: IE <=11 only
4995 // Make sure textarea (and checkbox) defaultValue is properly cloned
4996 div.innerHTML = "<textarea>x</textarea>";
4997 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
4999 // Support: IE <=9 only
5000 // IE <=9 replaces <option> tags with their contents when inserted outside of
5001 // the select element.
5002 div.innerHTML = "<option></option>";
5003 support.option = !!div.lastChild;
5007 // We have to close these tags to support XHTML (trac-13200)
5010 // XHTML parsers do not magically insert elements in the
5011 // same way that tag soup parsers do. So we cannot shorten
5012 // this by omitting <tbody> or other required elements.
5013 thead: [ 1, "<table>", "</table>" ],
5014 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
5015 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
5016 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
5018 _default: [ 0, "", "" ]
5021 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
5022 wrapMap.th = wrapMap.td;
5024 // Support: IE <=9 only
5025 if ( !support.option ) {
5026 wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
5030 function getAll( context, tag ) {
5032 // Support: IE <=9 - 11 only
5033 // Use typeof to avoid zero-argument method invocation on host objects (trac-15151)
5036 if ( typeof context.getElementsByTagName !== "undefined" ) {
5037 ret = context.getElementsByTagName( tag || "*" );
5039 } else if ( typeof context.querySelectorAll !== "undefined" ) {
5040 ret = context.querySelectorAll( tag || "*" );
5046 if ( tag === undefined || tag && nodeName( context, tag ) ) {
5047 return jQuery.merge( [ context ], ret );
5054 // Mark scripts as having already been evaluated
5055 function setGlobalEval( elems, refElements ) {
5059 for ( ; i < l; i++ ) {
5063 !refElements || dataPriv.get( refElements[ i ], "globalEval" )
5069 var rhtml = /<|&#?\w+;/;
5071 function buildFragment( elems, context, scripts, selection, ignored ) {
5072 var elem, tmp, tag, wrap, attached, j,
5073 fragment = context.createDocumentFragment(),
5078 for ( ; i < l; i++ ) {
5081 if ( elem || elem === 0 ) {
5083 // Add nodes directly
5084 if ( toType( elem ) === "object" ) {
5086 // Support: Android <=4.0 only, PhantomJS 1 only
5087 // push.apply(_, arraylike) throws on ancient WebKit
5088 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
5090 // Convert non-html into a text node
5091 } else if ( !rhtml.test( elem ) ) {
5092 nodes.push( context.createTextNode( elem ) );
5094 // Convert html into DOM nodes
5096 tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
5098 // Deserialize a standard representation
5099 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
5100 wrap = wrapMap[ tag ] || wrapMap._default;
5101 tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
5103 // Descend through wrappers to the right content
5106 tmp = tmp.lastChild;
5109 // Support: Android <=4.0 only, PhantomJS 1 only
5110 // push.apply(_, arraylike) throws on ancient WebKit
5111 jQuery.merge( nodes, tmp.childNodes );
5113 // Remember the top-level container
5114 tmp = fragment.firstChild;
5116 // Ensure the created nodes are orphaned (trac-12392)
5117 tmp.textContent = "";
5122 // Remove wrapper from fragment
5123 fragment.textContent = "";
5126 while ( ( elem = nodes[ i++ ] ) ) {
5128 // Skip elements already in the context collection (trac-4087)
5129 if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
5131 ignored.push( elem );
5136 attached = isAttached( elem );
5138 // Append to fragment
5139 tmp = getAll( fragment.appendChild( elem ), "script" );
5141 // Preserve script evaluation history
5143 setGlobalEval( tmp );
5146 // Capture executables
5149 while ( ( elem = tmp[ j++ ] ) ) {
5150 if ( rscriptType.test( elem.type || "" ) ) {
5151 scripts.push( elem );
5161 var rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
5163 function returnTrue() {
5167 function returnFalse() {
5171 // Support: IE <=9 - 11+
5172 // focus() and blur() are asynchronous, except when they are no-op.
5173 // So expect focus to be synchronous when the element is already active,
5174 // and blur to be synchronous when the element is not already active.
5175 // (focus and blur are always synchronous in other supported browsers,
5176 // this just defines when we can count on it).
5177 function expectSync( elem, type ) {
5178 return ( elem === safeActiveElement() ) === ( type === "focus" );
5181 // Support: IE <=9 only
5182 // Accessing document.activeElement can throw unexpectedly
5183 // https://bugs.jquery.com/ticket/13393
5184 function safeActiveElement() {
5186 return document.activeElement;
5190 function on( elem, types, selector, data, fn, one ) {
5193 // Types can be a map of types/handlers
5194 if ( typeof types === "object" ) {
5196 // ( types-Object, selector, data )
5197 if ( typeof selector !== "string" ) {
5199 // ( types-Object, data )
5200 data = data || selector;
5201 selector = undefined;
5203 for ( type in types ) {
5204 on( elem, type, selector, data, types[ type ], one );
5209 if ( data == null && fn == null ) {
5213 data = selector = undefined;
5214 } else if ( fn == null ) {
5215 if ( typeof selector === "string" ) {
5217 // ( types, selector, fn )
5222 // ( types, data, fn )
5225 selector = undefined;
5228 if ( fn === false ) {
5236 fn = function( event ) {
5238 // Can use an empty set, since event contains the info
5239 jQuery().off( event );
5240 return origFn.apply( this, arguments );
5243 // Use same guid so caller can remove using origFn
5244 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
5246 return elem.each( function() {
5247 jQuery.event.add( this, types, fn, data, selector );
5252 * Helper functions for managing events -- not part of the public interface.
5253 * Props to Dean Edwards' addEvent library for many of the ideas.
5259 add: function( elem, types, handler, data, selector ) {
5261 var handleObjIn, eventHandle, tmp,
5262 events, t, handleObj,
5263 special, handlers, type, namespaces, origType,
5264 elemData = dataPriv.get( elem );
5266 // Only attach events to objects that accept data
5267 if ( !acceptData( elem ) ) {
5271 // Caller can pass in an object of custom data in lieu of the handler
5272 if ( handler.handler ) {
5273 handleObjIn = handler;
5274 handler = handleObjIn.handler;
5275 selector = handleObjIn.selector;
5278 // Ensure that invalid selectors throw exceptions at attach time
5279 // Evaluate against documentElement in case elem is a non-element node (e.g., document)
5281 jQuery.find.matchesSelector( documentElement, selector );
5284 // Make sure that the handler has a unique ID, used to find/remove it later
5285 if ( !handler.guid ) {
5286 handler.guid = jQuery.guid++;
5289 // Init the element's event structure and main handler, if this is the first
5290 if ( !( events = elemData.events ) ) {
5291 events = elemData.events = Object.create( null );
5293 if ( !( eventHandle = elemData.handle ) ) {
5294 eventHandle = elemData.handle = function( e ) {
5296 // Discard the second event of a jQuery.event.trigger() and
5297 // when an event is called after a page has unloaded
5298 return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
5299 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
5303 // Handle multiple events separated by a space
5304 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
5307 tmp = rtypenamespace.exec( types[ t ] ) || [];
5308 type = origType = tmp[ 1 ];
5309 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
5311 // There *must* be a type, no attaching namespace-only handlers
5316 // If event changes its type, use the special event handlers for the changed type
5317 special = jQuery.event.special[ type ] || {};
5319 // If selector defined, determine special event api type, otherwise given type
5320 type = ( selector ? special.delegateType : special.bindType ) || type;
5322 // Update special based on newly reset type
5323 special = jQuery.event.special[ type ] || {};
5325 // handleObj is passed to all event handlers
5326 handleObj = jQuery.extend( {
5333 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
5334 namespace: namespaces.join( "." )
5337 // Init the event handler queue if we're the first
5338 if ( !( handlers = events[ type ] ) ) {
5339 handlers = events[ type ] = [];
5340 handlers.delegateCount = 0;
5342 // Only use addEventListener if the special events handler returns false
5343 if ( !special.setup ||
5344 special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
5346 if ( elem.addEventListener ) {
5347 elem.addEventListener( type, eventHandle );
5352 if ( special.add ) {
5353 special.add.call( elem, handleObj );
5355 if ( !handleObj.handler.guid ) {
5356 handleObj.handler.guid = handler.guid;
5360 // Add to the element's handler list, delegates in front
5362 handlers.splice( handlers.delegateCount++, 0, handleObj );
5364 handlers.push( handleObj );
5367 // Keep track of which events have ever been used, for event optimization
5368 jQuery.event.global[ type ] = true;
5373 // Detach an event or set of events from an element
5374 remove: function( elem, types, handler, selector, mappedTypes ) {
5376 var j, origCount, tmp,
5377 events, t, handleObj,
5378 special, handlers, type, namespaces, origType,
5379 elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
5381 if ( !elemData || !( events = elemData.events ) ) {
5385 // Once for each type.namespace in types; type may be omitted
5386 types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
5389 tmp = rtypenamespace.exec( types[ t ] ) || [];
5390 type = origType = tmp[ 1 ];
5391 namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
5393 // Unbind all events (on this namespace, if provided) for the element
5395 for ( type in events ) {
5396 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
5401 special = jQuery.event.special[ type ] || {};
5402 type = ( selector ? special.delegateType : special.bindType ) || type;
5403 handlers = events[ type ] || [];
5405 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
5407 // Remove matching events
5408 origCount = j = handlers.length;
5410 handleObj = handlers[ j ];
5412 if ( ( mappedTypes || origType === handleObj.origType ) &&
5413 ( !handler || handler.guid === handleObj.guid ) &&
5414 ( !tmp || tmp.test( handleObj.namespace ) ) &&
5415 ( !selector || selector === handleObj.selector ||
5416 selector === "**" && handleObj.selector ) ) {
5417 handlers.splice( j, 1 );
5419 if ( handleObj.selector ) {
5420 handlers.delegateCount--;
5422 if ( special.remove ) {
5423 special.remove.call( elem, handleObj );
5428 // Remove generic event handler if we removed something and no more handlers exist
5429 // (avoids potential for endless recursion during removal of special event handlers)
5430 if ( origCount && !handlers.length ) {
5431 if ( !special.teardown ||
5432 special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
5434 jQuery.removeEvent( elem, type, elemData.handle );
5437 delete events[ type ];
5441 // Remove data and the expando if it's no longer used
5442 if ( jQuery.isEmptyObject( events ) ) {
5443 dataPriv.remove( elem, "handle events" );
5447 dispatch: function( nativeEvent ) {
5449 var i, j, ret, matched, handleObj, handlerQueue,
5450 args = new Array( arguments.length ),
5452 // Make a writable jQuery.Event from the native event object
5453 event = jQuery.event.fix( nativeEvent ),
5456 dataPriv.get( this, "events" ) || Object.create( null )
5457 )[ event.type ] || [],
5458 special = jQuery.event.special[ event.type ] || {};
5460 // Use the fix-ed jQuery.Event rather than the (read-only) native event
5463 for ( i = 1; i < arguments.length; i++ ) {
5464 args[ i ] = arguments[ i ];
5467 event.delegateTarget = this;
5469 // Call the preDispatch hook for the mapped type, and let it bail if desired
5470 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
5474 // Determine handlers
5475 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
5477 // Run delegates first; they may want to stop propagation beneath us
5479 while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
5480 event.currentTarget = matched.elem;
5483 while ( ( handleObj = matched.handlers[ j++ ] ) &&
5484 !event.isImmediatePropagationStopped() ) {
5486 // If the event is namespaced, then each handler is only invoked if it is
5487 // specially universal or its namespaces are a superset of the event's.
5488 if ( !event.rnamespace || handleObj.namespace === false ||
5489 event.rnamespace.test( handleObj.namespace ) ) {
5491 event.handleObj = handleObj;
5492 event.data = handleObj.data;
5494 ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
5495 handleObj.handler ).apply( matched.elem, args );
5497 if ( ret !== undefined ) {
5498 if ( ( event.result = ret ) === false ) {
5499 event.preventDefault();
5500 event.stopPropagation();
5507 // Call the postDispatch hook for the mapped type
5508 if ( special.postDispatch ) {
5509 special.postDispatch.call( this, event );
5512 return event.result;
5515 handlers: function( event, handlers ) {
5516 var i, handleObj, sel, matchedHandlers, matchedSelectors,
5518 delegateCount = handlers.delegateCount,
5521 // Find delegate handlers
5522 if ( delegateCount &&
5525 // Black-hole SVG <use> instance trees (trac-13180)
5528 // Support: Firefox <=42
5529 // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
5530 // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
5531 // Support: IE 11 only
5532 // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
5533 !( event.type === "click" && event.button >= 1 ) ) {
5535 for ( ; cur !== this; cur = cur.parentNode || this ) {
5537 // Don't check non-elements (trac-13208)
5538 // Don't process clicks on disabled elements (trac-6911, trac-8165, trac-11382, trac-11764)
5539 if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
5540 matchedHandlers = [];
5541 matchedSelectors = {};
5542 for ( i = 0; i < delegateCount; i++ ) {
5543 handleObj = handlers[ i ];
5545 // Don't conflict with Object.prototype properties (trac-13203)
5546 sel = handleObj.selector + " ";
5548 if ( matchedSelectors[ sel ] === undefined ) {
5549 matchedSelectors[ sel ] = handleObj.needsContext ?
5550 jQuery( sel, this ).index( cur ) > -1 :
5551 jQuery.find( sel, this, null, [ cur ] ).length;
5553 if ( matchedSelectors[ sel ] ) {
5554 matchedHandlers.push( handleObj );
5557 if ( matchedHandlers.length ) {
5558 handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
5564 // Add the remaining (directly-bound) handlers
5566 if ( delegateCount < handlers.length ) {
5567 handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
5570 return handlerQueue;
5573 addProp: function( name, hook ) {
5574 Object.defineProperty( jQuery.Event.prototype, name, {
5578 get: isFunction( hook ) ?
5580 if ( this.originalEvent ) {
5581 return hook( this.originalEvent );
5585 if ( this.originalEvent ) {
5586 return this.originalEvent[ name ];
5590 set: function( value ) {
5591 Object.defineProperty( this, name, {
5601 fix: function( originalEvent ) {
5602 return originalEvent[ jQuery.expando ] ?
5604 new jQuery.Event( originalEvent );
5610 // Prevent triggered image.load events from bubbling to window.load
5615 // Utilize native event to ensure correct state for checkable inputs
5616 setup: function( data ) {
5618 // For mutual compressibility with _default, replace `this` access with a local var.
5619 // `|| data` is dead code meant only to preserve the variable through minification.
5620 var el = this || data;
5622 // Claim the first handler
5623 if ( rcheckableType.test( el.type ) &&
5624 el.click && nodeName( el, "input" ) ) {
5626 // dataPriv.set( el, "click", ... )
5627 leverageNative( el, "click", returnTrue );
5630 // Return false to allow normal processing in the caller
5633 trigger: function( data ) {
5635 // For mutual compressibility with _default, replace `this` access with a local var.
5636 // `|| data` is dead code meant only to preserve the variable through minification.
5637 var el = this || data;
5639 // Force setup before triggering a click
5640 if ( rcheckableType.test( el.type ) &&
5641 el.click && nodeName( el, "input" ) ) {
5643 leverageNative( el, "click" );
5646 // Return non-false to allow normal event-path propagation
5650 // For cross-browser consistency, suppress native .click() on links
5651 // Also prevent it if we're currently inside a leveraged native-event stack
5652 _default: function( event ) {
5653 var target = event.target;
5654 return rcheckableType.test( target.type ) &&
5655 target.click && nodeName( target, "input" ) &&
5656 dataPriv.get( target, "click" ) ||
5657 nodeName( target, "a" );
5662 postDispatch: function( event ) {
5664 // Support: Firefox 20+
5665 // Firefox doesn't alert if the returnValue field is not set.
5666 if ( event.result !== undefined && event.originalEvent ) {
5667 event.originalEvent.returnValue = event.result;
5674 // Ensure the presence of an event listener that handles manually-triggered
5675 // synthetic events by interrupting progress until reinvoked in response to
5676 // *native* events that it fires directly, ensuring that state changes have
5677 // already occurred before other listeners are invoked.
5678 function leverageNative( el, type, expectSync ) {
5680 // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
5681 if ( !expectSync ) {
5682 if ( dataPriv.get( el, type ) === undefined ) {
5683 jQuery.event.add( el, type, returnTrue );
5688 // Register the controller as a special universal handler for all event namespaces
5689 dataPriv.set( el, type, false );
5690 jQuery.event.add( el, type, {
5692 handler: function( event ) {
5693 var notAsync, result,
5694 saved = dataPriv.get( this, type );
5696 if ( ( event.isTrigger & 1 ) && this[ type ] ) {
5698 // Interrupt processing of the outer synthetic .trigger()ed event
5699 // Saved data should be false in such cases, but might be a leftover capture object
5700 // from an async native handler (gh-4350)
5701 if ( !saved.length ) {
5703 // Store arguments for use when handling the inner native event
5704 // There will always be at least one argument (an event object), so this array
5705 // will not be confused with a leftover capture object.
5706 saved = slice.call( arguments );
5707 dataPriv.set( this, type, saved );
5709 // Trigger the native event and capture its result
5710 // Support: IE <=9 - 11+
5711 // focus() and blur() are asynchronous
5712 notAsync = expectSync( this, type );
5714 result = dataPriv.get( this, type );
5715 if ( saved !== result || notAsync ) {
5716 dataPriv.set( this, type, false );
5720 if ( saved !== result ) {
5722 // Cancel the outer synthetic event
5723 event.stopImmediatePropagation();
5724 event.preventDefault();
5726 // Support: Chrome 86+
5727 // In Chrome, if an element having a focusout handler is blurred by
5728 // clicking outside of it, it invokes the handler synchronously. If
5729 // that handler calls `.remove()` on the element, the data is cleared,
5730 // leaving `result` undefined. We need to guard against this.
5731 return result && result.value;
5734 // If this is an inner synthetic event for an event with a bubbling surrogate
5735 // (focus or blur), assume that the surrogate already propagated from triggering the
5736 // native event and prevent that from happening again here.
5737 // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
5738 // bubbling surrogate propagates *after* the non-bubbling base), but that seems
5739 // less bad than duplication.
5740 } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
5741 event.stopPropagation();
5744 // If this is a native event triggered above, everything is now in order
5745 // Fire an inner synthetic event with the original arguments
5746 } else if ( saved.length ) {
5748 // ...and capture the result
5749 dataPriv.set( this, type, {
5750 value: jQuery.event.trigger(
5752 // Support: IE <=9 - 11+
5753 // Extend with the prototype to reset the above stopImmediatePropagation()
5754 jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
5760 // Abort handling of the native event
5761 event.stopImmediatePropagation();
5767 jQuery.removeEvent = function( elem, type, handle ) {
5769 // This "if" is needed for plain objects
5770 if ( elem.removeEventListener ) {
5771 elem.removeEventListener( type, handle );
5775 jQuery.Event = function( src, props ) {
5777 // Allow instantiation without the 'new' keyword
5778 if ( !( this instanceof jQuery.Event ) ) {
5779 return new jQuery.Event( src, props );
5783 if ( src && src.type ) {
5784 this.originalEvent = src;
5785 this.type = src.type;
5787 // Events bubbling up the document may have been marked as prevented
5788 // by a handler lower down the tree; reflect the correct value.
5789 this.isDefaultPrevented = src.defaultPrevented ||
5790 src.defaultPrevented === undefined &&
5792 // Support: Android <=2.3 only
5793 src.returnValue === false ?
5797 // Create target properties
5798 // Support: Safari <=6 - 7 only
5799 // Target should not be a text node (trac-504, trac-13143)
5800 this.target = ( src.target && src.target.nodeType === 3 ) ?
5801 src.target.parentNode :
5804 this.currentTarget = src.currentTarget;
5805 this.relatedTarget = src.relatedTarget;
5812 // Put explicitly provided properties onto the event object
5814 jQuery.extend( this, props );
5817 // Create a timestamp if incoming event doesn't have one
5818 this.timeStamp = src && src.timeStamp || Date.now();
5821 this[ jQuery.expando ] = true;
5824 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
5825 // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
5826 jQuery.Event.prototype = {
5827 constructor: jQuery.Event,
5828 isDefaultPrevented: returnFalse,
5829 isPropagationStopped: returnFalse,
5830 isImmediatePropagationStopped: returnFalse,
5833 preventDefault: function() {
5834 var e = this.originalEvent;
5836 this.isDefaultPrevented = returnTrue;
5838 if ( e && !this.isSimulated ) {
5842 stopPropagation: function() {
5843 var e = this.originalEvent;
5845 this.isPropagationStopped = returnTrue;
5847 if ( e && !this.isSimulated ) {
5848 e.stopPropagation();
5851 stopImmediatePropagation: function() {
5852 var e = this.originalEvent;
5854 this.isImmediatePropagationStopped = returnTrue;
5856 if ( e && !this.isSimulated ) {
5857 e.stopImmediatePropagation();
5860 this.stopPropagation();
5864 // Includes all common event props including KeyEvent and MouseEvent specific props
5869 changedTouches: true,
5893 targetTouches: true,
5897 }, jQuery.event.addProp );
5899 jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
5900 jQuery.event.special[ type ] = {
5902 // Utilize native event if possible so blur/focus sequence is correct
5905 // Claim the first handler
5906 // dataPriv.set( this, "focus", ... )
5907 // dataPriv.set( this, "blur", ... )
5908 leverageNative( this, type, expectSync );
5910 // Return false to allow normal processing in the caller
5913 trigger: function() {
5915 // Force setup before trigger
5916 leverageNative( this, type );
5918 // Return non-false to allow normal event-path propagation
5922 // Suppress native focus or blur if we're currently inside
5923 // a leveraged native-event stack
5924 _default: function( event ) {
5925 return dataPriv.get( event.target, type );
5928 delegateType: delegateType
5932 // Create mouseenter/leave events using mouseover/out and event-time checks
5933 // so that event delegation works in jQuery.
5934 // Do the same for pointerenter/pointerleave and pointerover/pointerout
5936 // Support: Safari 7 only
5937 // Safari sends mouseenter too often; see:
5938 // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
5939 // for the description of the bug (it existed in older Chrome versions as well).
5941 mouseenter: "mouseover",
5942 mouseleave: "mouseout",
5943 pointerenter: "pointerover",
5944 pointerleave: "pointerout"
5945 }, function( orig, fix ) {
5946 jQuery.event.special[ orig ] = {
5950 handle: function( event ) {
5953 related = event.relatedTarget,
5954 handleObj = event.handleObj;
5956 // For mouseenter/leave call the handler if related is outside the target.
5957 // NB: No relatedTarget if the mouse left/entered the browser window
5958 if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
5959 event.type = handleObj.origType;
5960 ret = handleObj.handler.apply( this, arguments );
5970 on: function( types, selector, data, fn ) {
5971 return on( this, types, selector, data, fn );
5973 one: function( types, selector, data, fn ) {
5974 return on( this, types, selector, data, fn, 1 );
5976 off: function( types, selector, fn ) {
5977 var handleObj, type;
5978 if ( types && types.preventDefault && types.handleObj ) {
5980 // ( event ) dispatched jQuery.Event
5981 handleObj = types.handleObj;
5982 jQuery( types.delegateTarget ).off(
5983 handleObj.namespace ?
5984 handleObj.origType + "." + handleObj.namespace :
5991 if ( typeof types === "object" ) {
5993 // ( types-object [, selector] )
5994 for ( type in types ) {
5995 this.off( type, selector, types[ type ] );
5999 if ( selector === false || typeof selector === "function" ) {
6003 selector = undefined;
6005 if ( fn === false ) {
6008 return this.each( function() {
6009 jQuery.event.remove( this, types, fn, selector );
6017 // Support: IE <=10 - 11, Edge 12 - 13 only
6018 // In IE/Edge using regex groups here causes severe slowdowns.
6019 // See https://connect.microsoft.com/IE/feedback/details/1736512/
6020 rnoInnerhtml = /<script|<style|<link/i,
6022 // checked="checked" or checked
6023 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
6025 rcleanScript = /^\s*<!\[CDATA\[|\]\]>\s*$/g;
6027 // Prefer a tbody over its parent table for containing new rows
6028 function manipulationTarget( elem, content ) {
6029 if ( nodeName( elem, "table" ) &&
6030 nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
6032 return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
6038 // Replace/restore the type attribute of script elements for safe DOM manipulation
6039 function disableScript( elem ) {
6040 elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
6043 function restoreScript( elem ) {
6044 if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
6045 elem.type = elem.type.slice( 5 );
6047 elem.removeAttribute( "type" );
6053 function cloneCopyEvent( src, dest ) {
6054 var i, l, type, pdataOld, udataOld, udataCur, events;
6056 if ( dest.nodeType !== 1 ) {
6060 // 1. Copy private data: events, handlers, etc.
6061 if ( dataPriv.hasData( src ) ) {
6062 pdataOld = dataPriv.get( src );
6063 events = pdataOld.events;
6066 dataPriv.remove( dest, "handle events" );
6068 for ( type in events ) {
6069 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
6070 jQuery.event.add( dest, type, events[ type ][ i ] );
6076 // 2. Copy user data
6077 if ( dataUser.hasData( src ) ) {
6078 udataOld = dataUser.access( src );
6079 udataCur = jQuery.extend( {}, udataOld );
6081 dataUser.set( dest, udataCur );
6085 // Fix IE bugs, see support tests
6086 function fixInput( src, dest ) {
6087 var nodeName = dest.nodeName.toLowerCase();
6089 // Fails to persist the checked state of a cloned checkbox or radio button.
6090 if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
6091 dest.checked = src.checked;
6093 // Fails to return the selected option to the default selected state when cloning options
6094 } else if ( nodeName === "input" || nodeName === "textarea" ) {
6095 dest.defaultValue = src.defaultValue;
6099 function domManip( collection, args, callback, ignored ) {
6101 // Flatten any nested arrays
6102 args = flat( args );
6104 var fragment, first, scripts, hasScripts, node, doc,
6106 l = collection.length,
6109 valueIsFunction = isFunction( value );
6111 // We can't cloneNode fragments that contain checked, in WebKit
6112 if ( valueIsFunction ||
6113 ( l > 1 && typeof value === "string" &&
6114 !support.checkClone && rchecked.test( value ) ) ) {
6115 return collection.each( function( index ) {
6116 var self = collection.eq( index );
6117 if ( valueIsFunction ) {
6118 args[ 0 ] = value.call( this, index, self.html() );
6120 domManip( self, args, callback, ignored );
6125 fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
6126 first = fragment.firstChild;
6128 if ( fragment.childNodes.length === 1 ) {
6132 // Require either new content or an interest in ignored elements to invoke the callback
6133 if ( first || ignored ) {
6134 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
6135 hasScripts = scripts.length;
6137 // Use the original fragment for the last item
6138 // instead of the first because it can end up
6139 // being emptied incorrectly in certain situations (trac-8070).
6140 for ( ; i < l; i++ ) {
6143 if ( i !== iNoClone ) {
6144 node = jQuery.clone( node, true, true );
6146 // Keep references to cloned scripts for later restoration
6149 // Support: Android <=4.0 only, PhantomJS 1 only
6150 // push.apply(_, arraylike) throws on ancient WebKit
6151 jQuery.merge( scripts, getAll( node, "script" ) );
6155 callback.call( collection[ i ], node, i );
6159 doc = scripts[ scripts.length - 1 ].ownerDocument;
6162 jQuery.map( scripts, restoreScript );
6164 // Evaluate executable scripts on first document insertion
6165 for ( i = 0; i < hasScripts; i++ ) {
6166 node = scripts[ i ];
6167 if ( rscriptType.test( node.type || "" ) &&
6168 !dataPriv.access( node, "globalEval" ) &&
6169 jQuery.contains( doc, node ) ) {
6171 if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
6173 // Optional AJAX dependency, but won't run scripts if not present
6174 if ( jQuery._evalUrl && !node.noModule ) {
6175 jQuery._evalUrl( node.src, {
6176 nonce: node.nonce || node.getAttribute( "nonce" )
6181 // Unwrap a CDATA section containing script contents. This shouldn't be
6182 // needed as in XML documents they're already not visible when
6183 // inspecting element contents and in HTML documents they have no
6184 // meaning but we're preserving that logic for backwards compatibility.
6185 // This will be removed completely in 4.0. See gh-4904.
6186 DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
6197 function remove( elem, selector, keepData ) {
6199 nodes = selector ? jQuery.filter( selector, elem ) : elem,
6202 for ( ; ( node = nodes[ i ] ) != null; i++ ) {
6203 if ( !keepData && node.nodeType === 1 ) {
6204 jQuery.cleanData( getAll( node ) );
6207 if ( node.parentNode ) {
6208 if ( keepData && isAttached( node ) ) {
6209 setGlobalEval( getAll( node, "script" ) );
6211 node.parentNode.removeChild( node );
6219 htmlPrefilter: function( html ) {
6223 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
6224 var i, l, srcElements, destElements,
6225 clone = elem.cloneNode( true ),
6226 inPage = isAttached( elem );
6228 // Fix IE cloning issues
6229 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
6230 !jQuery.isXMLDoc( elem ) ) {
6232 // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
6233 destElements = getAll( clone );
6234 srcElements = getAll( elem );
6236 for ( i = 0, l = srcElements.length; i < l; i++ ) {
6237 fixInput( srcElements[ i ], destElements[ i ] );
6241 // Copy the events from the original to the clone
6242 if ( dataAndEvents ) {
6243 if ( deepDataAndEvents ) {
6244 srcElements = srcElements || getAll( elem );
6245 destElements = destElements || getAll( clone );
6247 for ( i = 0, l = srcElements.length; i < l; i++ ) {
6248 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
6251 cloneCopyEvent( elem, clone );
6255 // Preserve script evaluation history
6256 destElements = getAll( clone, "script" );
6257 if ( destElements.length > 0 ) {
6258 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
6261 // Return the cloned set
6265 cleanData: function( elems ) {
6266 var data, elem, type,
6267 special = jQuery.event.special,
6270 for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
6271 if ( acceptData( elem ) ) {
6272 if ( ( data = elem[ dataPriv.expando ] ) ) {
6273 if ( data.events ) {
6274 for ( type in data.events ) {
6275 if ( special[ type ] ) {
6276 jQuery.event.remove( elem, type );
6278 // This is a shortcut to avoid jQuery.event.remove's overhead
6280 jQuery.removeEvent( elem, type, data.handle );
6285 // Support: Chrome <=35 - 45+
6286 // Assign undefined instead of using delete, see Data#remove
6287 elem[ dataPriv.expando ] = undefined;
6289 if ( elem[ dataUser.expando ] ) {
6291 // Support: Chrome <=35 - 45+
6292 // Assign undefined instead of using delete, see Data#remove
6293 elem[ dataUser.expando ] = undefined;
6301 detach: function( selector ) {
6302 return remove( this, selector, true );
6305 remove: function( selector ) {
6306 return remove( this, selector );
6309 text: function( value ) {
6310 return access( this, function( value ) {
6311 return value === undefined ?
6312 jQuery.text( this ) :
6313 this.empty().each( function() {
6314 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6315 this.textContent = value;
6318 }, null, value, arguments.length );
6321 append: function() {
6322 return domManip( this, arguments, function( elem ) {
6323 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6324 var target = manipulationTarget( this, elem );
6325 target.appendChild( elem );
6330 prepend: function() {
6331 return domManip( this, arguments, function( elem ) {
6332 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
6333 var target = manipulationTarget( this, elem );
6334 target.insertBefore( elem, target.firstChild );
6339 before: function() {
6340 return domManip( this, arguments, function( elem ) {
6341 if ( this.parentNode ) {
6342 this.parentNode.insertBefore( elem, this );
6348 return domManip( this, arguments, function( elem ) {
6349 if ( this.parentNode ) {
6350 this.parentNode.insertBefore( elem, this.nextSibling );
6359 for ( ; ( elem = this[ i ] ) != null; i++ ) {
6360 if ( elem.nodeType === 1 ) {
6362 // Prevent memory leaks
6363 jQuery.cleanData( getAll( elem, false ) );
6365 // Remove any remaining nodes
6366 elem.textContent = "";
6373 clone: function( dataAndEvents, deepDataAndEvents ) {
6374 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
6375 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
6377 return this.map( function() {
6378 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
6382 html: function( value ) {
6383 return access( this, function( value ) {
6384 var elem = this[ 0 ] || {},
6388 if ( value === undefined && elem.nodeType === 1 ) {
6389 return elem.innerHTML;
6392 // See if we can take a shortcut and just use innerHTML
6393 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
6394 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
6396 value = jQuery.htmlPrefilter( value );
6399 for ( ; i < l; i++ ) {
6400 elem = this[ i ] || {};
6402 // Remove element nodes and prevent memory leaks
6403 if ( elem.nodeType === 1 ) {
6404 jQuery.cleanData( getAll( elem, false ) );
6405 elem.innerHTML = value;
6411 // If using innerHTML throws an exception, use the fallback method
6416 this.empty().append( value );
6418 }, null, value, arguments.length );
6421 replaceWith: function() {
6424 // Make the changes, replacing each non-ignored context element with the new content
6425 return domManip( this, arguments, function( elem ) {
6426 var parent = this.parentNode;
6428 if ( jQuery.inArray( this, ignored ) < 0 ) {
6429 jQuery.cleanData( getAll( this ) );
6431 parent.replaceChild( elem, this );
6435 // Force callback invocation
6442 prependTo: "prepend",
6443 insertBefore: "before",
6444 insertAfter: "after",
6445 replaceAll: "replaceWith"
6446 }, function( name, original ) {
6447 jQuery.fn[ name ] = function( selector ) {
6450 insert = jQuery( selector ),
6451 last = insert.length - 1,
6454 for ( ; i <= last; i++ ) {
6455 elems = i === last ? this : this.clone( true );
6456 jQuery( insert[ i ] )[ original ]( elems );
6458 // Support: Android <=4.0 only, PhantomJS 1 only
6459 // .get() because push.apply(_, arraylike) throws on ancient WebKit
6460 push.apply( ret, elems.get() );
6463 return this.pushStack( ret );
6466 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
6468 var rcustomProp = /^--/;
6471 var getStyles = function( elem ) {
6473 // Support: IE <=11 only, Firefox <=30 (trac-15098, trac-14150)
6474 // IE throws on elements created in popups
6475 // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
6476 var view = elem.ownerDocument.defaultView;
6478 if ( !view || !view.opener ) {
6482 return view.getComputedStyle( elem );
6485 var swap = function( elem, options, callback ) {
6489 // Remember the old values, and insert the new ones
6490 for ( name in options ) {
6491 old[ name ] = elem.style[ name ];
6492 elem.style[ name ] = options[ name ];
6495 ret = callback.call( elem );
6497 // Revert the old values
6498 for ( name in options ) {
6499 elem.style[ name ] = old[ name ];
6506 var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
6508 var whitespace = "[\\x20\\t\\r\\n\\f]";
6511 var rtrimCSS = new RegExp(
6512 "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$",
6521 // Executing both pixelPosition & boxSizingReliable tests require only one layout
6522 // so they're executed at the same time to save the second computation.
6523 function computeStyleTests() {
6525 // This is a singleton, we need to execute it only once
6530 container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
6531 "margin-top:1px;padding:0;border:0";
6533 "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
6534 "margin:auto;border:1px;padding:1px;" +
6536 documentElement.appendChild( container ).appendChild( div );
6538 var divStyle = window.getComputedStyle( div );
6539 pixelPositionVal = divStyle.top !== "1%";
6541 // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
6542 reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
6544 // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
6545 // Some styles come back with percentage values, even though they shouldn't
6546 div.style.right = "60%";
6547 pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
6549 // Support: IE 9 - 11 only
6550 // Detect misreporting of content dimensions for box-sizing:border-box elements
6551 boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
6553 // Support: IE 9 only
6554 // Detect overflow:scroll screwiness (gh-3699)
6555 // Support: Chrome <=64
6556 // Don't get tricked when zoom affects offsetWidth (gh-4029)
6557 div.style.position = "absolute";
6558 scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
6560 documentElement.removeChild( container );
6562 // Nullify the div so it wouldn't be stored in the memory and
6563 // it will also be a sign that checks already performed
6567 function roundPixelMeasures( measure ) {
6568 return Math.round( parseFloat( measure ) );
6571 var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
6572 reliableTrDimensionsVal, reliableMarginLeftVal,
6573 container = document.createElement( "div" ),
6574 div = document.createElement( "div" );
6576 // Finish early in limited (non-browser) environments
6581 // Support: IE <=9 - 11 only
6582 // Style of cloned element affects source element cloned (trac-8908)
6583 div.style.backgroundClip = "content-box";
6584 div.cloneNode( true ).style.backgroundClip = "";
6585 support.clearCloneStyle = div.style.backgroundClip === "content-box";
6587 jQuery.extend( support, {
6588 boxSizingReliable: function() {
6589 computeStyleTests();
6590 return boxSizingReliableVal;
6592 pixelBoxStyles: function() {
6593 computeStyleTests();
6594 return pixelBoxStylesVal;
6596 pixelPosition: function() {
6597 computeStyleTests();
6598 return pixelPositionVal;
6600 reliableMarginLeft: function() {
6601 computeStyleTests();
6602 return reliableMarginLeftVal;
6604 scrollboxSize: function() {
6605 computeStyleTests();
6606 return scrollboxSizeVal;
6609 // Support: IE 9 - 11+, Edge 15 - 18+
6610 // IE/Edge misreport `getComputedStyle` of table rows with width/height
6611 // set in CSS while `offset*` properties report correct values.
6612 // Behavior in IE 9 is more subtle than in newer versions & it passes
6613 // some versions of this test; make sure not to make it pass there!
6615 // Support: Firefox 70+
6616 // Only Firefox includes border widths
6617 // in computed dimensions. (gh-4529)
6618 reliableTrDimensions: function() {
6619 var table, tr, trChild, trStyle;
6620 if ( reliableTrDimensionsVal == null ) {
6621 table = document.createElement( "table" );
6622 tr = document.createElement( "tr" );
6623 trChild = document.createElement( "div" );
6625 table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate";
6626 tr.style.cssText = "border:1px solid";
6628 // Support: Chrome 86+
6629 // Height set through cssText does not get applied.
6630 // Computed height then comes back as 0.
6631 tr.style.height = "1px";
6632 trChild.style.height = "9px";
6634 // Support: Android 8 Chrome 86+
6635 // In our bodyBackground.html iframe,
6636 // display for all div elements is set to "inline",
6637 // which causes a problem only in Android 8 Chrome 86.
6638 // Ensuring the div is display: block
6639 // gets around this issue.
6640 trChild.style.display = "block";
6643 .appendChild( table )
6645 .appendChild( trChild );
6647 trStyle = window.getComputedStyle( tr );
6648 reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) +
6649 parseInt( trStyle.borderTopWidth, 10 ) +
6650 parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight;
6652 documentElement.removeChild( table );
6654 return reliableTrDimensionsVal;
6660 function curCSS( elem, name, computed ) {
6661 var width, minWidth, maxWidth, ret,
6662 isCustomProp = rcustomProp.test( name ),
6664 // Support: Firefox 51+
6665 // Retrieving style before computed somehow
6666 // fixes an issue with getting wrong values
6667 // on detached elements
6670 computed = computed || getStyles( elem );
6672 // getPropertyValue is needed for:
6673 // .css('filter') (IE 9 only, trac-12537)
6674 // .css('--customProperty) (gh-3144)
6677 // Support: IE <=9 - 11+
6678 // IE only supports `"float"` in `getPropertyValue`; in computed styles
6679 // it's only available as `"cssFloat"`. We no longer modify properties
6680 // sent to `.css()` apart from camelCasing, so we need to check both.
6681 // Normally, this would create difference in behavior: if
6682 // `getPropertyValue` returns an empty string, the value returned
6683 // by `.css()` would be `undefined`. This is usually the case for
6684 // disconnected elements. However, in IE even disconnected elements
6685 // with no styles return `"none"` for `getPropertyValue( "float" )`
6686 ret = computed.getPropertyValue( name ) || computed[ name ];
6688 if ( isCustomProp && ret ) {
6690 // Support: Firefox 105+, Chrome <=105+
6691 // Spec requires trimming whitespace for custom properties (gh-4926).
6692 // Firefox only trims leading whitespace. Chrome just collapses
6693 // both leading & trailing whitespace to a single space.
6695 // Fall back to `undefined` if empty string returned.
6696 // This collapses a missing definition with property defined
6697 // and set to an empty string but there's no standard API
6698 // allowing us to differentiate them without a performance penalty
6699 // and returning `undefined` aligns with older jQuery.
6701 // rtrimCSS treats U+000D CARRIAGE RETURN and U+000C FORM FEED
6702 // as whitespace while CSS does not, but this is not a problem
6703 // because CSS preprocessing replaces them with U+000A LINE FEED
6704 // (which *is* CSS whitespace)
6705 // https://www.w3.org/TR/css-syntax-3/#input-preprocessing
6706 ret = ret.replace( rtrimCSS, "$1" ) || undefined;
6709 if ( ret === "" && !isAttached( elem ) ) {
6710 ret = jQuery.style( elem, name );
6713 // A tribute to the "awesome hack by Dean Edwards"
6714 // Android Browser returns percentage for some values,
6715 // but width seems to be reliably pixels.
6716 // This is against the CSSOM draft spec:
6717 // https://drafts.csswg.org/cssom/#resolved-values
6718 if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
6720 // Remember the original values
6721 width = style.width;
6722 minWidth = style.minWidth;
6723 maxWidth = style.maxWidth;
6725 // Put in the new values to get a computed value out
6726 style.minWidth = style.maxWidth = style.width = ret;
6727 ret = computed.width;
6729 // Revert the changed values
6730 style.width = width;
6731 style.minWidth = minWidth;
6732 style.maxWidth = maxWidth;
6736 return ret !== undefined ?
6738 // Support: IE <=9 - 11 only
6739 // IE returns zIndex value as an integer.
6745 function addGetHookIf( conditionFn, hookFn ) {
6747 // Define the hook, we'll check on the first run if it's really needed.
6750 if ( conditionFn() ) {
6752 // Hook not needed (or it's not possible to use it due
6753 // to missing dependency), remove it.
6758 // Hook needed; redefine it so that the support test is not executed again.
6759 return ( this.get = hookFn ).apply( this, arguments );
6765 var cssPrefixes = [ "Webkit", "Moz", "ms" ],
6766 emptyStyle = document.createElement( "div" ).style,
6769 // Return a vendor-prefixed property or undefined
6770 function vendorPropName( name ) {
6772 // Check for vendor prefixed names
6773 var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
6774 i = cssPrefixes.length;
6777 name = cssPrefixes[ i ] + capName;
6778 if ( name in emptyStyle ) {
6784 // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
6785 function finalPropName( name ) {
6786 var final = jQuery.cssProps[ name ] || vendorProps[ name ];
6791 if ( name in emptyStyle ) {
6794 return vendorProps[ name ] = vendorPropName( name ) || name;
6800 // Swappable if display is none or starts with table
6801 // except "table", "table-cell", or "table-caption"
6802 // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
6803 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
6804 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
6805 cssNormalTransform = {
6810 function setPositiveNumber( _elem, value, subtract ) {
6812 // Any relative (+/-) values have already been
6813 // normalized at this point
6814 var matches = rcssNum.exec( value );
6817 // Guard against undefined "subtract", e.g., when used as in cssHooks
6818 Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
6822 function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
6823 var i = dimension === "width" ? 1 : 0,
6827 // Adjustment may not be necessary
6828 if ( box === ( isBorderBox ? "border" : "content" ) ) {
6832 for ( ; i < 4; i += 2 ) {
6834 // Both box models exclude margin
6835 if ( box === "margin" ) {
6836 delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
6839 // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
6840 if ( !isBorderBox ) {
6843 delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6845 // For "border" or "margin", add border
6846 if ( box !== "padding" ) {
6847 delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6849 // But still keep track of it otherwise
6851 extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6854 // If we get here with a border-box (content + padding + border), we're seeking "content" or
6855 // "padding" or "margin"
6858 // For "content", subtract padding
6859 if ( box === "content" ) {
6860 delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6863 // For "content" or "padding", subtract border
6864 if ( box !== "margin" ) {
6865 delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6870 // Account for positive content-box scroll gutter when requested by providing computedVal
6871 if ( !isBorderBox && computedVal >= 0 ) {
6873 // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
6874 // Assuming integer scroll gutter, subtract the rest and round down
6875 delta += Math.max( 0, Math.ceil(
6876 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
6882 // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
6883 // Use an explicit zero to avoid NaN (gh-3964)
6890 function getWidthOrHeight( elem, dimension, extra ) {
6892 // Start with computed style
6893 var styles = getStyles( elem ),
6895 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
6896 // Fake content-box until we know it's needed to know the true value.
6897 boxSizingNeeded = !support.boxSizingReliable() || extra,
6898 isBorderBox = boxSizingNeeded &&
6899 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
6900 valueIsBorderBox = isBorderBox,
6902 val = curCSS( elem, dimension, styles ),
6903 offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
6905 // Support: Firefox <=54
6906 // Return a confounding non-pixel value or feign ignorance, as appropriate.
6907 if ( rnumnonpx.test( val ) ) {
6915 // Support: IE 9 - 11 only
6916 // Use offsetWidth/offsetHeight for when box sizing is unreliable.
6917 // In those cases, the computed value can be trusted to be border-box.
6918 if ( ( !support.boxSizingReliable() && isBorderBox ||
6920 // Support: IE 10 - 11+, Edge 15 - 18+
6921 // IE/Edge misreport `getComputedStyle` of table rows with width/height
6922 // set in CSS while `offset*` properties report correct values.
6923 // Interestingly, in some cases IE 9 doesn't suffer from this issue.
6924 !support.reliableTrDimensions() && nodeName( elem, "tr" ) ||
6926 // Fall back to offsetWidth/offsetHeight when value is "auto"
6927 // This happens for inline elements with no explicit setting (gh-3571)
6930 // Support: Android <=4.1 - 4.3 only
6931 // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
6932 !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
6934 // Make sure the element is visible & connected
6935 elem.getClientRects().length ) {
6937 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
6939 // Where available, offsetWidth/offsetHeight approximate border box dimensions.
6940 // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
6941 // retrieved value as a content box dimension.
6942 valueIsBorderBox = offsetProp in elem;
6943 if ( valueIsBorderBox ) {
6944 val = elem[ offsetProp ];
6948 // Normalize "" and auto
6949 val = parseFloat( val ) || 0;
6951 // Adjust for the element's box model
6956 extra || ( isBorderBox ? "border" : "content" ),
6960 // Provide the current computed size to request scroll gutter calculation (gh-3589)
6968 // Add in style property hooks for overriding the default
6969 // behavior of getting and setting a style property
6972 get: function( elem, computed ) {
6975 // We should always get a number back from opacity
6976 var ret = curCSS( elem, "opacity" );
6977 return ret === "" ? "1" : ret;
6983 // Don't automatically add "px" to these possibly-unitless properties
6985 "animationIterationCount": true,
6986 "columnCount": true,
6987 "fillOpacity": true,
6993 "gridColumnEnd": true,
6994 "gridColumnStart": true,
6997 "gridRowStart": true,
7007 // Add in properties whose names you wish to fix before
7008 // setting or getting the value
7011 // Get and set the style property on a DOM Node
7012 style: function( elem, name, value, extra ) {
7014 // Don't set styles on text and comment nodes
7015 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
7019 // Make sure that we're working with the right name
7020 var ret, type, hooks,
7021 origName = camelCase( name ),
7022 isCustomProp = rcustomProp.test( name ),
7025 // Make sure that we're working with the right name. We don't
7026 // want to query the value if it is a CSS custom property
7027 // since they are user-defined.
7028 if ( !isCustomProp ) {
7029 name = finalPropName( origName );
7032 // Gets hook for the prefixed version, then unprefixed version
7033 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
7035 // Check if we're setting a value
7036 if ( value !== undefined ) {
7037 type = typeof value;
7039 // Convert "+=" or "-=" to relative numbers (trac-7345)
7040 if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
7041 value = adjustCSS( elem, name, ret );
7043 // Fixes bug trac-9237
7047 // Make sure that null and NaN values aren't set (trac-7116)
7048 if ( value == null || value !== value ) {
7052 // If a number was passed in, add the unit (except for certain CSS properties)
7053 // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
7054 // "px" to a few hardcoded values.
7055 if ( type === "number" && !isCustomProp ) {
7056 value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
7059 // background-* props affect original clone's values
7060 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
7061 style[ name ] = "inherit";
7064 // If a hook was provided, use that value, otherwise just set the specified value
7065 if ( !hooks || !( "set" in hooks ) ||
7066 ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
7068 if ( isCustomProp ) {
7069 style.setProperty( name, value );
7071 style[ name ] = value;
7077 // If a hook was provided get the non-computed value from there
7078 if ( hooks && "get" in hooks &&
7079 ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
7084 // Otherwise just get the value from the style object
7085 return style[ name ];
7089 css: function( elem, name, extra, styles ) {
7090 var val, num, hooks,
7091 origName = camelCase( name ),
7092 isCustomProp = rcustomProp.test( name );
7094 // Make sure that we're working with the right name. We don't
7095 // want to modify the value if it is a CSS custom property
7096 // since they are user-defined.
7097 if ( !isCustomProp ) {
7098 name = finalPropName( origName );
7101 // Try prefixed name followed by the unprefixed name
7102 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
7104 // If a hook was provided get the computed value from there
7105 if ( hooks && "get" in hooks ) {
7106 val = hooks.get( elem, true, extra );
7109 // Otherwise, if a way to get the computed value exists, use that
7110 if ( val === undefined ) {
7111 val = curCSS( elem, name, styles );
7114 // Convert "normal" to computed value
7115 if ( val === "normal" && name in cssNormalTransform ) {
7116 val = cssNormalTransform[ name ];
7119 // Make numeric if forced or a qualifier was provided and val looks numeric
7120 if ( extra === "" || extra ) {
7121 num = parseFloat( val );
7122 return extra === true || isFinite( num ) ? num || 0 : val;
7129 jQuery.each( [ "height", "width" ], function( _i, dimension ) {
7130 jQuery.cssHooks[ dimension ] = {
7131 get: function( elem, computed, extra ) {
7134 // Certain elements can have dimension info if we invisibly show them
7135 // but it must have a current display style that would benefit
7136 return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
7138 // Support: Safari 8+
7139 // Table columns in Safari have non-zero offsetWidth & zero
7140 // getBoundingClientRect().width unless display is changed.
7141 // Support: IE <=11 only
7142 // Running getBoundingClientRect on a disconnected node
7143 // in IE throws an error.
7144 ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
7145 swap( elem, cssShow, function() {
7146 return getWidthOrHeight( elem, dimension, extra );
7148 getWidthOrHeight( elem, dimension, extra );
7152 set: function( elem, value, extra ) {
7154 styles = getStyles( elem ),
7156 // Only read styles.position if the test has a chance to fail
7157 // to avoid forcing a reflow.
7158 scrollboxSizeBuggy = !support.scrollboxSize() &&
7159 styles.position === "absolute",
7161 // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
7162 boxSizingNeeded = scrollboxSizeBuggy || extra,
7163 isBorderBox = boxSizingNeeded &&
7164 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
7175 // Account for unreliable border-box dimensions by comparing offset* to computed and
7176 // faking a content-box to get border and padding (gh-3699)
7177 if ( isBorderBox && scrollboxSizeBuggy ) {
7178 subtract -= Math.ceil(
7179 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
7180 parseFloat( styles[ dimension ] ) -
7181 boxModelAdjustment( elem, dimension, "border", false, styles ) -
7186 // Convert to pixels if value adjustment is needed
7187 if ( subtract && ( matches = rcssNum.exec( value ) ) &&
7188 ( matches[ 3 ] || "px" ) !== "px" ) {
7190 elem.style[ dimension ] = value;
7191 value = jQuery.css( elem, dimension );
7194 return setPositiveNumber( elem, value, subtract );
7199 jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
7200 function( elem, computed ) {
7202 return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
7203 elem.getBoundingClientRect().left -
7204 swap( elem, { marginLeft: 0 }, function() {
7205 return elem.getBoundingClientRect().left;
7212 // These hooks are used by animate to expand properties
7217 }, function( prefix, suffix ) {
7218 jQuery.cssHooks[ prefix + suffix ] = {
7219 expand: function( value ) {
7223 // Assumes a single number if not a string
7224 parts = typeof value === "string" ? value.split( " " ) : [ value ];
7226 for ( ; i < 4; i++ ) {
7227 expanded[ prefix + cssExpand[ i ] + suffix ] =
7228 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
7235 if ( prefix !== "margin" ) {
7236 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
7241 css: function( name, value ) {
7242 return access( this, function( elem, name, value ) {
7247 if ( Array.isArray( name ) ) {
7248 styles = getStyles( elem );
7251 for ( ; i < len; i++ ) {
7252 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
7258 return value !== undefined ?
7259 jQuery.style( elem, name, value ) :
7260 jQuery.css( elem, name );
7261 }, name, value, arguments.length > 1 );
7266 function Tween( elem, options, prop, end, easing ) {
7267 return new Tween.prototype.init( elem, options, prop, end, easing );
7269 jQuery.Tween = Tween;
7273 init: function( elem, options, prop, end, easing, unit ) {
7276 this.easing = easing || jQuery.easing._default;
7277 this.options = options;
7278 this.start = this.now = this.cur();
7280 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
7283 var hooks = Tween.propHooks[ this.prop ];
7285 return hooks && hooks.get ?
7287 Tween.propHooks._default.get( this );
7289 run: function( percent ) {
7291 hooks = Tween.propHooks[ this.prop ];
7293 if ( this.options.duration ) {
7294 this.pos = eased = jQuery.easing[ this.easing ](
7295 percent, this.options.duration * percent, 0, 1, this.options.duration
7298 this.pos = eased = percent;
7300 this.now = ( this.end - this.start ) * eased + this.start;
7302 if ( this.options.step ) {
7303 this.options.step.call( this.elem, this.now, this );
7306 if ( hooks && hooks.set ) {
7309 Tween.propHooks._default.set( this );
7315 Tween.prototype.init.prototype = Tween.prototype;
7319 get: function( tween ) {
7322 // Use a property on the element directly when it is not a DOM element,
7323 // or when there is no matching style property that exists.
7324 if ( tween.elem.nodeType !== 1 ||
7325 tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
7326 return tween.elem[ tween.prop ];
7329 // Passing an empty string as a 3rd parameter to .css will automatically
7330 // attempt a parseFloat and fallback to a string if the parse fails.
7331 // Simple values such as "10px" are parsed to Float;
7332 // complex values such as "rotate(1rad)" are returned as-is.
7333 result = jQuery.css( tween.elem, tween.prop, "" );
7335 // Empty strings, null, undefined and "auto" are converted to 0.
7336 return !result || result === "auto" ? 0 : result;
7338 set: function( tween ) {
7340 // Use step hook for back compat.
7341 // Use cssHook if its there.
7342 // Use .style if available and use plain properties where available.
7343 if ( jQuery.fx.step[ tween.prop ] ) {
7344 jQuery.fx.step[ tween.prop ]( tween );
7345 } else if ( tween.elem.nodeType === 1 && (
7346 jQuery.cssHooks[ tween.prop ] ||
7347 tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
7348 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
7350 tween.elem[ tween.prop ] = tween.now;
7356 // Support: IE <=9 only
7357 // Panic based approach to setting things on disconnected nodes
7358 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
7359 set: function( tween ) {
7360 if ( tween.elem.nodeType && tween.elem.parentNode ) {
7361 tween.elem[ tween.prop ] = tween.now;
7367 linear: function( p ) {
7370 swing: function( p ) {
7371 return 0.5 - Math.cos( p * Math.PI ) / 2;
7376 jQuery.fx = Tween.prototype.init;
7378 // Back compat <1.8 extension point
7379 jQuery.fx.step = {};
7386 rfxtypes = /^(?:toggle|show|hide)$/,
7387 rrun = /queueHooks$/;
7389 function schedule() {
7391 if ( document.hidden === false && window.requestAnimationFrame ) {
7392 window.requestAnimationFrame( schedule );
7394 window.setTimeout( schedule, jQuery.fx.interval );
7401 // Animations created synchronously will run synchronously
7402 function createFxNow() {
7403 window.setTimeout( function() {
7406 return ( fxNow = Date.now() );
7409 // Generate parameters to create a standard animation
7410 function genFx( type, includeWidth ) {
7413 attrs = { height: type };
7415 // If we include width, step value is 1 to do all cssExpand values,
7416 // otherwise step value is 2 to skip over Left and Right
7417 includeWidth = includeWidth ? 1 : 0;
7418 for ( ; i < 4; i += 2 - includeWidth ) {
7419 which = cssExpand[ i ];
7420 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
7423 if ( includeWidth ) {
7424 attrs.opacity = attrs.width = type;
7430 function createTween( value, prop, animation ) {
7432 collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
7434 length = collection.length;
7435 for ( ; index < length; index++ ) {
7436 if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
7438 // We're done with this property
7444 function defaultPrefilter( elem, props, opts ) {
7445 var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
7446 isBox = "width" in props || "height" in props,
7450 hidden = elem.nodeType && isHiddenWithinTree( elem ),
7451 dataShow = dataPriv.get( elem, "fxshow" );
7453 // Queue-skipping animations hijack the fx hooks
7454 if ( !opts.queue ) {
7455 hooks = jQuery._queueHooks( elem, "fx" );
7456 if ( hooks.unqueued == null ) {
7458 oldfire = hooks.empty.fire;
7459 hooks.empty.fire = function() {
7460 if ( !hooks.unqueued ) {
7467 anim.always( function() {
7469 // Ensure the complete handler is called before this completes
7470 anim.always( function() {
7472 if ( !jQuery.queue( elem, "fx" ).length ) {
7479 // Detect show/hide animations
7480 for ( prop in props ) {
7481 value = props[ prop ];
7482 if ( rfxtypes.test( value ) ) {
7483 delete props[ prop ];
7484 toggle = toggle || value === "toggle";
7485 if ( value === ( hidden ? "hide" : "show" ) ) {
7487 // Pretend to be hidden if this is a "show" and
7488 // there is still data from a stopped show/hide
7489 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
7492 // Ignore all other no-op show/hide data
7497 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
7501 // Bail out if this is a no-op like .hide().hide()
7502 propTween = !jQuery.isEmptyObject( props );
7503 if ( !propTween && jQuery.isEmptyObject( orig ) ) {
7507 // Restrict "overflow" and "display" styles during box animations
7508 if ( isBox && elem.nodeType === 1 ) {
7510 // Support: IE <=9 - 11, Edge 12 - 15
7511 // Record all 3 overflow attributes because IE does not infer the shorthand
7512 // from identically-valued overflowX and overflowY and Edge just mirrors
7513 // the overflowX value there.
7514 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
7516 // Identify a display type, preferring old show/hide data over the CSS cascade
7517 restoreDisplay = dataShow && dataShow.display;
7518 if ( restoreDisplay == null ) {
7519 restoreDisplay = dataPriv.get( elem, "display" );
7521 display = jQuery.css( elem, "display" );
7522 if ( display === "none" ) {
7523 if ( restoreDisplay ) {
7524 display = restoreDisplay;
7527 // Get nonempty value(s) by temporarily forcing visibility
7528 showHide( [ elem ], true );
7529 restoreDisplay = elem.style.display || restoreDisplay;
7530 display = jQuery.css( elem, "display" );
7531 showHide( [ elem ] );
7535 // Animate inline elements as inline-block
7536 if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
7537 if ( jQuery.css( elem, "float" ) === "none" ) {
7539 // Restore the original display value at the end of pure show/hide animations
7541 anim.done( function() {
7542 style.display = restoreDisplay;
7544 if ( restoreDisplay == null ) {
7545 display = style.display;
7546 restoreDisplay = display === "none" ? "" : display;
7549 style.display = "inline-block";
7554 if ( opts.overflow ) {
7555 style.overflow = "hidden";
7556 anim.always( function() {
7557 style.overflow = opts.overflow[ 0 ];
7558 style.overflowX = opts.overflow[ 1 ];
7559 style.overflowY = opts.overflow[ 2 ];
7563 // Implement show/hide animations
7565 for ( prop in orig ) {
7567 // General show/hide setup for this element animation
7570 if ( "hidden" in dataShow ) {
7571 hidden = dataShow.hidden;
7574 dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
7577 // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
7579 dataShow.hidden = !hidden;
7582 // Show elements before animating them
7584 showHide( [ elem ], true );
7587 /* eslint-disable no-loop-func */
7589 anim.done( function() {
7591 /* eslint-enable no-loop-func */
7593 // The final step of a "hide" animation is actually hiding the element
7595 showHide( [ elem ] );
7597 dataPriv.remove( elem, "fxshow" );
7598 for ( prop in orig ) {
7599 jQuery.style( elem, prop, orig[ prop ] );
7604 // Per-property setup
7605 propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
7606 if ( !( prop in dataShow ) ) {
7607 dataShow[ prop ] = propTween.start;
7609 propTween.end = propTween.start;
7610 propTween.start = 0;
7616 function propFilter( props, specialEasing ) {
7617 var index, name, easing, value, hooks;
7619 // camelCase, specialEasing and expand cssHook pass
7620 for ( index in props ) {
7621 name = camelCase( index );
7622 easing = specialEasing[ name ];
7623 value = props[ index ];
7624 if ( Array.isArray( value ) ) {
7625 easing = value[ 1 ];
7626 value = props[ index ] = value[ 0 ];
7629 if ( index !== name ) {
7630 props[ name ] = value;
7631 delete props[ index ];
7634 hooks = jQuery.cssHooks[ name ];
7635 if ( hooks && "expand" in hooks ) {
7636 value = hooks.expand( value );
7637 delete props[ name ];
7639 // Not quite $.extend, this won't overwrite existing keys.
7640 // Reusing 'index' because we have the correct "name"
7641 for ( index in value ) {
7642 if ( !( index in props ) ) {
7643 props[ index ] = value[ index ];
7644 specialEasing[ index ] = easing;
7648 specialEasing[ name ] = easing;
7653 function Animation( elem, properties, options ) {
7657 length = Animation.prefilters.length,
7658 deferred = jQuery.Deferred().always( function() {
7660 // Don't match elem in the :animated selector
7667 var currentTime = fxNow || createFxNow(),
7668 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
7670 // Support: Android 2.3 only
7671 // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (trac-12497)
7672 temp = remaining / animation.duration || 0,
7675 length = animation.tweens.length;
7677 for ( ; index < length; index++ ) {
7678 animation.tweens[ index ].run( percent );
7681 deferred.notifyWith( elem, [ animation, percent, remaining ] );
7683 // If there's more to do, yield
7684 if ( percent < 1 && length ) {
7688 // If this was an empty animation, synthesize a final progress notification
7690 deferred.notifyWith( elem, [ animation, 1, 0 ] );
7693 // Resolve the animation and report its conclusion
7694 deferred.resolveWith( elem, [ animation ] );
7697 animation = deferred.promise( {
7699 props: jQuery.extend( {}, properties ),
7700 opts: jQuery.extend( true, {
7702 easing: jQuery.easing._default
7704 originalProperties: properties,
7705 originalOptions: options,
7706 startTime: fxNow || createFxNow(),
7707 duration: options.duration,
7709 createTween: function( prop, end ) {
7710 var tween = jQuery.Tween( elem, animation.opts, prop, end,
7711 animation.opts.specialEasing[ prop ] || animation.opts.easing );
7712 animation.tweens.push( tween );
7715 stop: function( gotoEnd ) {
7718 // If we are going to the end, we want to run all the tweens
7719 // otherwise we skip this part
7720 length = gotoEnd ? animation.tweens.length : 0;
7725 for ( ; index < length; index++ ) {
7726 animation.tweens[ index ].run( 1 );
7729 // Resolve when we played the last frame; otherwise, reject
7731 deferred.notifyWith( elem, [ animation, 1, 0 ] );
7732 deferred.resolveWith( elem, [ animation, gotoEnd ] );
7734 deferred.rejectWith( elem, [ animation, gotoEnd ] );
7739 props = animation.props;
7741 propFilter( props, animation.opts.specialEasing );
7743 for ( ; index < length; index++ ) {
7744 result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
7746 if ( isFunction( result.stop ) ) {
7747 jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
7748 result.stop.bind( result );
7754 jQuery.map( props, createTween, animation );
7756 if ( isFunction( animation.opts.start ) ) {
7757 animation.opts.start.call( elem, animation );
7760 // Attach callbacks from options
7762 .progress( animation.opts.progress )
7763 .done( animation.opts.done, animation.opts.complete )
7764 .fail( animation.opts.fail )
7765 .always( animation.opts.always );
7768 jQuery.extend( tick, {
7771 queue: animation.opts.queue
7778 jQuery.Animation = jQuery.extend( Animation, {
7781 "*": [ function( prop, value ) {
7782 var tween = this.createTween( prop, value );
7783 adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
7788 tweener: function( props, callback ) {
7789 if ( isFunction( props ) ) {
7793 props = props.match( rnothtmlwhite );
7798 length = props.length;
7800 for ( ; index < length; index++ ) {
7801 prop = props[ index ];
7802 Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
7803 Animation.tweeners[ prop ].unshift( callback );
7807 prefilters: [ defaultPrefilter ],
7809 prefilter: function( callback, prepend ) {
7811 Animation.prefilters.unshift( callback );
7813 Animation.prefilters.push( callback );
7818 jQuery.speed = function( speed, easing, fn ) {
7819 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
7820 complete: fn || !fn && easing ||
7821 isFunction( speed ) && speed,
7823 easing: fn && easing || easing && !isFunction( easing ) && easing
7826 // Go to the end state if fx are off
7827 if ( jQuery.fx.off ) {
7831 if ( typeof opt.duration !== "number" ) {
7832 if ( opt.duration in jQuery.fx.speeds ) {
7833 opt.duration = jQuery.fx.speeds[ opt.duration ];
7836 opt.duration = jQuery.fx.speeds._default;
7841 // Normalize opt.queue - true/undefined/null -> "fx"
7842 if ( opt.queue == null || opt.queue === true ) {
7847 opt.old = opt.complete;
7849 opt.complete = function() {
7850 if ( isFunction( opt.old ) ) {
7851 opt.old.call( this );
7855 jQuery.dequeue( this, opt.queue );
7863 fadeTo: function( speed, to, easing, callback ) {
7865 // Show any hidden elements after setting opacity to 0
7866 return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
7868 // Animate to the value specified
7869 .end().animate( { opacity: to }, speed, easing, callback );
7871 animate: function( prop, speed, easing, callback ) {
7872 var empty = jQuery.isEmptyObject( prop ),
7873 optall = jQuery.speed( speed, easing, callback ),
7874 doAnimation = function() {
7876 // Operate on a copy of prop so per-property easing won't be lost
7877 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
7879 // Empty animations, or finishing resolves immediately
7880 if ( empty || dataPriv.get( this, "finish" ) ) {
7885 doAnimation.finish = doAnimation;
7887 return empty || optall.queue === false ?
7888 this.each( doAnimation ) :
7889 this.queue( optall.queue, doAnimation );
7891 stop: function( type, clearQueue, gotoEnd ) {
7892 var stopQueue = function( hooks ) {
7893 var stop = hooks.stop;
7898 if ( typeof type !== "string" ) {
7899 gotoEnd = clearQueue;
7904 this.queue( type || "fx", [] );
7907 return this.each( function() {
7909 index = type != null && type + "queueHooks",
7910 timers = jQuery.timers,
7911 data = dataPriv.get( this );
7914 if ( data[ index ] && data[ index ].stop ) {
7915 stopQueue( data[ index ] );
7918 for ( index in data ) {
7919 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
7920 stopQueue( data[ index ] );
7925 for ( index = timers.length; index--; ) {
7926 if ( timers[ index ].elem === this &&
7927 ( type == null || timers[ index ].queue === type ) ) {
7929 timers[ index ].anim.stop( gotoEnd );
7931 timers.splice( index, 1 );
7935 // Start the next in the queue if the last step wasn't forced.
7936 // Timers currently will call their complete callbacks, which
7937 // will dequeue but only if they were gotoEnd.
7938 if ( dequeue || !gotoEnd ) {
7939 jQuery.dequeue( this, type );
7943 finish: function( type ) {
7944 if ( type !== false ) {
7945 type = type || "fx";
7947 return this.each( function() {
7949 data = dataPriv.get( this ),
7950 queue = data[ type + "queue" ],
7951 hooks = data[ type + "queueHooks" ],
7952 timers = jQuery.timers,
7953 length = queue ? queue.length : 0;
7955 // Enable finishing flag on private data
7958 // Empty the queue first
7959 jQuery.queue( this, type, [] );
7961 if ( hooks && hooks.stop ) {
7962 hooks.stop.call( this, true );
7965 // Look for any active animations, and finish them
7966 for ( index = timers.length; index--; ) {
7967 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
7968 timers[ index ].anim.stop( true );
7969 timers.splice( index, 1 );
7973 // Look for any animations in the old queue and finish them
7974 for ( index = 0; index < length; index++ ) {
7975 if ( queue[ index ] && queue[ index ].finish ) {
7976 queue[ index ].finish.call( this );
7980 // Turn off finishing flag
7986 jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) {
7987 var cssFn = jQuery.fn[ name ];
7988 jQuery.fn[ name ] = function( speed, easing, callback ) {
7989 return speed == null || typeof speed === "boolean" ?
7990 cssFn.apply( this, arguments ) :
7991 this.animate( genFx( name, true ), speed, easing, callback );
7995 // Generate shortcuts for custom animations
7997 slideDown: genFx( "show" ),
7998 slideUp: genFx( "hide" ),
7999 slideToggle: genFx( "toggle" ),
8000 fadeIn: { opacity: "show" },
8001 fadeOut: { opacity: "hide" },
8002 fadeToggle: { opacity: "toggle" }
8003 }, function( name, props ) {
8004 jQuery.fn[ name ] = function( speed, easing, callback ) {
8005 return this.animate( props, speed, easing, callback );
8010 jQuery.fx.tick = function() {
8013 timers = jQuery.timers;
8017 for ( ; i < timers.length; i++ ) {
8018 timer = timers[ i ];
8020 // Run the timer and safely remove it when done (allowing for external removal)
8021 if ( !timer() && timers[ i ] === timer ) {
8022 timers.splice( i--, 1 );
8026 if ( !timers.length ) {
8032 jQuery.fx.timer = function( timer ) {
8033 jQuery.timers.push( timer );
8037 jQuery.fx.interval = 13;
8038 jQuery.fx.start = function() {
8047 jQuery.fx.stop = function() {
8051 jQuery.fx.speeds = {
8060 // Based off of the plugin by Clint Helfers, with permission.
8061 jQuery.fn.delay = function( time, type ) {
8062 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
8063 type = type || "fx";
8065 return this.queue( type, function( next, hooks ) {
8066 var timeout = window.setTimeout( next, time );
8067 hooks.stop = function() {
8068 window.clearTimeout( timeout );
8075 var input = document.createElement( "input" ),
8076 select = document.createElement( "select" ),
8077 opt = select.appendChild( document.createElement( "option" ) );
8079 input.type = "checkbox";
8081 // Support: Android <=4.3 only
8082 // Default value for a checkbox should be "on"
8083 support.checkOn = input.value !== "";
8085 // Support: IE <=11 only
8086 // Must access selectedIndex to make default options select
8087 support.optSelected = opt.selected;
8089 // Support: IE <=11 only
8090 // An input loses its value after becoming a radio
8091 input = document.createElement( "input" );
8093 input.type = "radio";
8094 support.radioValue = input.value === "t";
8099 attrHandle = jQuery.expr.attrHandle;
8102 attr: function( name, value ) {
8103 return access( this, jQuery.attr, name, value, arguments.length > 1 );
8106 removeAttr: function( name ) {
8107 return this.each( function() {
8108 jQuery.removeAttr( this, name );
8114 attr: function( elem, name, value ) {
8116 nType = elem.nodeType;
8118 // Don't get/set attributes on text, comment and attribute nodes
8119 if ( nType === 3 || nType === 8 || nType === 2 ) {
8123 // Fallback to prop when attributes are not supported
8124 if ( typeof elem.getAttribute === "undefined" ) {
8125 return jQuery.prop( elem, name, value );
8128 // Attribute hooks are determined by the lowercase version
8129 // Grab necessary hook if one is defined
8130 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
8131 hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
8132 ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
8135 if ( value !== undefined ) {
8136 if ( value === null ) {
8137 jQuery.removeAttr( elem, name );
8141 if ( hooks && "set" in hooks &&
8142 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
8146 elem.setAttribute( name, value + "" );
8150 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
8154 ret = jQuery.find.attr( elem, name );
8156 // Non-existent attributes return null, we normalize to undefined
8157 return ret == null ? undefined : ret;
8162 set: function( elem, value ) {
8163 if ( !support.radioValue && value === "radio" &&
8164 nodeName( elem, "input" ) ) {
8165 var val = elem.value;
8166 elem.setAttribute( "type", value );
8176 removeAttr: function( elem, value ) {
8180 // Attribute names can contain non-HTML whitespace characters
8181 // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
8182 attrNames = value && value.match( rnothtmlwhite );
8184 if ( attrNames && elem.nodeType === 1 ) {
8185 while ( ( name = attrNames[ i++ ] ) ) {
8186 elem.removeAttribute( name );
8192 // Hooks for boolean attributes
8194 set: function( elem, value, name ) {
8195 if ( value === false ) {
8197 // Remove boolean attributes when set to false
8198 jQuery.removeAttr( elem, name );
8200 elem.setAttribute( name, name );
8206 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) {
8207 var getter = attrHandle[ name ] || jQuery.find.attr;
8209 attrHandle[ name ] = function( elem, name, isXML ) {
8211 lowercaseName = name.toLowerCase();
8215 // Avoid an infinite loop by temporarily removing this function from the getter
8216 handle = attrHandle[ lowercaseName ];
8217 attrHandle[ lowercaseName ] = ret;
8218 ret = getter( elem, name, isXML ) != null ?
8221 attrHandle[ lowercaseName ] = handle;
8230 var rfocusable = /^(?:input|select|textarea|button)$/i,
8231 rclickable = /^(?:a|area)$/i;
8234 prop: function( name, value ) {
8235 return access( this, jQuery.prop, name, value, arguments.length > 1 );
8238 removeProp: function( name ) {
8239 return this.each( function() {
8240 delete this[ jQuery.propFix[ name ] || name ];
8246 prop: function( elem, name, value ) {
8248 nType = elem.nodeType;
8250 // Don't get/set properties on text, comment and attribute nodes
8251 if ( nType === 3 || nType === 8 || nType === 2 ) {
8255 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
8257 // Fix name and attach hooks
8258 name = jQuery.propFix[ name ] || name;
8259 hooks = jQuery.propHooks[ name ];
8262 if ( value !== undefined ) {
8263 if ( hooks && "set" in hooks &&
8264 ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
8268 return ( elem[ name ] = value );
8271 if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
8275 return elem[ name ];
8280 get: function( elem ) {
8282 // Support: IE <=9 - 11 only
8283 // elem.tabIndex doesn't always return the
8284 // correct value when it hasn't been explicitly set
8285 // Use proper attribute retrieval (trac-12072)
8286 var tabindex = jQuery.find.attr( elem, "tabindex" );
8289 return parseInt( tabindex, 10 );
8293 rfocusable.test( elem.nodeName ) ||
8294 rclickable.test( elem.nodeName ) &&
8307 "class": "className"
8311 // Support: IE <=11 only
8312 // Accessing the selectedIndex property
8313 // forces the browser to respect setting selected
8315 // The getter ensures a default option is selected
8316 // when in an optgroup
8317 // eslint rule "no-unused-expressions" is disabled for this code
8318 // since it considers such accessions noop
8319 if ( !support.optSelected ) {
8320 jQuery.propHooks.selected = {
8321 get: function( elem ) {
8323 /* eslint no-unused-expressions: "off" */
8325 var parent = elem.parentNode;
8326 if ( parent && parent.parentNode ) {
8327 parent.parentNode.selectedIndex;
8331 set: function( elem ) {
8333 /* eslint no-unused-expressions: "off" */
8335 var parent = elem.parentNode;
8337 parent.selectedIndex;
8339 if ( parent.parentNode ) {
8340 parent.parentNode.selectedIndex;
8359 jQuery.propFix[ this.toLowerCase() ] = this;
8365 // Strip and collapse whitespace according to HTML spec
8366 // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
8367 function stripAndCollapse( value ) {
8368 var tokens = value.match( rnothtmlwhite ) || [];
8369 return tokens.join( " " );
8373 function getClass( elem ) {
8374 return elem.getAttribute && elem.getAttribute( "class" ) || "";
8377 function classesToArray( value ) {
8378 if ( Array.isArray( value ) ) {
8381 if ( typeof value === "string" ) {
8382 return value.match( rnothtmlwhite ) || [];
8388 addClass: function( value ) {
8389 var classNames, cur, curValue, className, i, finalValue;
8391 if ( isFunction( value ) ) {
8392 return this.each( function( j ) {
8393 jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
8397 classNames = classesToArray( value );
8399 if ( classNames.length ) {
8400 return this.each( function() {
8401 curValue = getClass( this );
8402 cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
8405 for ( i = 0; i < classNames.length; i++ ) {
8406 className = classNames[ i ];
8407 if ( cur.indexOf( " " + className + " " ) < 0 ) {
8408 cur += className + " ";
8412 // Only assign if different to avoid unneeded rendering.
8413 finalValue = stripAndCollapse( cur );
8414 if ( curValue !== finalValue ) {
8415 this.setAttribute( "class", finalValue );
8424 removeClass: function( value ) {
8425 var classNames, cur, curValue, className, i, finalValue;
8427 if ( isFunction( value ) ) {
8428 return this.each( function( j ) {
8429 jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
8433 if ( !arguments.length ) {
8434 return this.attr( "class", "" );
8437 classNames = classesToArray( value );
8439 if ( classNames.length ) {
8440 return this.each( function() {
8441 curValue = getClass( this );
8443 // This expression is here for better compressibility (see addClass)
8444 cur = this.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
8447 for ( i = 0; i < classNames.length; i++ ) {
8448 className = classNames[ i ];
8450 // Remove *all* instances
8451 while ( cur.indexOf( " " + className + " " ) > -1 ) {
8452 cur = cur.replace( " " + className + " ", " " );
8456 // Only assign if different to avoid unneeded rendering.
8457 finalValue = stripAndCollapse( cur );
8458 if ( curValue !== finalValue ) {
8459 this.setAttribute( "class", finalValue );
8468 toggleClass: function( value, stateVal ) {
8469 var classNames, className, i, self,
8470 type = typeof value,
8471 isValidValue = type === "string" || Array.isArray( value );
8473 if ( isFunction( value ) ) {
8474 return this.each( function( i ) {
8475 jQuery( this ).toggleClass(
8476 value.call( this, i, getClass( this ), stateVal ),
8482 if ( typeof stateVal === "boolean" && isValidValue ) {
8483 return stateVal ? this.addClass( value ) : this.removeClass( value );
8486 classNames = classesToArray( value );
8488 return this.each( function() {
8489 if ( isValidValue ) {
8491 // Toggle individual class names
8492 self = jQuery( this );
8494 for ( i = 0; i < classNames.length; i++ ) {
8495 className = classNames[ i ];
8497 // Check each className given, space separated list
8498 if ( self.hasClass( className ) ) {
8499 self.removeClass( className );
8501 self.addClass( className );
8505 // Toggle whole class name
8506 } else if ( value === undefined || type === "boolean" ) {
8507 className = getClass( this );
8510 // Store className if set
8511 dataPriv.set( this, "__className__", className );
8514 // If the element has a class name or if we're passed `false`,
8515 // then remove the whole classname (if there was one, the above saved it).
8516 // Otherwise bring back whatever was previously saved (if anything),
8517 // falling back to the empty string if nothing was stored.
8518 if ( this.setAttribute ) {
8519 this.setAttribute( "class",
8520 className || value === false ?
8522 dataPriv.get( this, "__className__" ) || ""
8529 hasClass: function( selector ) {
8530 var className, elem,
8533 className = " " + selector + " ";
8534 while ( ( elem = this[ i++ ] ) ) {
8535 if ( elem.nodeType === 1 &&
8536 ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
8548 var rreturn = /\r/g;
8551 val: function( value ) {
8552 var hooks, ret, valueIsFunction,
8555 if ( !arguments.length ) {
8557 hooks = jQuery.valHooks[ elem.type ] ||
8558 jQuery.valHooks[ elem.nodeName.toLowerCase() ];
8562 ( ret = hooks.get( elem, "value" ) ) !== undefined
8569 // Handle most common string cases
8570 if ( typeof ret === "string" ) {
8571 return ret.replace( rreturn, "" );
8574 // Handle cases where value is null/undef or number
8575 return ret == null ? "" : ret;
8581 valueIsFunction = isFunction( value );
8583 return this.each( function( i ) {
8586 if ( this.nodeType !== 1 ) {
8590 if ( valueIsFunction ) {
8591 val = value.call( this, i, jQuery( this ).val() );
8596 // Treat null/undefined as ""; convert numbers to string
8597 if ( val == null ) {
8600 } else if ( typeof val === "number" ) {
8603 } else if ( Array.isArray( val ) ) {
8604 val = jQuery.map( val, function( value ) {
8605 return value == null ? "" : value + "";
8609 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
8611 // If set returns undefined, fall back to normal setting
8612 if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
8622 get: function( elem ) {
8624 var val = jQuery.find.attr( elem, "value" );
8625 return val != null ?
8628 // Support: IE <=10 - 11 only
8629 // option.text throws exceptions (trac-14686, trac-14858)
8630 // Strip and collapse whitespace
8631 // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
8632 stripAndCollapse( jQuery.text( elem ) );
8636 get: function( elem ) {
8637 var value, option, i,
8638 options = elem.options,
8639 index = elem.selectedIndex,
8640 one = elem.type === "select-one",
8641 values = one ? null : [],
8642 max = one ? index + 1 : options.length;
8648 i = one ? index : 0;
8651 // Loop through all the selected options
8652 for ( ; i < max; i++ ) {
8653 option = options[ i ];
8655 // Support: IE <=9 only
8656 // IE8-9 doesn't update selected after form reset (trac-2551)
8657 if ( ( option.selected || i === index ) &&
8659 // Don't return options that are disabled or in a disabled optgroup
8661 ( !option.parentNode.disabled ||
8662 !nodeName( option.parentNode, "optgroup" ) ) ) {
8664 // Get the specific value for the option
8665 value = jQuery( option ).val();
8667 // We don't need an array for one selects
8672 // Multi-Selects return an array
8673 values.push( value );
8680 set: function( elem, value ) {
8681 var optionSet, option,
8682 options = elem.options,
8683 values = jQuery.makeArray( value ),
8687 option = options[ i ];
8689 /* eslint-disable no-cond-assign */
8691 if ( option.selected =
8692 jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
8697 /* eslint-enable no-cond-assign */
8700 // Force browsers to behave consistently when non-matching value is set
8702 elem.selectedIndex = -1;
8710 // Radios and checkboxes getter/setter
8711 jQuery.each( [ "radio", "checkbox" ], function() {
8712 jQuery.valHooks[ this ] = {
8713 set: function( elem, value ) {
8714 if ( Array.isArray( value ) ) {
8715 return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
8719 if ( !support.checkOn ) {
8720 jQuery.valHooks[ this ].get = function( elem ) {
8721 return elem.getAttribute( "value" ) === null ? "on" : elem.value;
8729 // Return jQuery for attributes-only inclusion
8732 support.focusin = "onfocusin" in window;
8735 var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
8736 stopPropagationCallback = function( e ) {
8737 e.stopPropagation();
8740 jQuery.extend( jQuery.event, {
8742 trigger: function( event, data, elem, onlyHandlers ) {
8744 var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
8745 eventPath = [ elem || document ],
8746 type = hasOwn.call( event, "type" ) ? event.type : event,
8747 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
8749 cur = lastElement = tmp = elem = elem || document;
8751 // Don't do events on text and comment nodes
8752 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
8756 // focus/blur morphs to focusin/out; ensure we're not firing them right now
8757 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
8761 if ( type.indexOf( "." ) > -1 ) {
8763 // Namespaced trigger; create a regexp to match event type in handle()
8764 namespaces = type.split( "." );
8765 type = namespaces.shift();
8768 ontype = type.indexOf( ":" ) < 0 && "on" + type;
8770 // Caller can pass in a jQuery.Event object, Object, or just an event type string
8771 event = event[ jQuery.expando ] ?
8773 new jQuery.Event( type, typeof event === "object" && event );
8775 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
8776 event.isTrigger = onlyHandlers ? 2 : 3;
8777 event.namespace = namespaces.join( "." );
8778 event.rnamespace = event.namespace ?
8779 new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
8782 // Clean up the event in case it is being reused
8783 event.result = undefined;
8784 if ( !event.target ) {
8785 event.target = elem;
8788 // Clone any incoming data and prepend the event, creating the handler arg list
8789 data = data == null ?
8791 jQuery.makeArray( data, [ event ] );
8793 // Allow special events to draw outside the lines
8794 special = jQuery.event.special[ type ] || {};
8795 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
8799 // Determine event propagation path in advance, per W3C events spec (trac-9951)
8800 // Bubble up to document, then to window; watch for a global ownerDocument var (trac-9724)
8801 if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
8803 bubbleType = special.delegateType || type;
8804 if ( !rfocusMorph.test( bubbleType + type ) ) {
8805 cur = cur.parentNode;
8807 for ( ; cur; cur = cur.parentNode ) {
8808 eventPath.push( cur );
8812 // Only add window if we got to document (e.g., not plain obj or detached DOM)
8813 if ( tmp === ( elem.ownerDocument || document ) ) {
8814 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
8818 // Fire handlers on the event path
8820 while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
8822 event.type = i > 1 ?
8824 special.bindType || type;
8827 handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] &&
8828 dataPriv.get( cur, "handle" );
8830 handle.apply( cur, data );
8834 handle = ontype && cur[ ontype ];
8835 if ( handle && handle.apply && acceptData( cur ) ) {
8836 event.result = handle.apply( cur, data );
8837 if ( event.result === false ) {
8838 event.preventDefault();
8844 // If nobody prevented the default action, do it now
8845 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
8847 if ( ( !special._default ||
8848 special._default.apply( eventPath.pop(), data ) === false ) &&
8849 acceptData( elem ) ) {
8851 // Call a native DOM method on the target with the same name as the event.
8852 // Don't do default actions on window, that's where global variables be (trac-6170)
8853 if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
8855 // Don't re-trigger an onFOO event when we call its FOO() method
8856 tmp = elem[ ontype ];
8859 elem[ ontype ] = null;
8862 // Prevent re-triggering of the same event, since we already bubbled it above
8863 jQuery.event.triggered = type;
8865 if ( event.isPropagationStopped() ) {
8866 lastElement.addEventListener( type, stopPropagationCallback );
8871 if ( event.isPropagationStopped() ) {
8872 lastElement.removeEventListener( type, stopPropagationCallback );
8875 jQuery.event.triggered = undefined;
8878 elem[ ontype ] = tmp;
8884 return event.result;
8887 // Piggyback on a donor event to simulate a different one
8888 // Used only for `focus(in | out)` events
8889 simulate: function( type, elem, event ) {
8890 var e = jQuery.extend(
8899 jQuery.event.trigger( e, null, elem );
8906 trigger: function( type, data ) {
8907 return this.each( function() {
8908 jQuery.event.trigger( type, data, this );
8911 triggerHandler: function( type, data ) {
8912 var elem = this[ 0 ];
8914 return jQuery.event.trigger( type, data, elem, true );
8920 // Support: Firefox <=44
8921 // Firefox doesn't have focus(in | out) events
8922 // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
8924 // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
8925 // focus(in | out) events fire after focus & blur events,
8926 // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
8927 // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
8928 if ( !support.focusin ) {
8929 jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
8931 // Attach a single capturing handler on the document while someone wants focusin/focusout
8932 var handler = function( event ) {
8933 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
8936 jQuery.event.special[ fix ] = {
8939 // Handle: regular nodes (via `this.ownerDocument`), window
8940 // (via `this.document`) & document (via `this`).
8941 var doc = this.ownerDocument || this.document || this,
8942 attaches = dataPriv.access( doc, fix );
8945 doc.addEventListener( orig, handler, true );
8947 dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
8949 teardown: function() {
8950 var doc = this.ownerDocument || this.document || this,
8951 attaches = dataPriv.access( doc, fix ) - 1;
8954 doc.removeEventListener( orig, handler, true );
8955 dataPriv.remove( doc, fix );
8958 dataPriv.access( doc, fix, attaches );
8964 var location = window.location;
8966 var nonce = { guid: Date.now() };
8968 var rquery = ( /\?/ );
8972 // Cross-browser xml parsing
8973 jQuery.parseXML = function( data ) {
8974 var xml, parserErrorElem;
8975 if ( !data || typeof data !== "string" ) {
8979 // Support: IE 9 - 11 only
8980 // IE throws on parseFromString with invalid input.
8982 xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
8985 parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ];
8986 if ( !xml || parserErrorElem ) {
8987 jQuery.error( "Invalid XML: " + (
8989 jQuery.map( parserErrorElem.childNodes, function( el ) {
8990 return el.textContent;
9002 rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
9003 rsubmittable = /^(?:input|select|textarea|keygen)/i;
9005 function buildParams( prefix, obj, traditional, add ) {
9008 if ( Array.isArray( obj ) ) {
9010 // Serialize array item.
9011 jQuery.each( obj, function( i, v ) {
9012 if ( traditional || rbracket.test( prefix ) ) {
9014 // Treat each array item as a scalar.
9019 // Item is non-scalar (array or object), encode its numeric index.
9021 prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
9029 } else if ( !traditional && toType( obj ) === "object" ) {
9031 // Serialize object item.
9032 for ( name in obj ) {
9033 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
9038 // Serialize scalar item.
9043 // Serialize an array of form elements or a set of
9044 // key/values into a query string
9045 jQuery.param = function( a, traditional ) {
9048 add = function( key, valueOrFunction ) {
9050 // If value is a function, invoke it and use its return value
9051 var value = isFunction( valueOrFunction ) ?
9055 s[ s.length ] = encodeURIComponent( key ) + "=" +
9056 encodeURIComponent( value == null ? "" : value );
9063 // If an array was passed in, assume that it is an array of form elements.
9064 if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
9066 // Serialize the form elements
9067 jQuery.each( a, function() {
9068 add( this.name, this.value );
9073 // If traditional, encode the "old" way (the way 1.3.2 or older
9074 // did it), otherwise encode params recursively.
9075 for ( prefix in a ) {
9076 buildParams( prefix, a[ prefix ], traditional, add );
9080 // Return the resulting serialization
9081 return s.join( "&" );
9085 serialize: function() {
9086 return jQuery.param( this.serializeArray() );
9088 serializeArray: function() {
9089 return this.map( function() {
9091 // Can add propHook for "elements" to filter or add form elements
9092 var elements = jQuery.prop( this, "elements" );
9093 return elements ? jQuery.makeArray( elements ) : this;
9094 } ).filter( function() {
9095 var type = this.type;
9097 // Use .is( ":disabled" ) so that fieldset[disabled] works
9098 return this.name && !jQuery( this ).is( ":disabled" ) &&
9099 rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
9100 ( this.checked || !rcheckableType.test( type ) );
9101 } ).map( function( _i, elem ) {
9102 var val = jQuery( this ).val();
9104 if ( val == null ) {
9108 if ( Array.isArray( val ) ) {
9109 return jQuery.map( val, function( val ) {
9110 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
9114 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
9123 rantiCache = /([?&])_=[^&]*/,
9124 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
9126 // trac-7653, trac-8125, trac-8152: local protocol detection
9127 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
9128 rnoContent = /^(?:GET|HEAD)$/,
9129 rprotocol = /^\/\//,
9132 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
9133 * 2) These are called:
9134 * - BEFORE asking for a transport
9135 * - AFTER param serialization (s.data is a string if s.processData is true)
9136 * 3) key is the dataType
9137 * 4) the catchall symbol "*" can be used
9138 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
9142 /* Transports bindings
9143 * 1) key is the dataType
9144 * 2) the catchall symbol "*" can be used
9145 * 3) selection will start with transport dataType and THEN go to "*" if needed
9149 // Avoid comment-prolog char sequence (trac-10098); must appease lint and evade compression
9150 allTypes = "*/".concat( "*" ),
9152 // Anchor tag for parsing the document origin
9153 originAnchor = document.createElement( "a" );
9155 originAnchor.href = location.href;
9157 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
9158 function addToPrefiltersOrTransports( structure ) {
9160 // dataTypeExpression is optional and defaults to "*"
9161 return function( dataTypeExpression, func ) {
9163 if ( typeof dataTypeExpression !== "string" ) {
9164 func = dataTypeExpression;
9165 dataTypeExpression = "*";
9170 dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
9172 if ( isFunction( func ) ) {
9174 // For each dataType in the dataTypeExpression
9175 while ( ( dataType = dataTypes[ i++ ] ) ) {
9177 // Prepend if requested
9178 if ( dataType[ 0 ] === "+" ) {
9179 dataType = dataType.slice( 1 ) || "*";
9180 ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
9184 ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
9191 // Base inspection function for prefilters and transports
9192 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
9195 seekingTransport = ( structure === transports );
9197 function inspect( dataType ) {
9199 inspected[ dataType ] = true;
9200 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
9201 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
9202 if ( typeof dataTypeOrTransport === "string" &&
9203 !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
9205 options.dataTypes.unshift( dataTypeOrTransport );
9206 inspect( dataTypeOrTransport );
9208 } else if ( seekingTransport ) {
9209 return !( selected = dataTypeOrTransport );
9215 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
9218 // A special extend for ajax options
9219 // that takes "flat" options (not to be deep extended)
9221 function ajaxExtend( target, src ) {
9223 flatOptions = jQuery.ajaxSettings.flatOptions || {};
9225 for ( key in src ) {
9226 if ( src[ key ] !== undefined ) {
9227 ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
9231 jQuery.extend( true, target, deep );
9237 /* Handles responses to an ajax request:
9238 * - finds the right dataType (mediates between content-type and expected dataType)
9239 * - returns the corresponding response
9241 function ajaxHandleResponses( s, jqXHR, responses ) {
9243 var ct, type, finalDataType, firstDataType,
9244 contents = s.contents,
9245 dataTypes = s.dataTypes;
9247 // Remove auto dataType and get content-type in the process
9248 while ( dataTypes[ 0 ] === "*" ) {
9250 if ( ct === undefined ) {
9251 ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
9255 // Check if we're dealing with a known content-type
9257 for ( type in contents ) {
9258 if ( contents[ type ] && contents[ type ].test( ct ) ) {
9259 dataTypes.unshift( type );
9265 // Check to see if we have a response for the expected dataType
9266 if ( dataTypes[ 0 ] in responses ) {
9267 finalDataType = dataTypes[ 0 ];
9270 // Try convertible dataTypes
9271 for ( type in responses ) {
9272 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
9273 finalDataType = type;
9276 if ( !firstDataType ) {
9277 firstDataType = type;
9281 // Or just use first one
9282 finalDataType = finalDataType || firstDataType;
9285 // If we found a dataType
9286 // We add the dataType to the list if needed
9287 // and return the corresponding response
9288 if ( finalDataType ) {
9289 if ( finalDataType !== dataTypes[ 0 ] ) {
9290 dataTypes.unshift( finalDataType );
9292 return responses[ finalDataType ];
9296 /* Chain conversions given the request and the original response
9297 * Also sets the responseXXX fields on the jqXHR instance
9299 function ajaxConvert( s, response, jqXHR, isSuccess ) {
9300 var conv2, current, conv, tmp, prev,
9303 // Work with a copy of dataTypes in case we need to modify it for conversion
9304 dataTypes = s.dataTypes.slice();
9306 // Create converters map with lowercased keys
9307 if ( dataTypes[ 1 ] ) {
9308 for ( conv in s.converters ) {
9309 converters[ conv.toLowerCase() ] = s.converters[ conv ];
9313 current = dataTypes.shift();
9315 // Convert to each sequential dataType
9318 if ( s.responseFields[ current ] ) {
9319 jqXHR[ s.responseFields[ current ] ] = response;
9322 // Apply the dataFilter if provided
9323 if ( !prev && isSuccess && s.dataFilter ) {
9324 response = s.dataFilter( response, s.dataType );
9328 current = dataTypes.shift();
9332 // There's only work to do if current dataType is non-auto
9333 if ( current === "*" ) {
9337 // Convert response if prev dataType is non-auto and differs from current
9338 } else if ( prev !== "*" && prev !== current ) {
9340 // Seek a direct converter
9341 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
9343 // If none found, seek a pair
9345 for ( conv2 in converters ) {
9347 // If conv2 outputs current
9348 tmp = conv2.split( " " );
9349 if ( tmp[ 1 ] === current ) {
9351 // If prev can be converted to accepted input
9352 conv = converters[ prev + " " + tmp[ 0 ] ] ||
9353 converters[ "* " + tmp[ 0 ] ];
9356 // Condense equivalence converters
9357 if ( conv === true ) {
9358 conv = converters[ conv2 ];
9360 // Otherwise, insert the intermediate dataType
9361 } else if ( converters[ conv2 ] !== true ) {
9363 dataTypes.unshift( tmp[ 1 ] );
9371 // Apply converter (if not an equivalence)
9372 if ( conv !== true ) {
9374 // Unless errors are allowed to bubble, catch and return them
9375 if ( conv && s.throws ) {
9376 response = conv( response );
9379 response = conv( response );
9382 state: "parsererror",
9383 error: conv ? e : "No conversion from " + prev + " to " + current
9392 return { state: "success", data: response };
9397 // Counter for holding the number of active queries
9400 // Last-Modified header cache for next request
9407 isLocal: rlocalProtocol.test( location.protocol ),
9411 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
9429 xml: "application/xml, text/xml",
9430 json: "application/json, text/javascript"
9441 text: "responseText",
9442 json: "responseJSON"
9446 // Keys separate source (or catchall "*") and destination types with a single space
9449 // Convert anything to text
9452 // Text to html (true = no transformation)
9455 // Evaluate text as a json expression
9456 "text json": JSON.parse,
9458 // Parse text as xml
9459 "text xml": jQuery.parseXML
9462 // For options that shouldn't be deep extended:
9463 // you can add your own custom options here if
9464 // and when you create one that shouldn't be
9465 // deep extended (see ajaxExtend)
9472 // Creates a full fledged settings object into target
9473 // with both ajaxSettings and settings fields.
9474 // If target is omitted, writes into ajaxSettings.
9475 ajaxSetup: function( target, settings ) {
9478 // Building a settings object
9479 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
9481 // Extending ajaxSettings
9482 ajaxExtend( jQuery.ajaxSettings, target );
9485 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
9486 ajaxTransport: addToPrefiltersOrTransports( transports ),
9489 ajax: function( url, options ) {
9491 // If url is an object, simulate pre-1.5 signature
9492 if ( typeof url === "object" ) {
9497 // Force options to be an object
9498 options = options || {};
9502 // URL without anti-cache param
9506 responseHeadersString,
9515 // Request state (becomes false upon send and true upon completion)
9518 // To know if global events are to be dispatched
9524 // uncached part of the url
9527 // Create the final options object
9528 s = jQuery.ajaxSetup( {}, options ),
9530 // Callbacks context
9531 callbackContext = s.context || s,
9533 // Context for global events is callbackContext if it is a DOM node or jQuery collection
9534 globalEventContext = s.context &&
9535 ( callbackContext.nodeType || callbackContext.jquery ) ?
9536 jQuery( callbackContext ) :
9540 deferred = jQuery.Deferred(),
9541 completeDeferred = jQuery.Callbacks( "once memory" ),
9543 // Status-dependent callbacks
9544 statusCode = s.statusCode || {},
9546 // Headers (they are sent all at once)
9547 requestHeaders = {},
9548 requestHeadersNames = {},
9550 // Default abort message
9551 strAbort = "canceled",
9557 // Builds headers hashtable if needed
9558 getResponseHeader: function( key ) {
9561 if ( !responseHeaders ) {
9562 responseHeaders = {};
9563 while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
9564 responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
9565 ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
9566 .concat( match[ 2 ] );
9569 match = responseHeaders[ key.toLowerCase() + " " ];
9571 return match == null ? null : match.join( ", " );
9575 getAllResponseHeaders: function() {
9576 return completed ? responseHeadersString : null;
9579 // Caches the header
9580 setRequestHeader: function( name, value ) {
9581 if ( completed == null ) {
9582 name = requestHeadersNames[ name.toLowerCase() ] =
9583 requestHeadersNames[ name.toLowerCase() ] || name;
9584 requestHeaders[ name ] = value;
9589 // Overrides response content-type header
9590 overrideMimeType: function( type ) {
9591 if ( completed == null ) {
9597 // Status-dependent callbacks
9598 statusCode: function( map ) {
9603 // Execute the appropriate callbacks
9604 jqXHR.always( map[ jqXHR.status ] );
9607 // Lazy-add the new callbacks in a way that preserves old ones
9608 for ( code in map ) {
9609 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
9616 // Cancel the request
9617 abort: function( statusText ) {
9618 var finalText = statusText || strAbort;
9620 transport.abort( finalText );
9622 done( 0, finalText );
9628 deferred.promise( jqXHR );
9630 // Add protocol if not provided (prefilters might expect it)
9631 // Handle falsy url in the settings object (trac-10093: consistency with old signature)
9632 // We also use the url parameter if available
9633 s.url = ( ( url || s.url || location.href ) + "" )
9634 .replace( rprotocol, location.protocol + "//" );
9636 // Alias method option to type as per ticket trac-12004
9637 s.type = options.method || options.type || s.method || s.type;
9639 // Extract dataTypes list
9640 s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
9642 // A cross-domain request is in order when the origin doesn't match the current origin.
9643 if ( s.crossDomain == null ) {
9644 urlAnchor = document.createElement( "a" );
9646 // Support: IE <=8 - 11, Edge 12 - 15
9647 // IE throws exception on accessing the href property if url is malformed,
9648 // e.g. http://example.com:80x/
9650 urlAnchor.href = s.url;
9652 // Support: IE <=8 - 11 only
9653 // Anchor's host property isn't correctly set when s.url is relative
9654 urlAnchor.href = urlAnchor.href;
9655 s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
9656 urlAnchor.protocol + "//" + urlAnchor.host;
9659 // If there is an error parsing the URL, assume it is crossDomain,
9660 // it can be rejected by the transport if it is invalid
9661 s.crossDomain = true;
9665 // Convert data if not already a string
9666 if ( s.data && s.processData && typeof s.data !== "string" ) {
9667 s.data = jQuery.param( s.data, s.traditional );
9671 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
9673 // If request was aborted inside a prefilter, stop there
9678 // We can fire global events as of now if asked to
9679 // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (trac-15118)
9680 fireGlobals = jQuery.event && s.global;
9682 // Watch for a new set of requests
9683 if ( fireGlobals && jQuery.active++ === 0 ) {
9684 jQuery.event.trigger( "ajaxStart" );
9687 // Uppercase the type
9688 s.type = s.type.toUpperCase();
9690 // Determine if request has content
9691 s.hasContent = !rnoContent.test( s.type );
9693 // Save the URL in case we're toying with the If-Modified-Since
9694 // and/or If-None-Match header later on
9695 // Remove hash to simplify url manipulation
9696 cacheURL = s.url.replace( rhash, "" );
9698 // More options handling for requests with no content
9699 if ( !s.hasContent ) {
9701 // Remember the hash so we can put it back
9702 uncached = s.url.slice( cacheURL.length );
9704 // If data is available and should be processed, append data to url
9705 if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
9706 cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
9708 // trac-9682: remove data so that it's not used in an eventual retry
9712 // Add or update anti-cache param if needed
9713 if ( s.cache === false ) {
9714 cacheURL = cacheURL.replace( rantiCache, "$1" );
9715 uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) +
9719 // Put hash and anti-cache on the URL that will be requested (gh-1732)
9720 s.url = cacheURL + uncached;
9722 // Change '%20' to '+' if this is encoded form body content (gh-2658)
9723 } else if ( s.data && s.processData &&
9724 ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
9725 s.data = s.data.replace( r20, "+" );
9728 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9729 if ( s.ifModified ) {
9730 if ( jQuery.lastModified[ cacheURL ] ) {
9731 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
9733 if ( jQuery.etag[ cacheURL ] ) {
9734 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
9738 // Set the correct header, if data is being sent
9739 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
9740 jqXHR.setRequestHeader( "Content-Type", s.contentType );
9743 // Set the Accepts header for the server, depending on the dataType
9744 jqXHR.setRequestHeader(
9746 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
9747 s.accepts[ s.dataTypes[ 0 ] ] +
9748 ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
9752 // Check for headers option
9753 for ( i in s.headers ) {
9754 jqXHR.setRequestHeader( i, s.headers[ i ] );
9757 // Allow custom headers/mimetypes and early abort
9758 if ( s.beforeSend &&
9759 ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
9761 // Abort if not done already and return
9762 return jqXHR.abort();
9765 // Aborting is no longer a cancellation
9768 // Install callbacks on deferreds
9769 completeDeferred.add( s.complete );
9770 jqXHR.done( s.success );
9771 jqXHR.fail( s.error );
9774 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
9776 // If no transport, we auto-abort
9778 done( -1, "No Transport" );
9780 jqXHR.readyState = 1;
9782 // Send global event
9783 if ( fireGlobals ) {
9784 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
9787 // If request was aborted inside ajaxSend, stop there
9793 if ( s.async && s.timeout > 0 ) {
9794 timeoutTimer = window.setTimeout( function() {
9795 jqXHR.abort( "timeout" );
9801 transport.send( requestHeaders, done );
9804 // Rethrow post-completion exceptions
9809 // Propagate others as results
9814 // Callback for when everything is done
9815 function done( status, nativeStatusText, responses, headers ) {
9816 var isSuccess, success, error, response, modified,
9817 statusText = nativeStatusText;
9819 // Ignore repeat invocations
9826 // Clear timeout if it exists
9827 if ( timeoutTimer ) {
9828 window.clearTimeout( timeoutTimer );
9831 // Dereference transport for early garbage collection
9832 // (no matter how long the jqXHR object will be used)
9833 transport = undefined;
9835 // Cache response headers
9836 responseHeadersString = headers || "";
9839 jqXHR.readyState = status > 0 ? 4 : 0;
9841 // Determine if successful
9842 isSuccess = status >= 200 && status < 300 || status === 304;
9844 // Get response data
9846 response = ajaxHandleResponses( s, jqXHR, responses );
9849 // Use a noop converter for missing script but not if jsonp
9851 jQuery.inArray( "script", s.dataTypes ) > -1 &&
9852 jQuery.inArray( "json", s.dataTypes ) < 0 ) {
9853 s.converters[ "text script" ] = function() {};
9856 // Convert no matter what (that way responseXXX fields are always set)
9857 response = ajaxConvert( s, response, jqXHR, isSuccess );
9859 // If successful, handle type chaining
9862 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
9863 if ( s.ifModified ) {
9864 modified = jqXHR.getResponseHeader( "Last-Modified" );
9866 jQuery.lastModified[ cacheURL ] = modified;
9868 modified = jqXHR.getResponseHeader( "etag" );
9870 jQuery.etag[ cacheURL ] = modified;
9875 if ( status === 204 || s.type === "HEAD" ) {
9876 statusText = "nocontent";
9879 } else if ( status === 304 ) {
9880 statusText = "notmodified";
9882 // If we have data, let's convert it
9884 statusText = response.state;
9885 success = response.data;
9886 error = response.error;
9891 // Extract error from statusText and normalize for non-aborts
9893 if ( status || !statusText ) {
9894 statusText = "error";
9901 // Set data for the fake xhr object
9902 jqXHR.status = status;
9903 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
9907 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
9909 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
9912 // Status-dependent callbacks
9913 jqXHR.statusCode( statusCode );
9914 statusCode = undefined;
9916 if ( fireGlobals ) {
9917 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
9918 [ jqXHR, s, isSuccess ? success : error ] );
9922 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
9924 if ( fireGlobals ) {
9925 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
9927 // Handle the global AJAX counter
9928 if ( !( --jQuery.active ) ) {
9929 jQuery.event.trigger( "ajaxStop" );
9937 getJSON: function( url, data, callback ) {
9938 return jQuery.get( url, data, callback, "json" );
9941 getScript: function( url, callback ) {
9942 return jQuery.get( url, undefined, callback, "script" );
9946 jQuery.each( [ "get", "post" ], function( _i, method ) {
9947 jQuery[ method ] = function( url, data, callback, type ) {
9949 // Shift arguments if data argument was omitted
9950 if ( isFunction( data ) ) {
9951 type = type || callback;
9956 // The url can be an options object (which then must have .url)
9957 return jQuery.ajax( jQuery.extend( {
9963 }, jQuery.isPlainObject( url ) && url ) );
9967 jQuery.ajaxPrefilter( function( s ) {
9969 for ( i in s.headers ) {
9970 if ( i.toLowerCase() === "content-type" ) {
9971 s.contentType = s.headers[ i ] || "";
9977 jQuery._evalUrl = function( url, options, doc ) {
9978 return jQuery.ajax( {
9981 // Make this explicit, since user can override this through ajaxSetup (trac-11264)
9988 // Only evaluate the response if it is successful (gh-4126)
9989 // dataFilter is not invoked for failure responses, so using it instead
9990 // of the default converter is kludgy but it works.
9992 "text script": function() {}
9994 dataFilter: function( response ) {
9995 jQuery.globalEval( response, options, doc );
10001 jQuery.fn.extend( {
10002 wrapAll: function( html ) {
10006 if ( isFunction( html ) ) {
10007 html = html.call( this[ 0 ] );
10010 // The elements to wrap the target around
10011 wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
10013 if ( this[ 0 ].parentNode ) {
10014 wrap.insertBefore( this[ 0 ] );
10017 wrap.map( function() {
10020 while ( elem.firstElementChild ) {
10021 elem = elem.firstElementChild;
10025 } ).append( this );
10031 wrapInner: function( html ) {
10032 if ( isFunction( html ) ) {
10033 return this.each( function( i ) {
10034 jQuery( this ).wrapInner( html.call( this, i ) );
10038 return this.each( function() {
10039 var self = jQuery( this ),
10040 contents = self.contents();
10042 if ( contents.length ) {
10043 contents.wrapAll( html );
10046 self.append( html );
10051 wrap: function( html ) {
10052 var htmlIsFunction = isFunction( html );
10054 return this.each( function( i ) {
10055 jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
10059 unwrap: function( selector ) {
10060 this.parent( selector ).not( "body" ).each( function() {
10061 jQuery( this ).replaceWith( this.childNodes );
10068 jQuery.expr.pseudos.hidden = function( elem ) {
10069 return !jQuery.expr.pseudos.visible( elem );
10071 jQuery.expr.pseudos.visible = function( elem ) {
10072 return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
10078 jQuery.ajaxSettings.xhr = function() {
10080 return new window.XMLHttpRequest();
10084 var xhrSuccessStatus = {
10086 // File protocol always yields status code 0, assume 200
10089 // Support: IE <=9 only
10090 // trac-1450: sometimes IE returns 1223 when it should be 204
10093 xhrSupported = jQuery.ajaxSettings.xhr();
10095 support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
10096 support.ajax = xhrSupported = !!xhrSupported;
10098 jQuery.ajaxTransport( function( options ) {
10099 var callback, errorCallback;
10101 // Cross domain only allowed if supported through XMLHttpRequest
10102 if ( support.cors || xhrSupported && !options.crossDomain ) {
10104 send: function( headers, complete ) {
10106 xhr = options.xhr();
10116 // Apply custom fields if provided
10117 if ( options.xhrFields ) {
10118 for ( i in options.xhrFields ) {
10119 xhr[ i ] = options.xhrFields[ i ];
10123 // Override mime type if needed
10124 if ( options.mimeType && xhr.overrideMimeType ) {
10125 xhr.overrideMimeType( options.mimeType );
10128 // X-Requested-With header
10129 // For cross-domain requests, seeing as conditions for a preflight are
10130 // akin to a jigsaw puzzle, we simply never set it to be sure.
10131 // (it can always be set on a per-request basis or even using ajaxSetup)
10132 // For same-domain requests, won't change header if already provided.
10133 if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
10134 headers[ "X-Requested-With" ] = "XMLHttpRequest";
10138 for ( i in headers ) {
10139 xhr.setRequestHeader( i, headers[ i ] );
10143 callback = function( type ) {
10144 return function() {
10146 callback = errorCallback = xhr.onload =
10147 xhr.onerror = xhr.onabort = xhr.ontimeout =
10148 xhr.onreadystatechange = null;
10150 if ( type === "abort" ) {
10152 } else if ( type === "error" ) {
10154 // Support: IE <=9 only
10155 // On a manual native abort, IE9 throws
10156 // errors on any property access that is not readyState
10157 if ( typeof xhr.status !== "number" ) {
10158 complete( 0, "error" );
10162 // File: protocol always yields status 0; see trac-8605, trac-14207
10169 xhrSuccessStatus[ xhr.status ] || xhr.status,
10172 // Support: IE <=9 only
10173 // IE9 has no XHR2 but throws on binary (trac-11426)
10174 // For XHR2 non-text, let the caller handle it (gh-2498)
10175 ( xhr.responseType || "text" ) !== "text" ||
10176 typeof xhr.responseText !== "string" ?
10177 { binary: xhr.response } :
10178 { text: xhr.responseText },
10179 xhr.getAllResponseHeaders()
10186 // Listen to events
10187 xhr.onload = callback();
10188 errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
10190 // Support: IE 9 only
10191 // Use onreadystatechange to replace onabort
10192 // to handle uncaught aborts
10193 if ( xhr.onabort !== undefined ) {
10194 xhr.onabort = errorCallback;
10196 xhr.onreadystatechange = function() {
10198 // Check readyState before timeout as it changes
10199 if ( xhr.readyState === 4 ) {
10201 // Allow onerror to be called first,
10202 // but that will not handle a native abort
10203 // Also, save errorCallback to a variable
10204 // as xhr.onerror cannot be accessed
10205 window.setTimeout( function() {
10214 // Create the abort callback
10215 callback = callback( "abort" );
10219 // Do send the request (this may raise an exception)
10220 xhr.send( options.hasContent && options.data || null );
10223 // trac-14683: Only rethrow if this hasn't been notified as an error yet
10230 abort: function() {
10242 // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
10243 jQuery.ajaxPrefilter( function( s ) {
10244 if ( s.crossDomain ) {
10245 s.contents.script = false;
10249 // Install script dataType
10250 jQuery.ajaxSetup( {
10252 script: "text/javascript, application/javascript, " +
10253 "application/ecmascript, application/x-ecmascript"
10256 script: /\b(?:java|ecma)script\b/
10259 "text script": function( text ) {
10260 jQuery.globalEval( text );
10266 // Handle cache's special case and crossDomain
10267 jQuery.ajaxPrefilter( "script", function( s ) {
10268 if ( s.cache === undefined ) {
10271 if ( s.crossDomain ) {
10276 // Bind script tag hack transport
10277 jQuery.ajaxTransport( "script", function( s ) {
10279 // This transport only deals with cross domain or forced-by-attrs requests
10280 if ( s.crossDomain || s.scriptAttrs ) {
10281 var script, callback;
10283 send: function( _, complete ) {
10284 script = jQuery( "<script>" )
10285 .attr( s.scriptAttrs || {} )
10286 .prop( { charset: s.scriptCharset, src: s.url } )
10287 .on( "load error", callback = function( evt ) {
10291 complete( evt.type === "error" ? 404 : 200, evt.type );
10295 // Use native DOM manipulation to avoid our domManip AJAX trickery
10296 document.head.appendChild( script[ 0 ] );
10298 abort: function() {
10310 var oldCallbacks = [],
10311 rjsonp = /(=)\?(?=&|$)|\?\?/;
10313 // Default jsonp settings
10314 jQuery.ajaxSetup( {
10316 jsonpCallback: function() {
10317 var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce.guid++ ) );
10318 this[ callback ] = true;
10323 // Detect, normalize options and install callbacks for jsonp requests
10324 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
10326 var callbackName, overwritten, responseContainer,
10327 jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
10329 typeof s.data === "string" &&
10330 ( s.contentType || "" )
10331 .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
10332 rjsonp.test( s.data ) && "data"
10335 // Handle iff the expected data type is "jsonp" or we have a parameter to set
10336 if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
10338 // Get callback name, remembering preexisting value associated with it
10339 callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
10340 s.jsonpCallback() :
10343 // Insert callback into url or form data
10345 s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
10346 } else if ( s.jsonp !== false ) {
10347 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
10350 // Use data converter to retrieve json after script execution
10351 s.converters[ "script json" ] = function() {
10352 if ( !responseContainer ) {
10353 jQuery.error( callbackName + " was not called" );
10355 return responseContainer[ 0 ];
10358 // Force json dataType
10359 s.dataTypes[ 0 ] = "json";
10361 // Install callback
10362 overwritten = window[ callbackName ];
10363 window[ callbackName ] = function() {
10364 responseContainer = arguments;
10367 // Clean-up function (fires after converters)
10368 jqXHR.always( function() {
10370 // If previous value didn't exist - remove it
10371 if ( overwritten === undefined ) {
10372 jQuery( window ).removeProp( callbackName );
10374 // Otherwise restore preexisting value
10376 window[ callbackName ] = overwritten;
10379 // Save back as free
10380 if ( s[ callbackName ] ) {
10382 // Make sure that re-using the options doesn't screw things around
10383 s.jsonpCallback = originalSettings.jsonpCallback;
10385 // Save the callback name for future use
10386 oldCallbacks.push( callbackName );
10389 // Call if it was a function and we have a response
10390 if ( responseContainer && isFunction( overwritten ) ) {
10391 overwritten( responseContainer[ 0 ] );
10394 responseContainer = overwritten = undefined;
10397 // Delegate to script
10405 // Support: Safari 8 only
10406 // In Safari 8 documents created via document.implementation.createHTMLDocument
10407 // collapse sibling forms: the second one becomes a child of the first one.
10408 // Because of that, this security measure has to be disabled in Safari 8.
10409 // https://bugs.webkit.org/show_bug.cgi?id=137337
10410 support.createHTMLDocument = ( function() {
10411 var body = document.implementation.createHTMLDocument( "" ).body;
10412 body.innerHTML = "<form></form><form></form>";
10413 return body.childNodes.length === 2;
10417 // Argument "data" should be string of html
10418 // context (optional): If specified, the fragment will be created in this context,
10419 // defaults to document
10420 // keepScripts (optional): If true, will include scripts passed in the html string
10421 jQuery.parseHTML = function( data, context, keepScripts ) {
10422 if ( typeof data !== "string" ) {
10425 if ( typeof context === "boolean" ) {
10426 keepScripts = context;
10430 var base, parsed, scripts;
10434 // Stop scripts or inline event handlers from being executed immediately
10435 // by using document.implementation
10436 if ( support.createHTMLDocument ) {
10437 context = document.implementation.createHTMLDocument( "" );
10439 // Set the base href for the created document
10440 // so any parsed elements with URLs
10441 // are based on the document's URL (gh-2965)
10442 base = context.createElement( "base" );
10443 base.href = document.location.href;
10444 context.head.appendChild( base );
10446 context = document;
10450 parsed = rsingleTag.exec( data );
10451 scripts = !keepScripts && [];
10455 return [ context.createElement( parsed[ 1 ] ) ];
10458 parsed = buildFragment( [ data ], context, scripts );
10460 if ( scripts && scripts.length ) {
10461 jQuery( scripts ).remove();
10464 return jQuery.merge( [], parsed.childNodes );
10469 * Load a url into a page
10471 jQuery.fn.load = function( url, params, callback ) {
10472 var selector, type, response,
10474 off = url.indexOf( " " );
10477 selector = stripAndCollapse( url.slice( off ) );
10478 url = url.slice( 0, off );
10481 // If it's a function
10482 if ( isFunction( params ) ) {
10484 // We assume that it's the callback
10486 params = undefined;
10488 // Otherwise, build a param string
10489 } else if ( params && typeof params === "object" ) {
10493 // If we have elements to modify, make the request
10494 if ( self.length > 0 ) {
10498 // If "type" variable is undefined, then "GET" method will be used.
10499 // Make value of this field explicit since
10500 // user can override it through ajaxSetup method
10501 type: type || "GET",
10504 } ).done( function( responseText ) {
10506 // Save response for use in complete callback
10507 response = arguments;
10509 self.html( selector ?
10511 // If a selector was specified, locate the right elements in a dummy div
10512 // Exclude scripts to avoid IE 'Permission Denied' errors
10513 jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
10515 // Otherwise use the full result
10518 // If the request succeeds, this function gets "data", "status", "jqXHR"
10519 // but they are ignored because response was set above.
10520 // If it fails, this function gets "jqXHR", "status", "error"
10521 } ).always( callback && function( jqXHR, status ) {
10522 self.each( function() {
10523 callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
10534 jQuery.expr.pseudos.animated = function( elem ) {
10535 return jQuery.grep( jQuery.timers, function( fn ) {
10536 return elem === fn.elem;
10544 setOffset: function( elem, options, i ) {
10545 var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
10546 position = jQuery.css( elem, "position" ),
10547 curElem = jQuery( elem ),
10550 // Set position first, in-case top/left are set even on static elem
10551 if ( position === "static" ) {
10552 elem.style.position = "relative";
10555 curOffset = curElem.offset();
10556 curCSSTop = jQuery.css( elem, "top" );
10557 curCSSLeft = jQuery.css( elem, "left" );
10558 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
10559 ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
10561 // Need to be able to calculate position if either
10562 // top or left is auto and position is either absolute or fixed
10563 if ( calculatePosition ) {
10564 curPosition = curElem.position();
10565 curTop = curPosition.top;
10566 curLeft = curPosition.left;
10569 curTop = parseFloat( curCSSTop ) || 0;
10570 curLeft = parseFloat( curCSSLeft ) || 0;
10573 if ( isFunction( options ) ) {
10575 // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
10576 options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
10579 if ( options.top != null ) {
10580 props.top = ( options.top - curOffset.top ) + curTop;
10582 if ( options.left != null ) {
10583 props.left = ( options.left - curOffset.left ) + curLeft;
10586 if ( "using" in options ) {
10587 options.using.call( elem, props );
10590 curElem.css( props );
10595 jQuery.fn.extend( {
10597 // offset() relates an element's border box to the document origin
10598 offset: function( options ) {
10600 // Preserve chaining for setter
10601 if ( arguments.length ) {
10602 return options === undefined ?
10604 this.each( function( i ) {
10605 jQuery.offset.setOffset( this, options, i );
10616 // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
10617 // Support: IE <=11 only
10618 // Running getBoundingClientRect on a
10619 // disconnected node in IE throws an error
10620 if ( !elem.getClientRects().length ) {
10621 return { top: 0, left: 0 };
10624 // Get document-relative position by adding viewport scroll to viewport-relative gBCR
10625 rect = elem.getBoundingClientRect();
10626 win = elem.ownerDocument.defaultView;
10628 top: rect.top + win.pageYOffset,
10629 left: rect.left + win.pageXOffset
10633 // position() relates an element's margin box to its offset parent's padding box
10634 // This corresponds to the behavior of CSS absolute positioning
10635 position: function() {
10636 if ( !this[ 0 ] ) {
10640 var offsetParent, offset, doc,
10642 parentOffset = { top: 0, left: 0 };
10644 // position:fixed elements are offset from the viewport, which itself always has zero offset
10645 if ( jQuery.css( elem, "position" ) === "fixed" ) {
10647 // Assume position:fixed implies availability of getBoundingClientRect
10648 offset = elem.getBoundingClientRect();
10651 offset = this.offset();
10653 // Account for the *real* offset parent, which can be the document or its root element
10654 // when a statically positioned element is identified
10655 doc = elem.ownerDocument;
10656 offsetParent = elem.offsetParent || doc.documentElement;
10657 while ( offsetParent &&
10658 ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
10659 jQuery.css( offsetParent, "position" ) === "static" ) {
10661 offsetParent = offsetParent.parentNode;
10663 if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
10665 // Incorporate borders into its offset, since they are outside its content origin
10666 parentOffset = jQuery( offsetParent ).offset();
10667 parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
10668 parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
10672 // Subtract parent offsets and element margins
10674 top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
10675 left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
10679 // This method will return documentElement in the following cases:
10680 // 1) For the element inside the iframe without offsetParent, this method will return
10681 // documentElement of the parent window
10682 // 2) For the hidden or detached element
10683 // 3) For body or html element, i.e. in case of the html node - it will return itself
10685 // but those exceptions were never presented as a real life use-cases
10686 // and might be considered as more preferable results.
10688 // This logic, however, is not guaranteed and can change at any point in the future
10689 offsetParent: function() {
10690 return this.map( function() {
10691 var offsetParent = this.offsetParent;
10693 while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
10694 offsetParent = offsetParent.offsetParent;
10697 return offsetParent || documentElement;
10702 // Create scrollLeft and scrollTop methods
10703 jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
10704 var top = "pageYOffset" === prop;
10706 jQuery.fn[ method ] = function( val ) {
10707 return access( this, function( elem, method, val ) {
10709 // Coalesce documents and windows
10711 if ( isWindow( elem ) ) {
10713 } else if ( elem.nodeType === 9 ) {
10714 win = elem.defaultView;
10717 if ( val === undefined ) {
10718 return win ? win[ prop ] : elem[ method ];
10723 !top ? val : win.pageXOffset,
10724 top ? val : win.pageYOffset
10728 elem[ method ] = val;
10730 }, method, val, arguments.length );
10734 // Support: Safari <=7 - 9.1, Chrome <=37 - 49
10735 // Add the top/left cssHooks using jQuery.fn.position
10736 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
10737 // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
10738 // getComputedStyle returns percent when specified for top/left/bottom/right;
10739 // rather than make the css module depend on the offset module, just check for it here
10740 jQuery.each( [ "top", "left" ], function( _i, prop ) {
10741 jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
10742 function( elem, computed ) {
10744 computed = curCSS( elem, prop );
10746 // If curCSS returns percentage, fallback to offset
10747 return rnumnonpx.test( computed ) ?
10748 jQuery( elem ).position()[ prop ] + "px" :
10756 // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
10757 jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
10759 padding: "inner" + name,
10762 }, function( defaultExtra, funcName ) {
10764 // Margin is only for outerHeight, outerWidth
10765 jQuery.fn[ funcName ] = function( margin, value ) {
10766 var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
10767 extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
10769 return access( this, function( elem, type, value ) {
10772 if ( isWindow( elem ) ) {
10774 // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
10775 return funcName.indexOf( "outer" ) === 0 ?
10776 elem[ "inner" + name ] :
10777 elem.document.documentElement[ "client" + name ];
10780 // Get document width or height
10781 if ( elem.nodeType === 9 ) {
10782 doc = elem.documentElement;
10784 // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
10785 // whichever is greatest
10787 elem.body[ "scroll" + name ], doc[ "scroll" + name ],
10788 elem.body[ "offset" + name ], doc[ "offset" + name ],
10789 doc[ "client" + name ]
10793 return value === undefined ?
10795 // Get width or height on the element, requesting but not forcing parseFloat
10796 jQuery.css( elem, type, extra ) :
10798 // Set width or height on the element
10799 jQuery.style( elem, type, value, extra );
10800 }, type, chainable ? margin : undefined, chainable );
10813 ], function( _i, type ) {
10814 jQuery.fn[ type ] = function( fn ) {
10815 return this.on( type, fn );
10822 jQuery.fn.extend( {
10824 bind: function( types, data, fn ) {
10825 return this.on( types, null, data, fn );
10827 unbind: function( types, fn ) {
10828 return this.off( types, null, fn );
10831 delegate: function( selector, types, data, fn ) {
10832 return this.on( types, selector, data, fn );
10834 undelegate: function( selector, types, fn ) {
10836 // ( namespace ) or ( selector, types [, fn] )
10837 return arguments.length === 1 ?
10838 this.off( selector, "**" ) :
10839 this.off( types, selector || "**", fn );
10842 hover: function( fnOver, fnOut ) {
10843 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
10848 ( "blur focus focusin focusout resize scroll click dblclick " +
10849 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
10850 "change select submit keydown keypress keyup contextmenu" ).split( " " ),
10851 function( _i, name ) {
10853 // Handle event binding
10854 jQuery.fn[ name ] = function( data, fn ) {
10855 return arguments.length > 0 ?
10856 this.on( name, null, data, fn ) :
10857 this.trigger( name );
10865 // Support: Android <=4.0 only
10866 // Make sure we trim BOM and NBSP
10867 // Require that the "whitespace run" starts from a non-whitespace
10868 // to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position.
10869 var rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;
10871 // Bind a function to a context, optionally partially applying any
10873 // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
10874 // However, it is not slated for removal any time soon
10875 jQuery.proxy = function( fn, context ) {
10876 var tmp, args, proxy;
10878 if ( typeof context === "string" ) {
10879 tmp = fn[ context ];
10884 // Quick check to determine if target is callable, in the spec
10885 // this throws a TypeError, but we will just return undefined.
10886 if ( !isFunction( fn ) ) {
10891 args = slice.call( arguments, 2 );
10892 proxy = function() {
10893 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
10896 // Set the guid of unique handler to the same of original handler, so it can be removed
10897 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
10902 jQuery.holdReady = function( hold ) {
10904 jQuery.readyWait++;
10906 jQuery.ready( true );
10909 jQuery.isArray = Array.isArray;
10910 jQuery.parseJSON = JSON.parse;
10911 jQuery.nodeName = nodeName;
10912 jQuery.isFunction = isFunction;
10913 jQuery.isWindow = isWindow;
10914 jQuery.camelCase = camelCase;
10915 jQuery.type = toType;
10917 jQuery.now = Date.now;
10919 jQuery.isNumeric = function( obj ) {
10921 // As of jQuery 3.0, isNumeric is limited to
10922 // strings and numbers (primitives or objects)
10923 // that can be coerced to finite numbers (gh-2662)
10924 var type = jQuery.type( obj );
10925 return ( type === "number" || type === "string" ) &&
10927 // parseFloat NaNs numeric-cast false positives ("")
10928 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
10929 // subtraction forces infinities to NaN
10930 !isNaN( obj - parseFloat( obj ) );
10933 jQuery.trim = function( text ) {
10934 return text == null ?
10936 ( text + "" ).replace( rtrim, "$1" );
10941 // Register as a named AMD module, since jQuery can be concatenated with other
10942 // files that may use define, but not via a proper concatenation script that
10943 // understands anonymous AMD modules. A named AMD is safest and most robust
10944 // way to register. Lowercase jquery is used because AMD module names are
10945 // derived from file names, and jQuery is normally delivered in a lowercase
10946 // file name. Do this after creating the global so that if an AMD module wants
10947 // to call noConflict to hide this version of jQuery, it will work.
10949 // Note that for maximum portability, libraries that are not jQuery should
10950 // declare themselves as anonymous modules, and avoid setting a global if an
10951 // AMD loader is present. jQuery is a special case. For more information, see
10952 // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
10954 if ( typeof define === "function" && define.amd ) {
10955 define( "jquery", [], function() {
10965 // Map over jQuery in case of overwrite
10966 _jQuery = window.jQuery,
10968 // Map over the $ in case of overwrite
10971 jQuery.noConflict = function( deep ) {
10972 if ( window.$ === jQuery ) {
10976 if ( deep && window.jQuery === jQuery ) {
10977 window.jQuery = _jQuery;
10983 // Expose jQuery and $ identifiers, even in AMD
10984 // (trac-7102#comment:10, https://github.com/jquery/jquery/pull/557)
10985 // and CommonJS for browser emulators (trac-13566)
10986 if ( typeof noGlobal === "undefined" ) {
10987 window.jQuery = window.$ = jQuery;