1 | Â | /*! |
2 | Â | * jQuery JavaScript Library v3.5.1 |
3 | Â | * https://jquery.com/ |
4 | Â | * |
5 | Â | * Includes Sizzle.js |
6 | Â | * https://sizzlejs.com/ |
7 | Â | * |
8 | Â | * Copyright JS Foundation and other contributors |
9 | Â | * Released under the MIT license |
10 | Â | * https://jquery.org/license |
11 | Â | * |
12 | Â | * Date: 2020-05-04T22:49Z |
13 | Â | */ |
14 | Â | ( function( global, factory ) { |
15 | Â | |
16 | Â | "use strict"; |
17 | Â | |
18 | Â | if ( typeof module === "object" && typeof module.exports === "object" ) { |
19 | Â | |
20 | Â | // For CommonJS and CommonJS-like environments where a proper `window` |
21 | Â | // is present, execute the factory and get jQuery. |
22 | Â | // For environments that do not have a `window` with a `document` |
23 | Â | // (such as Node.js), expose a factory as module.exports. |
24 | Â | // This accentuates the need for the creation of a real `window`. |
25 | Â | // e.g. var jQuery = require("jquery")(window); |
26 | Â | // See ticket #14549 for more info. |
27 | Â | module.exports = global.document ? |
28 | Â | factory( global, true ) : |
29 | Â | function( w ) { |
30 | Â | if ( !w.document ) { |
31 | Â | throw new Error( "jQuery requires a window with a document" ); |
32 | Â | } |
33 | Â | return factory( w ); |
34 | Â | }; |
35 | Â | } else { |
36 | Â | factory( global ); |
37 | Â | } |
38 | Â | |
39 | Â | // Pass this if window is not defined yet |
40 | Â | } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { |
41 | Â | |
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. |
46 | Â | "use strict"; |
47 | Â | |
48 | Â | var arr = []; |
49 | Â | |
50 | Â | var getProto = Object.getPrototypeOf; |
51 | Â | |
52 | Â | var slice = arr.slice; |
53 | Â | |
54 | Â | var flat = arr.flat ? function( array ) { |
55 | Â | return arr.flat.call( array ); |
56 | Â | } : function( array ) { |
57 | Â | return arr.concat.apply( [], array ); |
58 | Â | }; |
59 | Â | |
60 | Â | |
61 | Â | var push = arr.push; |
62 | Â | |
63 | Â | var indexOf = arr.indexOf; |
64 | Â | |
65 | Â | var class2type = {}; |
66 | Â | |
67 | Â | var toString = class2type.toString; |
68 | Â | |
69 | Â | var hasOwn = class2type.hasOwnProperty; |
70 | Â | |
71 | Â | var fnToString = hasOwn.toString; |
72 | Â | |
73 | Â | var ObjectFunctionString = fnToString.call( Object ); |
74 | Â | |
75 | Â | var support = {}; |
76 | Â | |
77 | Â | var isFunction = function isFunction( obj ) { |
78 | Â | |
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 | Â | return typeof obj === "function" && typeof obj.nodeType !== "number"; |
84 | Â | }; |
85 | Â | |
86 | Â | |
87 | Â | var isWindow = function isWindow( obj ) { |
88 | Â | return obj != null && obj === obj.window; |
89 | Â | }; |
90 | Â | |
91 | Â | |
92 | Â | var document = window.document; |
93 | Â | |
94 | Â | |
95 | Â | |
96 | Â | var preservedScriptAttributes = { |
97 | Â | type: true, |
98 | Â | src: true, |
99 | Â | nonce: true, |
100 | Â | noModule: true |
101 | Â | }; |
102 | Â | |
103 | Â | function DOMEval( code, node, doc ) { |
104 | Â | doc = doc || document; |
105 | Â | |
106 | Â | var i, val, |
107 | Â | script = doc.createElement( "script" ); |
108 | Â | |
109 | Â | script.text = code; |
110 | Â | if ( node ) { |
111 | Â | for ( i in preservedScriptAttributes ) { |
112 | Â | |
113 | Â | // Support: Firefox 64+, Edge 18+ |
114 | Â | // Some browsers don't support the "nonce" property on scripts. |
115 | Â | // On the other hand, just using `getAttribute` is not enough as |
116 | Â | // the `nonce` attribute is reset to an empty string whenever it |
117 | Â | // becomes browsing-context connected. |
118 | Â | // See https://github.com/whatwg/html/issues/2369 |
119 | Â | // See https://html.spec.whatwg.org/#nonce-attributes |
120 | Â | // The `node.getAttribute` check was added for the sake of |
121 | Â | // `jQuery.globalEval` so that it can fake a nonce-containing node |
122 | Â | // via an object. |
123 | Â | val = node[ i ] || node.getAttribute && node.getAttribute( i ); |
124 | Â | if ( val ) { |
125 | Â | script.setAttribute( i, val ); |
126 | Â | } |
127 | Â | } |
128 | Â | } |
129 | Â | doc.head.appendChild( script ).parentNode.removeChild( script ); |
130 | Â | } |
131 | Â | |
132 | Â | |
133 | Â | function toType( obj ) { |
134 | Â | if ( obj == null ) { |
135 | Â | return obj + ""; |
136 | Â | } |
137 | Â | |
138 | Â | // Support: Android <=2.3 only (functionish RegExp) |
139 | Â | return typeof obj === "object" || typeof obj === "function" ? |
140 | Â | class2type[ toString.call( obj ) ] || "object" : |
141 | Â | typeof obj; |
142 | Â | } |
143 | Â | /* global Symbol */ |
144 | Â | // Defining this global in .eslintrc.json would create a danger of using the global |
145 | Â | // unguarded in another place, it seems safer to define global only for this module |
146 | Â | |
147 | Â | |
148 | Â | |
149 | Â | var |
150 | Â | version = "3.5.1", |
151 | Â | |
152 | Â | // Define a local copy of jQuery |
153 | Â | jQuery = function( selector, context ) { |
154 | Â | |
155 | Â | // The jQuery object is actually just the init constructor 'enhanced' |
156 | Â | // Need init if jQuery is called (just allow error to be thrown if not included) |
157 | Â | return new jQuery.fn.init( selector, context ); |
158 | Â | }; |
159 | Â | |
160 | Â | jQuery.fn = jQuery.prototype = { |
161 | Â | |
162 | Â | // The current version of jQuery being used |
163 | Â | jquery: version, |
164 | Â | |
165 | Â | constructor: jQuery, |
166 | Â | |
167 | Â | // The default length of a jQuery object is 0 |
168 | Â | length: 0, |
169 | Â | |
170 | Â | toArray: function() { |
171 | Â | return slice.call( this ); |
172 | Â | }, |
173 | Â | |
174 | Â | // Get the Nth element in the matched element set OR |
175 | Â | // Get the whole matched element set as a clean array |
176 | Â | get: function( num ) { |
177 | Â | |
178 | Â | // Return all the elements in a clean array |
179 | Â | if ( num == null ) { |
180 | Â | return slice.call( this ); |
181 | Â | } |
182 | Â | |
183 | Â | // Return just the one element from the set |
184 | Â | return num < 0 ? this[ num + this.length ] : this[ num ]; |
185 | Â | }, |
186 | Â | |
187 | Â | // Take an array of elements and push it onto the stack |
188 | Â | // (returning the new matched element set) |
189 | Â | pushStack: function( elems ) { |
190 | Â | |
191 | Â | // Build a new jQuery matched element set |
192 | Â | var ret = jQuery.merge( this.constructor(), elems ); |
193 | Â | |
194 | Â | // Add the old object onto the stack (as a reference) |
195 | Â | ret.prevObject = this; |
196 | Â | |
197 | Â | // Return the newly-formed element set |
198 | Â | return ret; |
199 | Â | }, |
200 | Â | |
201 | Â | // Execute a callback for every element in the matched set. |
202 | Â | each: function( callback ) { |
203 | Â | return jQuery.each( this, callback ); |
204 | Â | }, |
205 | Â | |
206 | Â | map: function( callback ) { |
207 | Â | return this.pushStack( jQuery.map( this, function( elem, i ) { |
208 | Â | return callback.call( elem, i, elem ); |
209 | Â | } ) ); |
210 | Â | }, |
211 | Â | |
212 | Â | slice: function() { |
213 | Â | return this.pushStack( slice.apply( this, arguments ) ); |
214 | Â | }, |
215 | Â | |
216 | Â | first: function() { |
217 | Â | return this.eq( 0 ); |
218 | Â | }, |
219 | Â | |
220 | Â | last: function() { |
221 | Â | return this.eq( -1 ); |
222 | Â | }, |
223 | Â | |
224 | Â | even: function() { |
225 | Â | return this.pushStack( jQuery.grep( this, function( _elem, i ) { |
226 | Â | return ( i + 1 ) % 2; |
227 | Â | } ) ); |
228 | Â | }, |
229 | Â | |
230 | Â | odd: function() { |
231 | Â | return this.pushStack( jQuery.grep( this, function( _elem, i ) { |
232 | Â | return i % 2; |
233 | Â | } ) ); |
234 | Â | }, |
235 | Â | |
236 | Â | eq: function( i ) { |
237 | Â | var len = this.length, |
238 | Â | j = +i + ( i < 0 ? len : 0 ); |
239 | Â | return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); |
240 | Â | }, |
241 | Â | |
242 | Â | end: function() { |
243 | Â | return this.prevObject || this.constructor(); |
244 | Â | }, |
245 | Â | |
246 | Â | // For internal use only. |
247 | Â | // Behaves like an Array's method, not like a jQuery method. |
248 | Â | push: push, |
249 | Â | sort: arr.sort, |
250 | Â | splice: arr.splice |
251 | Â | }; |
252 | Â | |
253 | Â | jQuery.extend = jQuery.fn.extend = function() { |
254 | Â | var options, name, src, copy, copyIsArray, clone, |
255 | Â | target = arguments[ 0 ] || {}, |
256 | Â | i = 1, |
257 | Â | length = arguments.length, |
258 | Â | deep = false; |
259 | Â | |
260 | Â | // Handle a deep copy situation |
261 | Â | if ( typeof target === "boolean" ) { |
262 | Â | deep = target; |
263 | Â | |
264 | Â | // Skip the boolean and the target |
265 | Â | target = arguments[ i ] || {}; |
266 | Â | i++; |
267 | Â | } |
268 | Â | |
269 | Â | // Handle case when target is a string or something (possible in deep copy) |
270 | Â | if ( typeof target !== "object" && !isFunction( target ) ) { |
271 | Â | target = {}; |
272 | Â | } |
273 | Â | |
274 | Â | // Extend jQuery itself if only one argument is passed |
275 | Â | if ( i === length ) { |
276 | Â | target = this; |
277 | Â | i--; |
278 | Â | } |
279 | Â | |
280 | Â | for ( ; i < length; i++ ) { |
281 | Â | |
282 | Â | // Only deal with non-null/undefined values |
283 | Â | if ( ( options = arguments[ i ] ) != null ) { |
284 | Â | |
285 | Â | // Extend the base object |
286 | Â | for ( name in options ) { |
287 | Â | copy = options[ name ]; |
288 | Â | |
289 | Â | // Prevent Object.prototype pollution |
290 | Â | // Prevent never-ending loop |
291 | Â | if ( name === "__proto__" || target === copy ) { |
292 | Â | continue; |
293 | Â | } |
294 | Â | |
295 | Â | // Recurse if we're merging plain objects or arrays |
296 | Â | if ( deep && copy && ( jQuery.isPlainObject( copy ) || |
297 | Â | ( copyIsArray = Array.isArray( copy ) ) ) ) { |
298 | Â | src = target[ name ]; |
299 | Â | |
300 | Â | // Ensure proper type for the source value |
301 | Â | if ( copyIsArray && !Array.isArray( src ) ) { |
302 | Â | clone = []; |
303 | Â | } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) { |
304 | Â | clone = {}; |
305 | Â | } else { |
306 | Â | clone = src; |
307 | Â | } |
308 | Â | copyIsArray = false; |
309 | Â | |
310 | Â | // Never move original objects, clone them |
311 | Â | target[ name ] = jQuery.extend( deep, clone, copy ); |
312 | Â | |
313 | Â | // Don't bring in undefined values |
314 | Â | } else if ( copy !== undefined ) { |
315 | Â | target[ name ] = copy; |
316 | Â | } |
317 | Â | } |
318 | Â | } |
319 | Â | } |
320 | Â | |
321 | Â | // Return the modified object |
322 | Â | return target; |
323 | Â | }; |
324 | Â | |
325 | Â | jQuery.extend( { |
326 | Â | |
327 | Â | // Unique for each copy of jQuery on the page |
328 | Â | expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), |
329 | Â | |
330 | Â | // Assume jQuery is ready without the ready module |
331 | Â | isReady: true, |
332 | Â | |
333 | Â | error: function( msg ) { |
334 | Â | throw new Error( msg ); |
335 | Â | }, |
336 | Â | |
337 | Â | noop: function() {}, |
338 | Â | |
339 | Â | isPlainObject: function( obj ) { |
340 | Â | var proto, Ctor; |
341 | Â | |
342 | Â | // Detect obvious negatives |
343 | Â | // Use toString instead of jQuery.type to catch host objects |
344 | Â | if ( !obj || toString.call( obj ) !== "[object Object]" ) { |
345 | Â | return false; |
346 | Â | } |
347 | Â | |
348 | Â | proto = getProto( obj ); |
349 | Â | |
350 | Â | // Objects with no prototype (e.g., `Object.create( null )`) are plain |
351 | Â | if ( !proto ) { |
352 | Â | return true; |
353 | Â | } |
354 | Â | |
355 | Â | // Objects with prototype are plain iff they were constructed by a global Object function |
356 | Â | Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; |
357 | Â | return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; |
358 | Â | }, |
359 | Â | |
360 | Â | isEmptyObject: function( obj ) { |
361 | Â | var name; |
362 | Â | |
363 | Â | for ( name in obj ) { |
364 | Â | return false; |
365 | Â | } |
366 | Â | return true; |
367 | Â | }, |
368 | Â | |
369 | Â | // Evaluates a script in a provided context; falls back to the global one |
370 | Â | // if not specified. |
371 | Â | globalEval: function( code, options, doc ) { |
372 | Â | DOMEval( code, { nonce: options && options.nonce }, doc ); |
373 | Â | }, |
374 | Â | |
375 | Â | each: function( obj, callback ) { |
376 | Â | var length, i = 0; |
377 | Â | |
378 | Â | if ( isArrayLike( obj ) ) { |
379 | Â | length = obj.length; |
380 | Â | for ( ; i < length; i++ ) { |
381 | Â | if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { |
382 | Â | break; |
383 | Â | } |
384 | Â | } |
385 | Â | } else { |
386 | Â | for ( i in obj ) { |
387 | Â | if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { |
388 | Â | break; |
389 | Â | } |
390 | Â | } |
391 | Â | } |
392 | Â | |
393 | Â | return obj; |
394 | Â | }, |
395 | Â | |
396 | Â | // results is for internal usage only |
397 | Â | makeArray: function( arr, results ) { |
398 | Â | var ret = results || []; |
399 | Â | |
400 | Â | if ( arr != null ) { |
401 | Â | if ( isArrayLike( Object( arr ) ) ) { |
402 | Â | jQuery.merge( ret, |
403 | Â | typeof arr === "string" ? |
404 | Â | [ arr ] : arr |
405 | Â | ); |
406 | Â | } else { |
407 | Â | push.call( ret, arr ); |
408 | Â | } |
409 | Â | } |
410 | Â | |
411 | Â | return ret; |
412 | Â | }, |
413 | Â | |
414 | Â | inArray: function( elem, arr, i ) { |
415 | Â | return arr == null ? -1 : indexOf.call( arr, elem, i ); |
416 | Â | }, |
417 | Â | |
418 | Â | // Support: Android <=4.0 only, PhantomJS 1 only |
419 | Â | // push.apply(_, arraylike) throws on ancient WebKit |
420 | Â | merge: function( first, second ) { |
421 | Â | var len = +second.length, |
422 | Â | j = 0, |
423 | Â | i = first.length; |
424 | Â | |
425 | Â | for ( ; j < len; j++ ) { |
426 | Â | first[ i++ ] = second[ j ]; |
427 | Â | } |
428 | Â | |
429 | Â | first.length = i; |
430 | Â | |
431 | Â | return first; |
432 | Â | }, |
433 | Â | |
434 | Â | grep: function( elems, callback, invert ) { |
435 | Â | var callbackInverse, |
436 | Â | matches = [], |
437 | Â | i = 0, |
438 | Â | length = elems.length, |
439 | Â | callbackExpect = !invert; |
440 | Â | |
441 | Â | // Go through the array, only saving the items |
442 | Â | // that pass the validator function |
443 | Â | for ( ; i < length; i++ ) { |
444 | Â | callbackInverse = !callback( elems[ i ], i ); |
445 | Â | if ( callbackInverse !== callbackExpect ) { |
446 | Â | matches.push( elems[ i ] ); |
447 | Â | } |
448 | Â | } |
449 | Â | |
450 | Â | return matches; |
451 | Â | }, |
452 | Â | |
453 | Â | // arg is for internal usage only |
454 | Â | map: function( elems, callback, arg ) { |
455 | Â | var length, value, |
456 | Â | i = 0, |
457 | Â | ret = []; |
458 | Â | |
459 | Â | // Go through the array, translating each of the items to their new values |
460 | Â | if ( isArrayLike( elems ) ) { |
461 | Â | length = elems.length; |
462 | Â | for ( ; i < length; i++ ) { |
463 | Â | value = callback( elems[ i ], i, arg ); |
464 | Â | |
465 | Â | if ( value != null ) { |
466 | Â | ret.push( value ); |
467 | Â | } |
468 | Â | } |
469 | Â | |
470 | Â | // Go through every key on the object, |
471 | Â | } else { |
472 | Â | for ( i in elems ) { |
473 | Â | value = callback( elems[ i ], i, arg ); |
474 | Â | |
475 | Â | if ( value != null ) { |
476 | Â | ret.push( value ); |
477 | Â | } |
478 | Â | } |
479 | Â | } |
480 | Â | |
481 | Â | // Flatten any nested arrays |
482 | Â | return flat( ret ); |
483 | Â | }, |
484 | Â | |
485 | Â | // A global GUID counter for objects |
486 | Â | guid: 1, |
487 | Â | |
488 | Â | // jQuery.support is not used in Core but other projects attach their |
489 | Â | // properties to it so it needs to exist. |
490 | Â | support: support |
491 | Â | } ); |
492 | Â | |
493 | Â | if ( typeof Symbol === "function" ) { |
494 | Â | jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; |
495 | Â | } |
496 | Â | |
497 | Â | // Populate the class2type map |
498 | Â | jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), |
499 | Â | function( _i, name ) { |
500 | Â | class2type[ "[object " + name + "]" ] = name.toLowerCase(); |
501 | Â | } ); |
502 | Â | |
503 | Â | function isArrayLike( obj ) { |
504 | Â | |
505 | Â | // Support: real iOS 8.2 only (not reproducible in simulator) |
506 | Â | // `in` check used to prevent JIT error (gh-2145) |
507 | Â | // hasOwn isn't used here due to false negatives |
508 | Â | // regarding Nodelist length in IE |
509 | Â | var length = !!obj && "length" in obj && obj.length, |
510 | Â | type = toType( obj ); |
511 | Â | |
512 | Â | if ( isFunction( obj ) || isWindow( obj ) ) { |
513 | Â | return false; |
514 | Â | } |
515 | Â | |
516 | Â | return type === "array" || length === 0 || |
517 | Â | typeof length === "number" && length > 0 && ( length - 1 ) in obj; |
518 | Â | } |
519 | Â | var Sizzle = |
520 | Â | /*! |
521 | Â | * Sizzle CSS Selector Engine v2.3.5 |
522 | Â | * https://sizzlejs.com/ |
523 | Â | * |
524 | Â | * Copyright JS Foundation and other contributors |
525 | Â | * Released under the MIT license |
526 | Â | * https://js.foundation/ |
527 | Â | * |
528 | Â | * Date: 2020-03-14 |
529 | Â | */ |
530 | Â | ( function( window ) { |
531 | Â | var i, |
532 | Â | support, |
533 | Â | Expr, |
534 | Â | getText, |
535 | Â | isXML, |
536 | Â | tokenize, |
537 | Â | compile, |
538 | Â | select, |
539 | Â | outermostContext, |
540 | Â | sortInput, |
541 | Â | hasDuplicate, |
542 | Â | |
543 | Â | // Local document vars |
544 | Â | setDocument, |
545 | Â | document, |
546 | Â | docElem, |
547 | Â | documentIsHTML, |
548 | Â | rbuggyQSA, |
549 | Â | rbuggyMatches, |
550 | Â | matches, |
551 | Â | contains, |
552 | Â | |
553 | Â | // Instance-specific data |
554 | Â | expando = "sizzle" + 1 * new Date(), |
555 | Â | preferredDoc = window.document, |
556 | Â | dirruns = 0, |
557 | Â | done = 0, |
558 | Â | classCache = createCache(), |
559 | Â | tokenCache = createCache(), |
560 | Â | compilerCache = createCache(), |
561 | Â | nonnativeSelectorCache = createCache(), |
562 | Â | sortOrder = function( a, b ) { |
563 | Â | if ( a === b ) { |
564 | Â | hasDuplicate = true; |
565 | Â | } |
566 | Â | return 0; |
567 | Â | }, |
568 | Â | |
569 | Â | // Instance methods |
570 | Â | hasOwn = ( {} ).hasOwnProperty, |
571 | Â | arr = [], |
572 | Â | pop = arr.pop, |
573 | Â | pushNative = arr.push, |
574 | Â | push = arr.push, |
575 | Â | slice = arr.slice, |
576 | Â | |
577 | Â | // Use a stripped-down indexOf as it's faster than native |
578 | Â | // https://jsperf.com/thor-indexof-vs-for/5 |
579 | Â | indexOf = function( list, elem ) { |
580 | Â | var i = 0, |
581 | Â | len = list.length; |
582 | Â | for ( ; i < len; i++ ) { |
583 | Â | if ( list[ i ] === elem ) { |
584 | Â | return i; |
585 | Â | } |
586 | Â | } |
587 | Â | return -1; |
588 | Â | }, |
589 | Â | |
590 | Â | booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" + |
591 | Â | "ismap|loop|multiple|open|readonly|required|scoped", |
592 | Â | |
593 | Â | // Regular expressions |
594 | Â | |
595 | Â | // http://www.w3.org/TR/css3-selectors/#whitespace |
596 | Â | whitespace = "[\\x20\\t\\r\\n\\f]", |
597 | Â | |
598 | Â | // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram |
599 | Â | identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + |
600 | Â | "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", |
601 | Â | |
602 | Â | // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors |
603 | Â | attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + |
604 | Â | |
605 | Â | // Operator (capture 2) |
606 | Â | "*([*^$|!~]?=)" + whitespace + |
607 | Â | |
608 | Â | // "Attribute values must be CSS identifiers [capture 5] |
609 | Â | // or strings [capture 3 or capture 4]" |
610 | Â | "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + |
611 | Â | whitespace + "*\\]", |
612 | Â | |
613 | Â | pseudos = ":(" + identifier + ")(?:\\((" + |
614 | Â | |
615 | Â | // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: |
616 | Â | // 1. quoted (capture 3; capture 4 or capture 5) |
617 | Â | "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + |
618 | Â | |
619 | Â | // 2. simple (capture 6) |
620 | Â | "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + |
621 | Â | |
622 | Â | // 3. anything else (capture 2) |
623 | Â | ".*" + |
624 | Â | ")\\)|)", |
625 | Â | |
626 | Â | // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter |
627 | Â | rwhitespace = new RegExp( whitespace + "+", "g" ), |
628 | Â | rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + |
629 | Â | whitespace + "+$", "g" ), |
630 | Â | |
631 | Â | rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), |
632 | Â | rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + |
633 | Â | "*" ), |
634 | Â | rdescend = new RegExp( whitespace + "|>" ), |
635 | Â | |
636 | Â | rpseudo = new RegExp( pseudos ), |
637 | Â | ridentifier = new RegExp( "^" + identifier + "$" ), |
638 | Â | |
639 | Â | matchExpr = { |
640 | Â | "ID": new RegExp( "^#(" + identifier + ")" ), |
641 | Â | "CLASS": new RegExp( "^\\.(" + identifier + ")" ), |
642 | Â | "TAG": new RegExp( "^(" + identifier + "|[*])" ), |
643 | Â | "ATTR": new RegExp( "^" + attributes ), |
644 | Â | "PSEUDO": new RegExp( "^" + pseudos ), |
645 | Â | "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + |
646 | Â | whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + |
647 | Â | whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), |
648 | Â | "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), |
649 | Â | |
650 | Â | // For use in libraries implementing .is() |
651 | Â | // We use this for POS matching in `select` |
652 | Â | "needsContext": new RegExp( "^" + whitespace + |
653 | Â | "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + |
654 | Â | "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) |
655 | Â | }, |
656 | Â | |
657 | Â | rhtml = /HTML$/i, |
658 | Â | rinputs = /^(?:input|select|textarea|button)$/i, |
659 | Â | rheader = /^h\d$/i, |
660 | Â | |
661 | Â | rnative = /^[^{]+\{\s*\[native \w/, |
662 | Â | |
663 | Â | // Easily-parseable/retrievable ID or TAG or CLASS selectors |
664 | Â | rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, |
665 | Â | |
666 | Â | rsibling = /[+~]/, |
667 | Â | |
668 | Â | // CSS escapes |
669 | Â | // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters |
670 | Â | runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ), |
671 | Â | funescape = function( escape, nonHex ) { |
672 | Â | var high = "0x" + escape.slice( 1 ) - 0x10000; |
673 | Â | |
674 | Â | return nonHex ? |
675 | Â | |
676 | Â | // Strip the backslash prefix from a non-hex escape sequence |
677 | Â | nonHex : |
678 | Â | |
679 | Â | // Replace a hexadecimal escape sequence with the encoded Unicode code point |
680 | Â | // Support: IE <=11+ |
681 | Â | // For values outside the Basic Multilingual Plane (BMP), manually construct a |
682 | Â | // surrogate pair |
683 | Â | high < 0 ? |
684 | Â | String.fromCharCode( high + 0x10000 ) : |
685 | Â | String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); |
686 | Â | }, |
687 | Â | |
688 | Â | // CSS string/identifier serialization |
689 | Â | // https://drafts.csswg.org/cssom/#common-serializing-idioms |
690 | Â | rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g, |
691 | Â | fcssescape = function( ch, asCodePoint ) { |
692 | Â | if ( asCodePoint ) { |
693 | Â | |
694 | Â | // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER |
695 | Â | if ( ch === "\0" ) { |
696 | Â | return "\uFFFD"; |
697 | Â | } |
698 | Â | |
699 | Â | // Control characters and (dependent upon position) numbers get escaped as code points |
700 | Â | return ch.slice( 0, -1 ) + "\\" + |
701 | Â | ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; |
702 | Â | } |
703 | Â | |
704 | Â | // Other potentially-special ASCII characters get backslash-escaped |
705 | Â | return "\\" + ch; |
706 | Â | }, |
707 | Â | |
708 | Â | // Used for iframes |
709 | Â | // See setDocument() |
710 | Â | // Removing the function wrapper causes a "Permission Denied" |
711 | Â | // error in IE |
712 | Â | unloadHandler = function() { |
713 | Â | setDocument(); |
714 | Â | }, |
715 | Â | |
716 | Â | inDisabledFieldset = addCombinator( |
717 | Â | function( elem ) { |
718 | Â | return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset"; |
719 | Â | }, |
720 | Â | { dir: "parentNode", next: "legend" } |
721 | Â | ); |
722 | Â | |
723 | Â | // Optimize for push.apply( _, NodeList ) |
724 | Â | try { |
725 | Â | push.apply( |
726 | Â | ( arr = slice.call( preferredDoc.childNodes ) ), |
727 | Â | preferredDoc.childNodes |
728 | Â | ); |
729 | Â | |
730 | Â | // Support: Android<4.0 |
731 | Â | // Detect silently failing push.apply |
732 | Â | // eslint-disable-next-line no-unused-expressions |
733 | Â | arr[ preferredDoc.childNodes.length ].nodeType; |
734 | Â | } catch ( e ) { |
735 | Â | push = { apply: arr.length ? |
736 | Â | |
737 | Â | // Leverage slice if possible |
738 | Â | function( target, els ) { |
739 | Â | pushNative.apply( target, slice.call( els ) ); |
740 | Â | } : |
741 | Â | |
742 | Â | // Support: IE<9 |
743 | Â | // Otherwise append directly |
744 | Â | function( target, els ) { |
745 | Â | var j = target.length, |
746 | Â | i = 0; |
747 | Â | |
748 | Â | // Can't trust NodeList.length |
749 | Â | while ( ( target[ j++ ] = els[ i++ ] ) ) {} |
750 | Â | target.length = j - 1; |
751 | Â | } |
752 | Â | }; |
753 | Â | } |
754 | Â | |
755 | Â | function Sizzle( selector, context, results, seed ) { |
756 | Â | var m, i, elem, nid, match, groups, newSelector, |
757 | Â | newContext = context && context.ownerDocument, |
758 | Â | |
759 | Â | // nodeType defaults to 9, since context defaults to document |
760 | Â | nodeType = context ? context.nodeType : 9; |
761 | Â | |
762 | Â | results = results || []; |
763 | Â | |
764 | Â | // Return early from calls with invalid selector or context |
765 | Â | if ( typeof selector !== "string" || !selector || |
766 | Â | nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { |
767 | Â | |
768 | Â | return results; |
769 | Â | } |
770 | Â | |
771 | Â | // Try to shortcut find operations (as opposed to filters) in HTML documents |
772 | Â | if ( !seed ) { |
773 | Â | setDocument( context ); |
774 | Â | context = context || document; |
775 | Â | |
776 | Â | if ( documentIsHTML ) { |
777 | Â | |
778 | Â | // If the selector is sufficiently simple, try using a "get*By*" DOM method |
779 | Â | // (excepting DocumentFragment context, where the methods don't exist) |
780 | Â | if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) { |
781 | Â | |
782 | Â | // ID selector |
783 | Â | if ( ( m = match[ 1 ] ) ) { |
784 | Â | |
785 | Â | // Document context |
786 | Â | if ( nodeType === 9 ) { |
787 | Â | if ( ( elem = context.getElementById( m ) ) ) { |
788 | Â | |
789 | Â | // Support: IE, Opera, Webkit |
790 | Â | // TODO: identify versions |
791 | Â | // getElementById can match elements by name instead of ID |
792 | Â | if ( elem.id === m ) { |
793 | Â | results.push( elem ); |
794 | Â | return results; |
795 | Â | } |
796 | Â | } else { |
797 | Â | return results; |
798 | Â | } |
799 | Â | |
800 | Â | // Element context |
801 | Â | } else { |
802 | Â | |
803 | Â | // Support: IE, Opera, Webkit |
804 | Â | // TODO: identify versions |
805 | Â | // getElementById can match elements by name instead of ID |
806 | Â | if ( newContext && ( elem = newContext.getElementById( m ) ) && |
807 | Â | contains( context, elem ) && |
808 | Â | elem.id === m ) { |
809 | Â | |
810 | Â | results.push( elem ); |
811 | Â | return results; |
812 | Â | } |
813 | Â | } |
814 | Â | |
815 | Â | // Type selector |
816 | Â | } else if ( match[ 2 ] ) { |
817 | Â | push.apply( results, context.getElementsByTagName( selector ) ); |
818 | Â | return results; |
819 | Â | |
820 | Â | // Class selector |
821 | Â | } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName && |
822 | Â | context.getElementsByClassName ) { |
823 | Â | |
824 | Â | push.apply( results, context.getElementsByClassName( m ) ); |
825 | Â | return results; |
826 | Â | } |
827 | Â | } |
828 | Â | |
829 | Â | // Take advantage of querySelectorAll |
830 | Â | if ( support.qsa && |
831 | Â | !nonnativeSelectorCache[ selector + " " ] && |
832 | Â | ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) && |
833 | Â | |
834 | Â | // Support: IE 8 only |
835 | Â | // Exclude object elements |
836 | Â | ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) { |
837 | Â | |
838 | Â | newSelector = selector; |
839 | Â | newContext = context; |
840 | Â | |
841 | Â | // qSA considers elements outside a scoping root when evaluating child or |
842 | Â | // descendant combinators, which is not what we want. |
843 | Â | // In such cases, we work around the behavior by prefixing every selector in the |
844 | Â | // list with an ID selector referencing the scope context. |
845 | Â | // The technique has to be used as well when a leading combinator is used |
846 | Â | // as such selectors are not recognized by querySelectorAll. |
847 | Â | // Thanks to Andrew Dupont for this technique. |
848 | Â | if ( nodeType === 1 && |
849 | Â | ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) { |
850 | Â | |
851 | Â | // Expand context for sibling selectors |
852 | Â | newContext = rsibling.test( selector ) && testContext( context.parentNode ) || |
853 | Â | context; |
854 | Â | |
855 | Â | // We can use :scope instead of the ID hack if the browser |
856 | Â | // supports it & if we're not changing the context. |
857 | Â | if ( newContext !== context || !support.scope ) { |
858 | Â | |
859 | Â | // Capture the context ID, setting it first if necessary |
860 | Â | if ( ( nid = context.getAttribute( "id" ) ) ) { |
861 | Â | nid = nid.replace( rcssescape, fcssescape ); |
862 | Â | } else { |
863 | Â | context.setAttribute( "id", ( nid = expando ) ); |
864 | Â | } |
865 | Â | } |
866 | Â | |
867 | Â | // Prefix every selector in the list |
868 | Â | groups = tokenize( selector ); |
869 | Â | i = groups.length; |
870 | Â | while ( i-- ) { |
871 | Â | groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " + |
872 | Â | toSelector( groups[ i ] ); |
873 | Â | } |
874 | Â | newSelector = groups.join( "," ); |
875 | Â | } |
876 | Â | |
877 | Â | try { |
878 | Â | push.apply( results, |
879 | Â | newContext.querySelectorAll( newSelector ) |
880 | Â | ); |
881 | Â | return results; |
882 | Â | } catch ( qsaError ) { |
883 | Â | nonnativeSelectorCache( selector, true ); |
884 | Â | } finally { |
885 | Â | if ( nid === expando ) { |
886 | Â | context.removeAttribute( "id" ); |
887 | Â | } |
888 | Â | } |
889 | Â | } |
890 | Â | } |
891 | Â | } |
892 | Â | |
893 | Â | // All others |
894 | Â | return select( selector.replace( rtrim, "$1" ), context, results, seed ); |
895 | Â | } |
896 | Â | |
897 | Â | /** |
898 | Â | * Create key-value caches of limited size |
899 | Â | * @returns {function(string, object)} Returns the Object data after storing it on itself with |
900 | Â | * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) |
901 | Â | * deleting the oldest entry |
902 | Â | */ |
903 | Â | function createCache() { |
904 | Â | var keys = []; |
905 | Â | |
906 | Â | function cache( key, value ) { |
907 | Â | |
908 | Â | // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) |
909 | Â | if ( keys.push( key + " " ) > Expr.cacheLength ) { |
910 | Â | |
911 | Â | // Only keep the most recent entries |
912 | Â | delete cache[ keys.shift() ]; |
913 | Â | } |
914 | Â | return ( cache[ key + " " ] = value ); |
915 | Â | } |
916 | Â | return cache; |
917 | Â | } |
918 | Â | |
919 | Â | /** |
920 | Â | * Mark a function for special use by Sizzle |
921 | Â | * @param {Function} fn The function to mark |
922 | Â | */ |
923 | Â | function markFunction( fn ) { |
924 | Â | fn[ expando ] = true; |
925 | Â | return fn; |
926 | Â | } |
927 | Â | |
928 | Â | /** |
929 | Â | * Support testing using an element |
930 | Â | * @param {Function} fn Passed the created element and returns a boolean result |
931 | Â | */ |
932 | Â | function assert( fn ) { |
933 | Â | var el = document.createElement( "fieldset" ); |
934 | Â | |
935 | Â | try { |
936 | Â | return !!fn( el ); |
937 | Â | } catch ( e ) { |
938 | Â | return false; |
939 | Â | } finally { |
940 | Â | |
941 | Â | // Remove from its parent by default |
942 | Â | if ( el.parentNode ) { |
943 | Â | el.parentNode.removeChild( el ); |
944 | Â | } |
945 | Â | |
946 | Â | // release memory in IE |
947 | Â | el = null; |
948 | Â | } |
949 | Â | } |
950 | Â | |
951 | Â | /** |
952 | Â | * Adds the same handler for all of the specified attrs |
953 | Â | * @param {String} attrs Pipe-separated list of attributes |
954 | Â | * @param {Function} handler The method that will be applied |
955 | Â | */ |
956 | Â | function addHandle( attrs, handler ) { |
957 | Â | var arr = attrs.split( "|" ), |
958 | Â | i = arr.length; |
959 | Â | |
960 | Â | while ( i-- ) { |
961 | Â | Expr.attrHandle[ arr[ i ] ] = handler; |
962 | Â | } |
963 | Â | } |
964 | Â | |
965 | Â | /** |
966 | Â | * Checks document order of two siblings |
967 | Â | * @param {Element} a |
968 | Â | * @param {Element} b |
969 | Â | * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b |
970 | Â | */ |
971 | Â | function siblingCheck( a, b ) { |
972 | Â | var cur = b && a, |
973 | Â | diff = cur && a.nodeType === 1 && b.nodeType === 1 && |
974 | Â | a.sourceIndex - b.sourceIndex; |
975 | Â | |
976 | Â | // Use IE sourceIndex if available on both nodes |
977 | Â | if ( diff ) { |
978 | Â | return diff; |
979 | Â | } |
980 | Â | |
981 | Â | // Check if b follows a |
982 | Â | if ( cur ) { |
983 | Â | while ( ( cur = cur.nextSibling ) ) { |
984 | Â | if ( cur === b ) { |
985 | Â | return -1; |
986 | Â | } |
987 | Â | } |
988 | Â | } |
989 | Â | |
990 | Â | return a ? 1 : -1; |
991 | Â | } |
992 | Â | |
993 | Â | /** |
994 | Â | * Returns a function to use in pseudos for input types |
995 | Â | * @param {String} type |
996 | Â | */ |
997 | Â | function createInputPseudo( type ) { |
998 | Â | return function( elem ) { |
999 | Â | var name = elem.nodeName.toLowerCase(); |
1000 | Â | return name === "input" && elem.type === type; |
1001 | Â | }; |
1002 | Â | } |
1003 | Â | |
1004 | Â | /** |
1005 | Â | * Returns a function to use in pseudos for buttons |
1006 | Â | * @param {String} type |
1007 | Â | */ |
1008 | Â | function createButtonPseudo( type ) { |
1009 | Â | return function( elem ) { |
1010 | Â | var name = elem.nodeName.toLowerCase(); |
1011 | Â | return ( name === "input" || name === "button" ) && elem.type === type; |
1012 | Â | }; |
1013 | Â | } |
1014 | Â | |
1015 | Â | /** |
1016 | Â | * Returns a function to use in pseudos for :enabled/:disabled |
1017 | Â | * @param {Boolean} disabled true for :disabled; false for :enabled |
1018 | Â | */ |
1019 | Â | function createDisabledPseudo( disabled ) { |
1020 | Â | |
1021 | Â | // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable |
1022 | Â | return function( elem ) { |
1023 | Â | |
1024 | Â | // Only certain elements can match :enabled or :disabled |
1025 | Â | // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled |
1026 | Â | // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled |
1027 | Â | if ( "form" in elem ) { |
1028 | Â | |
1029 | Â | // Check for inherited disabledness on relevant non-disabled elements: |
1030 | Â | // * listed form-associated elements in a disabled fieldset |
1031 | Â | // https://html.spec.whatwg.org/multipage/forms.html#category-listed |
1032 | Â | // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled |
1033 | Â | // * option elements in a disabled optgroup |
1034 | Â | // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled |
1035 | Â | // All such elements have a "form" property. |
1036 | Â | if ( elem.parentNode && elem.disabled === false ) { |
1037 | Â | |
1038 | Â | // Option elements defer to a parent optgroup if present |
1039 | Â | if ( "label" in elem ) { |
1040 | Â | if ( "label" in elem.parentNode ) { |
1041 | Â | return elem.parentNode.disabled === disabled; |
1042 | Â | } else { |
1043 | Â | return elem.disabled === disabled; |
1044 | Â | } |
1045 | Â | } |
1046 | Â | |
1047 | Â | // Support: IE 6 - 11 |
1048 | Â | // Use the isDisabled shortcut property to check for disabled fieldset ancestors |
1049 | Â | return elem.isDisabled === disabled || |
1050 | Â | |
1051 | Â | // Where there is no isDisabled, check manually |
1052 | Â | /* jshint -W018 */ |
1053 | Â | elem.isDisabled !== !disabled && |
1054 | Â | inDisabledFieldset( elem ) === disabled; |
1055 | Â | } |
1056 | Â | |
1057 | Â | return elem.disabled === disabled; |
1058 | Â | |
1059 | Â | // Try to winnow out elements that can't be disabled before trusting the disabled property. |
1060 | Â | // Some victims get caught in our net (label, legend, menu, track), but it shouldn't |
1061 | Â | // even exist on them, let alone have a boolean value. |
1062 | Â | } else if ( "label" in elem ) { |
1063 | Â | return elem.disabled === disabled; |
1064 | Â | } |
1065 | Â | |
1066 | Â | // Remaining elements are neither :enabled nor :disabled |
1067 | Â | return false; |
1068 | Â | }; |
1069 | Â | } |
1070 | Â | |
1071 | Â | /** |
1072 | Â | * Returns a function to use in pseudos for positionals |
1073 | Â | * @param {Function} fn |
1074 | Â | */ |
1075 | Â | function createPositionalPseudo( fn ) { |
1076 | Â | return markFunction( function( argument ) { |
1077 | Â | argument = +argument; |
1078 | Â | return markFunction( function( seed, matches ) { |
1079 | Â | var j, |
1080 | Â | matchIndexes = fn( [], seed.length, argument ), |
1081 | Â | i = matchIndexes.length; |
1082 | Â | |
1083 | Â | // Match elements found at the specified indexes |
1084 | Â | while ( i-- ) { |
1085 | Â | if ( seed[ ( j = matchIndexes[ i ] ) ] ) { |
1086 | Â | seed[ j ] = !( matches[ j ] = seed[ j ] ); |
1087 | Â | } |
1088 | Â | } |
1089 | Â | } ); |
1090 | Â | } ); |
1091 | Â | } |
1092 | Â | |
1093 | Â | /** |
1094 | Â | * Checks a node for validity as a Sizzle context |
1095 | Â | * @param {Element|Object=} context |
1096 | Â | * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value |
1097 | Â | */ |
1098 | Â | function testContext( context ) { |
1099 | Â | return context && typeof context.getElementsByTagName !== "undefined" && context; |
1100 | Â | } |
1101 | Â | |
1102 | Â | // Expose support vars for convenience |
1103 | Â | support = Sizzle.support = {}; |
1104 | Â | |
1105 | Â | /** |
1106 | Â | * Detects XML nodes |
1107 | Â | * @param {Element|Object} elem An element or a document |
1108 | Â | * @returns {Boolean} True iff elem is a non-HTML XML node |
1109 | Â | */ |
1110 | Â | isXML = Sizzle.isXML = function( elem ) { |
1111 | Â | var namespace = elem.namespaceURI, |
1112 | Â | docElem = ( elem.ownerDocument || elem ).documentElement; |
1113 | Â | |
1114 | Â | // Support: IE <=8 |
1115 | Â | // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes |
1116 | Â | // https://bugs.jquery.com/ticket/4833 |
1117 | Â | return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" ); |
1118 | Â | }; |
1119 | Â | |
1120 | Â | /** |
1121 | Â | * Sets document-related variables once based on the current document |
1122 | Â | * @param {Element|Object} [doc] An element or document object to use to set the document |
1123 | Â | * @returns {Object} Returns the current document |
1124 | Â | */ |
1125 | Â | setDocument = Sizzle.setDocument = function( node ) { |
1126 | Â | var hasCompare, subWindow, |
1127 | Â | doc = node ? node.ownerDocument || node : preferredDoc; |
1128 | Â | |
1129 | Â | // Return early if doc is invalid or already selected |
1130 | Â | // Support: IE 11+, Edge 17 - 18+ |
1131 | Â | // IE/Edge sometimes throw a "Permission denied" error when strict-comparing |
1132 | Â | // two documents; shallow comparisons work. |
1133 | Â | // eslint-disable-next-line eqeqeq |
1134 | Â | if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) { |
1135 | Â | return document; |
1136 | Â | } |
1137 | Â | |
1138 | Â | // Update global variables |
1139 | Â | document = doc; |
1140 | Â | docElem = document.documentElement; |
1141 | Â | documentIsHTML = !isXML( document ); |
1142 | Â | |
1143 | Â | // Support: IE 9 - 11+, Edge 12 - 18+ |
1144 | Â | // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) |
1145 | Â | // Support: IE 11+, Edge 17 - 18+ |
1146 | Â | // IE/Edge sometimes throw a "Permission denied" error when strict-comparing |
1147 | Â | // two documents; shallow comparisons work. |
1148 | Â | // eslint-disable-next-line eqeqeq |
1149 | Â | if ( preferredDoc != document && |
1150 | Â | ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) { |
1151 | Â | |
1152 | Â | // Support: IE 11, Edge |
1153 | Â | if ( subWindow.addEventListener ) { |
1154 | Â | subWindow.addEventListener( "unload", unloadHandler, false ); |
1155 | Â | |
1156 | Â | // Support: IE 9 - 10 only |
1157 | Â | } else if ( subWindow.attachEvent ) { |
1158 | Â | subWindow.attachEvent( "onunload", unloadHandler ); |
1159 | Â | } |
1160 | Â | } |
1161 | Â | |
1162 | Â | // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only, |
1163 | Â | // Safari 4 - 5 only, Opera <=11.6 - 12.x only |
1164 | Â | // IE/Edge & older browsers don't support the :scope pseudo-class. |
1165 | Â | // Support: Safari 6.0 only |
1166 | Â | // Safari 6.0 supports :scope but it's an alias of :root there. |
1167 | Â | support.scope = assert( function( el ) { |
1168 | Â | docElem.appendChild( el ).appendChild( document.createElement( "div" ) ); |
1169 | Â | return typeof el.querySelectorAll !== "undefined" && |
1170 | Â | !el.querySelectorAll( ":scope fieldset div" ).length; |
1171 | Â | } ); |
1172 | Â | |
1173 | Â | /* Attributes |
1174 | Â | ---------------------------------------------------------------------- */ |
1175 | Â | |
1176 | Â | // Support: IE<8 |
1177 | Â | // Verify that getAttribute really returns attributes and not properties |
1178 | Â | // (excepting IE8 booleans) |
1179 | Â | support.attributes = assert( function( el ) { |
1180 | Â | el.className = "i"; |
1181 | Â | return !el.getAttribute( "className" ); |
1182 | Â | } ); |
1183 | Â | |
1184 | Â | /* getElement(s)By* |
1185 | Â | ---------------------------------------------------------------------- */ |
1186 | Â | |
1187 | Â | // Check if getElementsByTagName("*") returns only elements |
1188 | Â | support.getElementsByTagName = assert( function( el ) { |
1189 | Â | el.appendChild( document.createComment( "" ) ); |
1190 | Â | return !el.getElementsByTagName( "*" ).length; |
1191 | Â | } ); |
1192 | Â | |
1193 | Â | // Support: IE<9 |
1194 | Â | support.getElementsByClassName = rnative.test( document.getElementsByClassName ); |
1195 | Â | |
1196 | Â | // Support: IE<10 |
1197 | Â | // Check if getElementById returns elements by name |
1198 | Â | // The broken getElementById methods don't pick up programmatically-set names, |
1199 | Â | // so use a roundabout getElementsByName test |
1200 | Â | support.getById = assert( function( el ) { |
1201 | Â | docElem.appendChild( el ).id = expando; |
1202 | Â | return !document.getElementsByName || !document.getElementsByName( expando ).length; |
1203 | Â | } ); |
1204 | Â | |
1205 | Â | // ID filter and find |
1206 | Â | if ( support.getById ) { |
1207 | Â | Expr.filter[ "ID" ] = function( id ) { |
1208 | Â | var attrId = id.replace( runescape, funescape ); |
1209 | Â | return function( elem ) { |
1210 | Â | return elem.getAttribute( "id" ) === attrId; |
1211 | Â | }; |
1212 | Â | }; |
1213 | Â | Expr.find[ "ID" ] = function( id, context ) { |
1214 | Â | if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { |
1215 | Â | var elem = context.getElementById( id ); |
1216 | Â | return elem ? [ elem ] : []; |
1217 | Â | } |
1218 | Â | }; |
1219 | Â | } else { |
1220 | Â | Expr.filter[ "ID" ] = function( id ) { |
1221 | Â | var attrId = id.replace( runescape, funescape ); |
1222 | Â | return function( elem ) { |
1223 | Â | var node = typeof elem.getAttributeNode !== "undefined" && |
1224 | Â | elem.getAttributeNode( "id" ); |
1225 | Â | return node && node.value === attrId; |
1226 | Â | }; |
1227 | Â | }; |
1228 | Â | |
1229 | Â | // Support: IE 6 - 7 only |
1230 | Â | // getElementById is not reliable as a find shortcut |
1231 | Â | Expr.find[ "ID" ] = function( id, context ) { |
1232 | Â | if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { |
1233 | Â | var node, i, elems, |
1234 | Â | elem = context.getElementById( id ); |
1235 | Â | |
1236 | Â | if ( elem ) { |
1237 | Â | |
1238 | Â | // Verify the id attribute |
1239 | Â | node = elem.getAttributeNode( "id" ); |
1240 | Â | if ( node && node.value === id ) { |
1241 | Â | return [ elem ]; |
1242 | Â | } |
1243 | Â | |
1244 | Â | // Fall back on getElementsByName |
1245 | Â | elems = context.getElementsByName( id ); |
1246 | Â | i = 0; |
1247 | Â | while ( ( elem = elems[ i++ ] ) ) { |
1248 | Â | node = elem.getAttributeNode( "id" ); |
1249 | Â | if ( node && node.value === id ) { |
1250 | Â | return [ elem ]; |
1251 | Â | } |
1252 | Â | } |
1253 | Â | } |
1254 | Â | |
1255 | Â | return []; |
1256 | Â | } |
1257 | Â | }; |
1258 | Â | } |
1259 | Â | |
1260 | Â | // Tag |
1261 | Â | Expr.find[ "TAG" ] = support.getElementsByTagName ? |
1262 | Â | function( tag, context ) { |
1263 | Â | if ( typeof context.getElementsByTagName !== "undefined" ) { |
1264 | Â | return context.getElementsByTagName( tag ); |
1265 | Â | |
1266 | Â | // DocumentFragment nodes don't have gEBTN |
1267 | Â | } else if ( support.qsa ) { |
1268 | Â | return context.querySelectorAll( tag ); |
1269 | Â | } |
1270 | Â | } : |
1271 | Â | |
1272 | Â | function( tag, context ) { |
1273 | Â | var elem, |
1274 | Â | tmp = [], |
1275 | Â | i = 0, |
1276 | Â | |
1277 | Â | // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too |
1278 | Â | results = context.getElementsByTagName( tag ); |
1279 | Â | |
1280 | Â | // Filter out possible comments |
1281 | Â | if ( tag === "*" ) { |
1282 | Â | while ( ( elem = results[ i++ ] ) ) { |
1283 | Â | if ( elem.nodeType === 1 ) { |
1284 | Â | tmp.push( elem ); |
1285 | Â | } |
1286 | Â | } |
1287 | Â | |
1288 | Â | return tmp; |
1289 | Â | } |
1290 | Â | return results; |
1291 | Â | }; |
1292 | Â | |
1293 | Â | // Class |
1294 | Â | Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) { |
1295 | Â | if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { |
1296 | Â | return context.getElementsByClassName( className ); |
1297 | Â | } |
1298 | Â | }; |
1299 | Â | |
1300 | Â | /* QSA/matchesSelector |
1301 | Â | ---------------------------------------------------------------------- */ |
1302 | Â | |
1303 | Â | // QSA and matchesSelector support |
1304 | Â | |
1305 | Â | // matchesSelector(:active) reports false when true (IE9/Opera 11.5) |
1306 | Â | rbuggyMatches = []; |
1307 | Â | |
1308 | Â | // qSa(:focus) reports false when true (Chrome 21) |
1309 | Â | // We allow this because of a bug in IE8/9 that throws an error |
1310 | Â | // whenever `document.activeElement` is accessed on an iframe |
1311 | Â | // So, we allow :focus to pass through QSA all the time to avoid the IE error |
1312 | Â | // See https://bugs.jquery.com/ticket/13378 |
1313 | Â | rbuggyQSA = []; |
1314 | Â | |
1315 | Â | if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) { |
1316 | Â | |
1317 | Â | // Build QSA regex |
1318 | Â | // Regex strategy adopted from Diego Perini |
1319 | Â | assert( function( el ) { |
1320 | Â | |
1321 | Â | var input; |
1322 | Â | |
1323 | Â | // Select is set to empty string on purpose |
1324 | Â | // This is to test IE's treatment of not explicitly |
1325 | Â | // setting a boolean content attribute, |
1326 | Â | // since its presence should be enough |
1327 | Â | // https://bugs.jquery.com/ticket/12359 |
1328 | Â | docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" + |
1329 | Â | "<select id='" + expando + "-\r\\' msallowcapture=''>" + |
1330 | Â | "<option selected=''></option></select>"; |
1331 | Â | |
1332 | Â | // Support: IE8, Opera 11-12.16 |
1333 | Â | // Nothing should be selected when empty strings follow ^= or $= or *= |
1334 | Â | // The test attribute must be unknown in Opera but "safe" for WinRT |
1335 | Â | // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section |
1336 | Â | if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) { |
1337 | Â | rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); |
1338 | Â | } |
1339 | Â | |
1340 | Â | // Support: IE8 |
1341 | Â | // Boolean attributes and "value" are not treated correctly |
1342 | Â | if ( !el.querySelectorAll( "[selected]" ).length ) { |
1343 | Â | rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); |
1344 | Â | } |
1345 | Â | |
1346 | Â | // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ |
1347 | Â | if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { |
1348 | Â | rbuggyQSA.push( "~=" ); |
1349 | Â | } |
1350 | Â | |
1351 | Â | // Support: IE 11+, Edge 15 - 18+ |
1352 | Â | // IE 11/Edge don't find elements on a `[name='']` query in some cases. |
1353 | Â | // Adding a temporary attribute to the document before the selection works |
1354 | Â | // around the issue. |
1355 | Â | // Interestingly, IE 10 & older don't seem to have the issue. |
1356 | Â | input = document.createElement( "input" ); |
1357 | Â | input.setAttribute( "name", "" ); |
1358 | Â | el.appendChild( input ); |
1359 | Â | if ( !el.querySelectorAll( "[name='']" ).length ) { |
1360 | Â | rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" + |
1361 | Â | whitespace + "*(?:''|\"\")" ); |
1362 | Â | } |
1363 | Â | |
1364 | Â | // Webkit/Opera - :checked should return selected option elements |
1365 | Â | // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
1366 | Â | // IE8 throws error here and will not see later tests |
1367 | Â | if ( !el.querySelectorAll( ":checked" ).length ) { |
1368 | Â | rbuggyQSA.push( ":checked" ); |
1369 | Â | } |
1370 | Â | |
1371 | Â | // Support: Safari 8+, iOS 8+ |
1372 | Â | // https://bugs.webkit.org/show_bug.cgi?id=136851 |
1373 | Â | // In-page `selector#id sibling-combinator selector` fails |
1374 | Â | if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { |
1375 | Â | rbuggyQSA.push( ".#.+[+~]" ); |
1376 | Â | } |
1377 | Â | |
1378 | Â | // Support: Firefox <=3.6 - 5 only |
1379 | Â | // Old Firefox doesn't throw on a badly-escaped identifier. |
1380 | Â | el.querySelectorAll( "\\\f" ); |
1381 | Â | rbuggyQSA.push( "[\\r\\n\\f]" ); |
1382 | Â | } ); |
1383 | Â | |
1384 | Â | assert( function( el ) { |
1385 | Â | el.innerHTML = "<a href='' disabled='disabled'></a>" + |
1386 | Â | "<select disabled='disabled'><option/></select>"; |
1387 | Â | |
1388 | Â | // Support: Windows 8 Native Apps |
1389 | Â | // The type and name attributes are restricted during .innerHTML assignment |
1390 | Â | var input = document.createElement( "input" ); |
1391 | Â | input.setAttribute( "type", "hidden" ); |
1392 | Â | el.appendChild( input ).setAttribute( "name", "D" ); |
1393 | Â | |
1394 | Â | // Support: IE8 |
1395 | Â | // Enforce case-sensitivity of name attribute |
1396 | Â | if ( el.querySelectorAll( "[name=d]" ).length ) { |
1397 | Â | rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); |
1398 | Â | } |
1399 | Â | |
1400 | Â | // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) |
1401 | Â | // IE8 throws error here and will not see later tests |
1402 | Â | if ( el.querySelectorAll( ":enabled" ).length !== 2 ) { |
1403 | Â | rbuggyQSA.push( ":enabled", ":disabled" ); |
1404 | Â | } |
1405 | Â | |
1406 | Â | // Support: IE9-11+ |
1407 | Â | // IE's :disabled selector does not pick up the children of disabled fieldsets |
1408 | Â | docElem.appendChild( el ).disabled = true; |
1409 | Â | if ( el.querySelectorAll( ":disabled" ).length !== 2 ) { |
1410 | Â | rbuggyQSA.push( ":enabled", ":disabled" ); |
1411 | Â | } |
1412 | Â | |
1413 | Â | // Support: Opera 10 - 11 only |
1414 | Â | // Opera 10-11 does not throw on post-comma invalid pseudos |
1415 | Â | el.querySelectorAll( "*,:x" ); |
1416 | Â | rbuggyQSA.push( ",.*:" ); |
1417 | Â | } ); |
1418 | Â | } |
1419 | Â | |
1420 | Â | if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches || |
1421 | Â | docElem.webkitMatchesSelector || |
1422 | Â | docElem.mozMatchesSelector || |
1423 | Â | docElem.oMatchesSelector || |
1424 | Â | docElem.msMatchesSelector ) ) ) ) { |
1425 | Â | |
1426 | Â | assert( function( el ) { |
1427 | Â | |
1428 | Â | // Check to see if it's possible to do matchesSelector |
1429 | Â | // on a disconnected node (IE 9) |
1430 | Â | support.disconnectedMatch = matches.call( el, "*" ); |
1431 | Â | |
1432 | Â | // This should fail with an exception |
1433 | Â | // Gecko does not error, returns false instead |
1434 | Â | matches.call( el, "[s!='']:x" ); |
1435 | Â | rbuggyMatches.push( "!=", pseudos ); |
1436 | Â | } ); |
1437 | Â | } |
1438 | Â | |
1439 | Â | rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) ); |
1440 | Â | rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) ); |
1441 | Â | |
1442 | Â | /* Contains |
1443 | Â | ---------------------------------------------------------------------- */ |
1444 | Â | hasCompare = rnative.test( docElem.compareDocumentPosition ); |
1445 | Â | |
1446 | Â | // Element contains another |
1447 | Â | // Purposefully self-exclusive |
1448 | Â | // As in, an element does not contain itself |
1449 | Â | contains = hasCompare || rnative.test( docElem.contains ) ? |
1450 | Â | function( a, b ) { |
1451 | Â | var adown = a.nodeType === 9 ? a.documentElement : a, |
1452 | Â | bup = b && b.parentNode; |
1453 | Â | return a === bup || !!( bup && bup.nodeType === 1 && ( |
1454 | Â | adown.contains ? |
1455 | Â | adown.contains( bup ) : |
1456 | Â | a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 |
1457 | Â | ) ); |
1458 | Â | } : |
1459 | Â | function( a, b ) { |
1460 | Â | if ( b ) { |
1461 | Â | while ( ( b = b.parentNode ) ) { |
1462 | Â | if ( b === a ) { |
1463 | Â | return true; |
1464 | Â | } |
1465 | Â | } |
1466 | Â | } |
1467 | Â | return false; |
1468 | Â | }; |
1469 | Â | |
1470 | Â | /* Sorting |
1471 | Â | ---------------------------------------------------------------------- */ |
1472 | Â | |
1473 | Â | // Document order sorting |
1474 | Â | sortOrder = hasCompare ? |
1475 | Â | function( a, b ) { |
1476 | Â | |
1477 | Â | // Flag for duplicate removal |
1478 | Â | if ( a === b ) { |
1479 | Â | hasDuplicate = true; |
1480 | Â | return 0; |
1481 | Â | } |
1482 | Â | |
1483 | Â | // Sort on method existence if only one input has compareDocumentPosition |
1484 | Â | var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; |
1485 | Â | if ( compare ) { |
1486 | Â | return compare; |
1487 | Â | } |
1488 | Â | |
1489 | Â | // Calculate position if both inputs belong to the same document |
1490 | Â | // Support: IE 11+, Edge 17 - 18+ |
1491 | Â | // IE/Edge sometimes throw a "Permission denied" error when strict-comparing |
1492 | Â | // two documents; shallow comparisons work. |
1493 | Â | // eslint-disable-next-line eqeqeq |
1494 | Â | compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ? |
1495 | Â | a.compareDocumentPosition( b ) : |
1496 | Â | |
1497 | Â | // Otherwise we know they are disconnected |
1498 | Â | 1; |
1499 | Â | |
1500 | Â | // Disconnected nodes |
1501 | Â | if ( compare & 1 || |
1502 | Â | ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) { |
1503 | Â | |
1504 | Â | // Choose the first element that is related to our preferred document |
1505 | Â | // Support: IE 11+, Edge 17 - 18+ |
1506 | Â | // IE/Edge sometimes throw a "Permission denied" error when strict-comparing |
1507 | Â | // two documents; shallow comparisons work. |
1508 | Â | // eslint-disable-next-line eqeqeq |
1509 | Â | if ( a == document || a.ownerDocument == preferredDoc && |
1510 | Â | contains( preferredDoc, a ) ) { |
1511 | Â | return -1; |
1512 | Â | } |
1513 | Â | |
1514 | Â | // Support: IE 11+, Edge 17 - 18+ |
1515 | Â | // IE/Edge sometimes throw a "Permission denied" error when strict-comparing |
1516 | Â | // two documents; shallow comparisons work. |
1517 | Â | // eslint-disable-next-line eqeqeq |
1518 | Â | if ( b == document || b.ownerDocument == preferredDoc && |
1519 | Â | contains( preferredDoc, b ) ) { |
1520 | Â | return 1; |
1521 | Â | } |
1522 | Â | |
1523 | Â | // Maintain original order |
1524 | Â | return sortInput ? |
1525 | Â | ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : |
1526 | Â | 0; |
1527 | Â | } |
1528 | Â | |
1529 | Â | return compare & 4 ? -1 : 1; |
1530 | Â | } : |
1531 | Â | function( a, b ) { |
1532 | Â | |
1533 | Â | // Exit early if the nodes are identical |
1534 | Â | if ( a === b ) { |
1535 | Â | hasDuplicate = true; |
1536 | Â | return 0; |
1537 | Â | } |
1538 | Â | |
1539 | Â | var cur, |
1540 | Â | i = 0, |
1541 | Â | aup = a.parentNode, |
1542 | Â | bup = b.parentNode, |
1543 | Â | ap = [ a ], |
1544 | Â | bp = [ b ]; |
1545 | Â | |
1546 | Â | // Parentless nodes are either documents or disconnected |
1547 | Â | if ( !aup || !bup ) { |
1548 | Â | |
1549 | Â | // Support: IE 11+, Edge 17 - 18+ |
1550 | Â | // IE/Edge sometimes throw a "Permission denied" error when strict-comparing |
1551 | Â | // two documents; shallow comparisons work. |
1552 | Â | /* eslint-disable eqeqeq */ |
1553 | Â | return a == document ? -1 : |
1554 | Â | b == document ? 1 : |
1555 | Â | /* eslint-enable eqeqeq */ |
1556 | Â | aup ? -1 : |
1557 | Â | bup ? 1 : |
1558 | Â | sortInput ? |
1559 | Â | ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : |
1560 | Â | 0; |
1561 | Â | |
1562 | Â | // If the nodes are siblings, we can do a quick check |
1563 | Â | } else if ( aup === bup ) { |
1564 | Â | return siblingCheck( a, b ); |
1565 | Â | } |
1566 | Â | |
1567 | Â | // Otherwise we need full lists of their ancestors for comparison |
1568 | Â | cur = a; |
1569 | Â | while ( ( cur = cur.parentNode ) ) { |
1570 | Â | ap.unshift( cur ); |
1571 | Â | } |
1572 | Â | cur = b; |
1573 | Â | while ( ( cur = cur.parentNode ) ) { |
1574 | Â | bp.unshift( cur ); |
1575 | Â | } |
1576 | Â | |
1577 | Â | // Walk down the tree looking for a discrepancy |
1578 | Â | while ( ap[ i ] === bp[ i ] ) { |
1579 | Â | i++; |
1580 | Â | } |
1581 | Â | |
1582 | Â | return i ? |
1583 | Â | |
1584 | Â | // Do a sibling check if the nodes have a common ancestor |
1585 | Â | siblingCheck( ap[ i ], bp[ i ] ) : |
1586 | Â | |
1587 | Â | // Otherwise nodes in our document sort first |
1588 | Â | // Support: IE 11+, Edge 17 - 18+ |
1589 | Â | // IE/Edge sometimes throw a "Permission denied" error when strict-comparing |
1590 | Â | // two documents; shallow comparisons work. |
1591 | Â | /* eslint-disable eqeqeq */ |
1592 | Â | ap[ i ] == preferredDoc ? -1 : |
1593 | Â | bp[ i ] == preferredDoc ? 1 : |
1594 | Â | /* eslint-enable eqeqeq */ |
1595 | Â | 0; |
1596 | Â | }; |
1597 | Â | |
1598 | Â | return document; |
1599 | Â | }; |
1600 | Â | |
1601 | Â | Sizzle.matches = function( expr, elements ) { |
1602 | Â | return Sizzle( expr, null, null, elements ); |
1603 | Â | }; |
1604 | Â | |
1605 | Â | Sizzle.matchesSelector = function( elem, expr ) { |
1606 | Â | setDocument( elem ); |
1607 | Â | |
1608 | Â | if ( support.matchesSelector && documentIsHTML && |
1609 | Â | !nonnativeSelectorCache[ expr + " " ] && |
1610 | Â | ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && |
1611 | Â | ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { |
1612 | Â | |
1613 | Â | try { |
1614 | Â | var ret = matches.call( elem, expr ); |
1615 | Â | |
1616 | Â | // IE 9's matchesSelector returns false on disconnected nodes |
1617 | Â | if ( ret || support.disconnectedMatch || |
1618 | Â | |
1619 | Â | // As well, disconnected nodes are said to be in a document |
1620 | Â | // fragment in IE 9 |
1621 | Â | elem.document && elem.document.nodeType !== 11 ) { |
1622 | Â | return ret; |
1623 | Â | } |
1624 | Â | } catch ( e ) { |
1625 | Â | nonnativeSelectorCache( expr, true ); |
1626 | Â | } |
1627 | Â | } |
1628 | Â | |
1629 | Â | return Sizzle( expr, document, null, [ elem ] ).length > 0; |
1630 | Â | }; |
1631 | Â | |
1632 | Â | Sizzle.contains = function( context, elem ) { |
1633 | Â | |
1634 | Â | // Set document vars if needed |
1635 | Â | // Support: IE 11+, Edge 17 - 18+ |
1636 | Â | // IE/Edge sometimes throw a "Permission denied" error when strict-comparing |
1637 | Â | // two documents; shallow comparisons work. |
1638 | Â | // eslint-disable-next-line eqeqeq |
1639 | Â | if ( ( context.ownerDocument || context ) != document ) { |
1640 | Â | setDocument( context ); |
1641 | Â | } |
1642 | Â | return contains( context, elem ); |
1643 | Â | }; |
1644 | Â | |
1645 | Â | Sizzle.attr = function( elem, name ) { |
1646 | Â | |
1647 | Â | // Set document vars if needed |
1648 | Â | // Support: IE 11+, Edge 17 - 18+ |
1649 | Â | // IE/Edge sometimes throw a "Permission denied" error when strict-comparing |
1650 | Â | // two documents; shallow comparisons work. |
1651 | Â | // eslint-disable-next-line eqeqeq |
1652 | Â | if ( ( elem.ownerDocument || elem ) != document ) { |
1653 | Â | setDocument( elem ); |
1654 | Â | } |
1655 | Â | |
1656 | Â | var fn = Expr.attrHandle[ name.toLowerCase() ], |
1657 | Â | |
1658 | Â | // Don't get fooled by Object.prototype properties (jQuery #13807) |
1659 | Â | val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? |
1660 | Â | fn( elem, name, !documentIsHTML ) : |
1661 | Â | undefined; |
1662 | Â | |
1663 | Â | return val !== undefined ? |
1664 | Â | val : |
1665 | Â | support.attributes || !documentIsHTML ? |
1666 | Â | elem.getAttribute( name ) : |
1667 | Â | ( val = elem.getAttributeNode( name ) ) && val.specified ? |
1668 | Â | val.value : |
1669 | Â | null; |
1670 | Â | }; |
1671 | Â | |
1672 | Â | Sizzle.escape = function( sel ) { |
1673 | Â | return ( sel + "" ).replace( rcssescape, fcssescape ); |
1674 | Â | }; |
1675 | Â | |
1676 | Â | Sizzle.error = function( msg ) { |
1677 | Â | throw new Error( "Syntax error, unrecognized expression: " + msg ); |
1678 | Â | }; |
1679 | Â | |
1680 | Â | /** |
1681 | Â | * Document sorting and removing duplicates |
1682 | Â | * @param {ArrayLike} results |
1683 | Â | */ |
1684 | Â | Sizzle.uniqueSort = function( results ) { |
1685 | Â | var elem, |
1686 | Â | duplicates = [], |
1687 | Â | j = 0, |
1688 | Â | i = 0; |
1689 | Â | |
1690 | Â | // Unless we *know* we can detect duplicates, assume their presence |
1691 | Â | hasDuplicate = !support.detectDuplicates; |
1692 | Â | sortInput = !support.sortStable && results.slice( 0 ); |
1693 | Â | results.sort( sortOrder ); |
1694 | Â | |
1695 | Â | if ( hasDuplicate ) { |
1696 | Â | while ( ( elem = results[ i++ ] ) ) { |
1697 | Â | if ( elem === results[ i ] ) { |
1698 | Â | j = duplicates.push( i ); |
1699 | Â | } |
1700 | Â | } |
1701 | Â | while ( j-- ) { |
1702 | Â | results.splice( duplicates[ j ], 1 ); |
1703 | Â | } |
1704 | Â | } |
1705 | Â | |
1706 | Â | // Clear input after sorting to release objects |
1707 | Â | // See https://github.com/jquery/sizzle/pull/225 |
1708 | Â | sortInput = null; |
1709 | Â | |
1710 | Â | return results; |
1711 | Â | }; |
1712 | Â | |
1713 | Â | /** |
1714 | Â | * Utility function for retrieving the text value of an array of DOM nodes |
1715 | Â | * @param {Array|Element} elem |
1716 | Â | */ |
1717 | Â | getText = Sizzle.getText = function( elem ) { |
1718 | Â | var node, |
1719 | Â | ret = "", |
1720 | Â | i = 0, |
1721 | Â | nodeType = elem.nodeType; |
1722 | Â | |
1723 | Â | if ( !nodeType ) { |
1724 | Â | |
1725 | Â | // If no nodeType, this is expected to be an array |
1726 | Â | while ( ( node = elem[ i++ ] ) ) { |
1727 | Â | |
1728 | Â | // Do not traverse comment nodes |
1729 | Â | ret += getText( node ); |
1730 | Â | } |
1731 | Â | } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { |
1732 | Â | |
1733 | Â | // Use textContent for elements |
1734 | Â | // innerText usage removed for consistency of new lines (jQuery #11153) |
1735 | Â | if ( typeof elem.textContent === "string" ) { |
1736 | Â | return elem.textContent; |
1737 | Â | } else { |
1738 | Â | |
1739 | Â | // Traverse its children |
1740 | Â | for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { |
1741 | Â | ret += getText( elem ); |
1742 | Â | } |
1743 | Â | } |
1744 | Â | } else if ( nodeType === 3 || nodeType === 4 ) { |
1745 | Â | return elem.nodeValue; |
1746 | Â | } |
1747 | Â | |
1748 | Â | // Do not include comment or processing instruction nodes |
1749 | Â | |
1750 | Â | return ret; |
1751 | Â | }; |
1752 | Â | |
1753 | Â | Expr = Sizzle.selectors = { |
1754 | Â | |
1755 | Â | // Can be adjusted by the user |
1756 | Â | cacheLength: 50, |
1757 | Â | |
1758 | Â | createPseudo: markFunction, |
1759 | Â | |
1760 | Â | match: matchExpr, |
1761 | Â | |
1762 | Â | attrHandle: {}, |
1763 | Â | |
1764 | Â | find: {}, |
1765 | Â | |
1766 | Â | relative: { |
1767 | Â | ">": { dir: "parentNode", first: true }, |
1768 | Â | " ": { dir: "parentNode" }, |
1769 | Â | "+": { dir: "previousSibling", first: true }, |
1770 | Â | "~": { dir: "previousSibling" } |
1771 | Â | }, |
1772 | Â | |
1773 | Â | preFilter: { |
1774 | Â | "ATTR": function( match ) { |
1775 | Â | match[ 1 ] = match[ 1 ].replace( runescape, funescape ); |
1776 | Â | |
1777 | Â | // Move the given value to match[3] whether quoted or unquoted |
1778 | Â | match[ 3 ] = ( match[ 3 ] || match[ 4 ] || |
1779 | Â | match[ 5 ] || "" ).replace( runescape, funescape ); |
1780 | Â | |
1781 | Â | if ( match[ 2 ] === "~=" ) { |
1782 | Â | match[ 3 ] = " " + match[ 3 ] + " "; |
1783 | Â | } |
1784 | Â | |
1785 | Â | return match.slice( 0, 4 ); |
1786 | Â | }, |
1787 | Â | |
1788 | Â | "CHILD": function( match ) { |
1789 | Â | |
1790 | Â | /* matches from matchExpr["CHILD"] |
1791 | Â | 1 type (only|nth|...) |
1792 | Â | 2 what (child|of-type) |
1793 | Â | 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) |
1794 | Â | 4 xn-component of xn+y argument ([+-]?\d*n|) |
1795 | Â | 5 sign of xn-component |
1796 | Â | 6 x of xn-component |
1797 | Â | 7 sign of y-component |
1798 | Â | 8 y of y-component |
1799 | Â | */ |
1800 | Â | match[ 1 ] = match[ 1 ].toLowerCase(); |
1801 | Â | |
1802 | Â | if ( match[ 1 ].slice( 0, 3 ) === "nth" ) { |
1803 | Â | |
1804 | Â | // nth-* requires argument |
1805 | Â | if ( !match[ 3 ] ) { |
1806 | Â | Sizzle.error( match[ 0 ] ); |
1807 | Â | } |
1808 | Â | |
1809 | Â | // numeric x and y parameters for Expr.filter.CHILD |
1810 | Â | // remember that false/true cast respectively to 0/1 |
1811 | Â | match[ 4 ] = +( match[ 4 ] ? |
1812 | Â | match[ 5 ] + ( match[ 6 ] || 1 ) : |
1813 | Â | 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) ); |
1814 | Â | match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" ); |
1815 | Â | |
1816 | Â | // other types prohibit arguments |
1817 | Â | } else if ( match[ 3 ] ) { |
1818 | Â | Sizzle.error( match[ 0 ] ); |
1819 | Â | } |
1820 | Â | |
1821 | Â | return match; |
1822 | Â | }, |
1823 | Â | |
1824 | Â | "PSEUDO": function( match ) { |
1825 | Â | var excess, |
1826 | Â | unquoted = !match[ 6 ] && match[ 2 ]; |
1827 | Â | |
1828 | Â | if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) { |
1829 | Â | return null; |
1830 | Â | } |
1831 | Â | |
1832 | Â | // Accept quoted arguments as-is |
1833 | Â | if ( match[ 3 ] ) { |
1834 | Â | match[ 2 ] = match[ 4 ] || match[ 5 ] || ""; |
1835 | Â | |
1836 | Â | // Strip excess characters from unquoted arguments |
1837 | Â | } else if ( unquoted && rpseudo.test( unquoted ) && |
1838 | Â | |
1839 | Â | // Get excess from tokenize (recursively) |
1840 | Â | ( excess = tokenize( unquoted, true ) ) && |
1841 | Â | |
1842 | Â | // advance to the next closing parenthesis |
1843 | Â | ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) { |
1844 | Â | |
1845 | Â | // excess is a negative index |
1846 | Â | match[ 0 ] = match[ 0 ].slice( 0, excess ); |
1847 | Â | match[ 2 ] = unquoted.slice( 0, excess ); |
1848 | Â | } |
1849 | Â | |
1850 | Â | // Return only captures needed by the pseudo filter method (type and argument) |
1851 | Â | return match.slice( 0, 3 ); |
1852 | Â | } |
1853 | Â | }, |
1854 | Â | |
1855 | Â | filter: { |
1856 | Â | |
1857 | Â | "TAG": function( nodeNameSelector ) { |
1858 | Â | var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); |
1859 | Â | return nodeNameSelector === "*" ? |
1860 | Â | function() { |
1861 | Â | return true; |
1862 | Â | } : |
1863 | Â | function( elem ) { |
1864 | Â | return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; |
1865 | Â | }; |
1866 | Â | }, |
1867 | Â | |
1868 | Â | "CLASS": function( className ) { |
1869 | Â | var pattern = classCache[ className + " " ]; |
1870 | Â | |
1871 | Â | return pattern || |
1872 | Â | ( pattern = new RegExp( "(^|" + whitespace + |
1873 | Â | ")" + className + "(" + whitespace + "|$)" ) ) && classCache( |
1874 | Â | className, function( elem ) { |
1875 | Â | return pattern.test( |
1876 | Â | typeof elem.className === "string" && elem.className || |
1877 | Â | typeof elem.getAttribute !== "undefined" && |
1878 | Â | elem.getAttribute( "class" ) || |
1879 | Â | "" |
1880 | Â | ); |
1881 | Â | } ); |
1882 | Â | }, |
1883 | Â | |
1884 | Â | "ATTR": function( name, operator, check ) { |
1885 | Â | return function( elem ) { |
1886 | Â | var result = Sizzle.attr( elem, name ); |
1887 | Â | |
1888 | Â | if ( result == null ) { |
1889 | Â | return operator === "!="; |
1890 | Â | } |
1891 | Â | if ( !operator ) { |
1892 | Â | return true; |
1893 | Â | } |
1894 | Â | |
1895 | Â | result += ""; |
1896 | Â | |
1897 | Â | /* eslint-disable max-len */ |
1898 | Â | |
1899 | Â | return operator === "=" ? result === check : |
1900 | Â | operator === "!=" ? result !== check : |
1901 | Â | operator === "^=" ? check && result.indexOf( check ) === 0 : |
1902 | Â | operator === "*=" ? check && result.indexOf( check ) > -1 : |
1903 | Â | operator === "$=" ? check && result.slice( -check.length ) === check : |
1904 | Â | operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : |
1905 | Â | operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : |
1906 | Â | false; |
1907 | Â | /* eslint-enable max-len */ |
1908 | Â | |
1909 | Â | }; |
1910 | Â | }, |
1911 | Â | |
1912 | Â | "CHILD": function( type, what, _argument, first, last ) { |
1913 | Â | var simple = type.slice( 0, 3 ) !== "nth", |
1914 | Â | forward = type.slice( -4 ) !== "last", |
1915 | Â | ofType = what === "of-type"; |
1916 | Â | |
1917 | Â | return first === 1 && last === 0 ? |
1918 | Â | |
1919 | Â | // Shortcut for :nth-*(n) |
1920 | Â | function( elem ) { |
1921 | Â | return !!elem.parentNode; |
1922 | Â | } : |
1923 | Â | |
1924 | Â | function( elem, _context, xml ) { |
1925 | Â | var cache, uniqueCache, outerCache, node, nodeIndex, start, |
1926 | Â | dir = simple !== forward ? "nextSibling" : "previousSibling", |
1927 | Â | parent = elem.parentNode, |
1928 | Â | name = ofType && elem.nodeName.toLowerCase(), |
1929 | Â | useCache = !xml && !ofType, |
1930 | Â | diff = false; |
1931 | Â | |
1932 | Â | if ( parent ) { |
1933 | Â | |
1934 | Â | // :(first|last|only)-(child|of-type) |
1935 | Â | if ( simple ) { |
1936 | Â | while ( dir ) { |
1937 | Â | node = elem; |
1938 | Â | while ( ( node = node[ dir ] ) ) { |
1939 | Â | if ( ofType ? |
1940 | Â | node.nodeName.toLowerCase() === name : |
1941 | Â | node.nodeType === 1 ) { |
1942 | Â | |
1943 | Â | return false; |
1944 | Â | } |
1945 | Â | } |
1946 | Â | |
1947 | Â | // Reverse direction for :only-* (if we haven't yet done so) |
1948 | Â | start = dir = type === "only" && !start && "nextSibling"; |
1949 | Â | } |
1950 | Â | return true; |
1951 | Â | } |
1952 | Â | |
1953 | Â | start = [ forward ? parent.firstChild : parent.lastChild ]; |
1954 | Â | |
1955 | Â | // non-xml :nth-child(...) stores cache data on `parent` |
1956 | Â | if ( forward && useCache ) { |
1957 | Â | |
1958 | Â | // Seek `elem` from a previously-cached index |
1959 | Â | |
1960 | Â | // ...in a gzip-friendly way |
1961 | Â | node = parent; |
1962 | Â | outerCache = node[ expando ] || ( node[ expando ] = {} ); |
1963 | Â | |
1964 | Â | // Support: IE <9 only |
1965 | Â | // Defend against cloned attroperties (jQuery gh-1709) |
1966 | Â | uniqueCache = outerCache[ node.uniqueID ] || |
1967 | Â | ( outerCache[ node.uniqueID ] = {} ); |
1968 | Â | |
1969 | Â | cache = uniqueCache[ type ] || []; |
1970 | Â | nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; |
1971 | Â | diff = nodeIndex && cache[ 2 ]; |
1972 | Â | node = nodeIndex && parent.childNodes[ nodeIndex ]; |
1973 | Â | |
1974 | Â | while ( ( node = ++nodeIndex && node && node[ dir ] || |
1975 | Â | |
1976 | Â | // Fallback to seeking `elem` from the start |
1977 | Â | ( diff = nodeIndex = 0 ) || start.pop() ) ) { |
1978 | Â | |
1979 | Â | // When found, cache indexes on `parent` and break |
1980 | Â | if ( node.nodeType === 1 && ++diff && node === elem ) { |
1981 | Â | uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; |
1982 | Â | break; |
1983 | Â | } |
1984 | Â | } |
1985 | Â | |
1986 | Â | } else { |
1987 | Â | |
1988 | Â | // Use previously-cached element index if available |
1989 | Â | if ( useCache ) { |
1990 | Â | |
1991 | Â | // ...in a gzip-friendly way |
1992 | Â | node = elem; |
1993 | Â | outerCache = node[ expando ] || ( node[ expando ] = {} ); |
1994 | Â | |
1995 | Â | // Support: IE <9 only |
1996 | Â | // Defend against cloned attroperties (jQuery gh-1709) |
1997 | Â | uniqueCache = outerCache[ node.uniqueID ] || |
1998 | Â | ( outerCache[ node.uniqueID ] = {} ); |
1999 | Â | |
2000 | Â | cache = uniqueCache[ type ] || []; |
2001 | Â | nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; |
2002 | Â | diff = nodeIndex; |
2003 | Â | } |
2004 | Â | |
2005 | Â | // xml :nth-child(...) |
2006 | Â | // or :nth-last-child(...) or :nth(-last)?-of-type(...) |
2007 | Â | if ( diff === false ) { |
2008 | Â | |
2009 | Â | // Use the same loop as above to seek `elem` from the start |
2010 | Â | while ( ( node = ++nodeIndex && node && node[ dir ] || |
2011 | Â | ( diff = nodeIndex = 0 ) || start.pop() ) ) { |
2012 | Â | |
2013 | Â | if ( ( ofType ? |
2014 | Â | node.nodeName.toLowerCase() === name : |
2015 | Â | node.nodeType === 1 ) && |
2016 | Â | ++diff ) { |
2017 | Â | |
2018 | Â | // Cache the index of each encountered element |
2019 | Â | if ( useCache ) { |
2020 | Â | outerCache = node[ expando ] || |
2021 | Â | ( node[ expando ] = {} ); |
2022 | Â | |
2023 | Â | // Support: IE <9 only |
2024 | Â | // Defend against cloned attroperties (jQuery gh-1709) |
2025 | Â | uniqueCache = outerCache[ node.uniqueID ] || |
2026 | Â | ( outerCache[ node.uniqueID ] = {} ); |
2027 | Â | |
2028 | Â | uniqueCache[ type ] = [ dirruns, diff ]; |
2029 | Â | } |
2030 | Â | |
2031 | Â | if ( node === elem ) { |
2032 | Â | break; |
2033 | Â | } |
2034 | Â | } |
2035 | Â | } |
2036 | Â | } |
2037 | Â | } |
2038 | Â | |
2039 | Â | // Incorporate the offset, then check against cycle size |
2040 | Â | diff -= last; |
2041 | Â | return diff === first || ( diff % first === 0 && diff / first >= 0 ); |
2042 | Â | } |
2043 | Â | }; |
2044 | Â | }, |
2045 | Â | |
2046 | Â | "PSEUDO": function( pseudo, argument ) { |
2047 | Â | |
2048 | Â | // pseudo-class names are case-insensitive |
2049 | Â | // http://www.w3.org/TR/selectors/#pseudo-classes |
2050 | Â | // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters |
2051 | Â | // Remember that setFilters inherits from pseudos |
2052 | Â | var args, |
2053 | Â | fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || |
2054 | Â | Sizzle.error( "unsupported pseudo: " + pseudo ); |
2055 | Â | |
2056 | Â | // The user may use createPseudo to indicate that |
2057 | Â | // arguments are needed to create the filter function |
2058 | Â | // just as Sizzle does |
2059 | Â | if ( fn[ expando ] ) { |
2060 | Â | return fn( argument ); |
2061 | Â | } |
2062 | Â | |
2063 | Â | // But maintain support for old signatures |
2064 | Â | if ( fn.length > 1 ) { |
2065 | Â | args = [ pseudo, pseudo, "", argument ]; |
2066 | Â | return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? |
2067 | Â | markFunction( function( seed, matches ) { |
2068 | Â | var idx, |
2069 | Â | matched = fn( seed, argument ), |
2070 | Â | i = matched.length; |
2071 | Â | while ( i-- ) { |
2072 | Â | idx = indexOf( seed, matched[ i ] ); |
2073 | Â | seed[ idx ] = !( matches[ idx ] = matched[ i ] ); |
2074 | Â | } |
2075 | Â | } ) : |
2076 | Â | function( elem ) { |
2077 | Â | return fn( elem, 0, args ); |
2078 | Â | }; |
2079 | Â | } |
2080 | Â | |
2081 | Â | return fn; |
2082 | Â | } |
2083 | Â | }, |
2084 | Â | |
2085 | Â | pseudos: { |
2086 | Â | |
2087 | Â | // Potentially complex pseudos |
2088 | Â | "not": markFunction( function( selector ) { |
2089 | Â | |
2090 | Â | // Trim the selector passed to compile |
2091 | Â | // to avoid treating leading and trailing |
2092 | Â | // spaces as combinators |
2093 | Â | var input = [], |
2094 | Â | results = [], |
2095 | Â | matcher = compile( selector.replace( rtrim, "$1" ) ); |
2096 | Â | |
2097 | Â | return matcher[ expando ] ? |
2098 | Â | markFunction( function( seed, matches, _context, xml ) { |
2099 | Â | var elem, |
2100 | Â | unmatched = matcher( seed, null, xml, [] ), |
2101 | Â | i = seed.length; |
2102 | Â | |
2103 | Â | // Match elements unmatched by `matcher` |
2104 | Â | while ( i-- ) { |
2105 | Â | if ( ( elem = unmatched[ i ] ) ) { |
2106 | Â | seed[ i ] = !( matches[ i ] = elem ); |
2107 | Â | } |
2108 | Â | } |
2109 | Â | } ) : |
2110 | Â | function( elem, _context, xml ) { |
2111 | Â | input[ 0 ] = elem; |
2112 | Â | matcher( input, null, xml, results ); |
2113 | Â | |
2114 | Â | // Don't keep the element (issue #299) |
2115 | Â | input[ 0 ] = null; |
2116 | Â | return !results.pop(); |
2117 | Â | }; |
2118 | Â | } ), |
2119 | Â | |
2120 | Â | "has": markFunction( function( selector ) { |
2121 | Â | return function( elem ) { |
2122 | Â | return Sizzle( selector, elem ).length > 0; |
2123 | Â | }; |
2124 | Â | } ), |
2125 | Â | |
2126 | Â | "contains": markFunction( function( text ) { |
2127 | Â | text = text.replace( runescape, funescape ); |
2128 | Â | return function( elem ) { |
2129 | Â | return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1; |
2130 | Â | }; |
2131 | Â | } ), |
2132 | Â | |
2133 | Â | // "Whether an element is represented by a :lang() selector |
2134 | Â | // is based solely on the element's language value |
2135 | Â | // being equal to the identifier C, |
2136 | Â | // or beginning with the identifier C immediately followed by "-". |
2137 | Â | // The matching of C against the element's language value is performed case-insensitively. |
2138 | Â | // The identifier C does not have to be a valid language name." |
2139 | Â | // http://www.w3.org/TR/selectors/#lang-pseudo |
2140 | Â | "lang": markFunction( function( lang ) { |
2141 | Â | |
2142 | Â | // lang value must be a valid identifier |
2143 | Â | if ( !ridentifier.test( lang || "" ) ) { |
2144 | Â | Sizzle.error( "unsupported lang: " + lang ); |
2145 | Â | } |
2146 | Â | lang = lang.replace( runescape, funescape ).toLowerCase(); |
2147 | Â | return function( elem ) { |
2148 | Â | var elemLang; |
2149 | Â | do { |
2150 | Â | if ( ( elemLang = documentIsHTML ? |
2151 | Â | elem.lang : |
2152 | Â | elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) { |
2153 | Â | |
2154 | Â | elemLang = elemLang.toLowerCase(); |
2155 | Â | return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; |
2156 | Â | } |
2157 | Â | } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 ); |
2158 | Â | return false; |
2159 | Â | }; |
2160 | Â | } ), |
2161 | Â | |
2162 | Â | // Miscellaneous |
2163 | Â | "target": function( elem ) { |
2164 | Â | var hash = window.location && window.location.hash; |
2165 | Â | return hash && hash.slice( 1 ) === elem.id; |
2166 | Â | }, |
2167 | Â | |
2168 | Â | "root": function( elem ) { |
2169 | Â | return elem === docElem; |
2170 | Â | }, |
2171 | Â | |
2172 | Â | "focus": function( elem ) { |
2173 | Â | return elem === document.activeElement && |
2174 | Â | ( !document.hasFocus || document.hasFocus() ) && |
2175 | Â | !!( elem.type || elem.href || ~elem.tabIndex ); |
2176 | Â | }, |
2177 | Â | |
2178 | Â | // Boolean properties |
2179 | Â | "enabled": createDisabledPseudo( false ), |
2180 | Â | "disabled": createDisabledPseudo( true ), |
2181 | Â | |
2182 | Â | "checked": function( elem ) { |
2183 | Â | |
2184 | Â | // In CSS3, :checked should return both checked and selected elements |
2185 | Â | // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked |
2186 | Â | var nodeName = elem.nodeName.toLowerCase(); |
2187 | Â | return ( nodeName === "input" && !!elem.checked ) || |
2188 | Â | ( nodeName === "option" && !!elem.selected ); |
2189 | Â | }, |
2190 | Â | |
2191 | Â | "selected": function( elem ) { |
2192 | Â | |
2193 | Â | // Accessing this property makes selected-by-default |
2194 | Â | // options in Safari work properly |
2195 | Â | if ( elem.parentNode ) { |
2196 | Â | // eslint-disable-next-line no-unused-expressions |
2197 | Â | elem.parentNode.selectedIndex; |
2198 | Â | } |
2199 | Â | |
2200 | Â | return elem.selected === true; |
2201 | Â | }, |
2202 | Â | |
2203 | Â | // Contents |
2204 | Â | "empty": function( elem ) { |
2205 | Â | |
2206 | Â | // http://www.w3.org/TR/selectors/#empty-pseudo |
2207 | Â | // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), |
2208 | Â | // but not by others (comment: 8; processing instruction: 7; etc.) |
2209 | Â | // nodeType < 6 works because attributes (2) do not appear as children |
2210 | Â | for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { |
2211 | Â | if ( elem.nodeType < 6 ) { |
2212 | Â | return false; |
2213 | Â | } |
2214 | Â | } |
2215 | Â | return true; |
2216 | Â | }, |
2217 | Â | |
2218 | Â | "parent": function( elem ) { |
2219 | Â | return !Expr.pseudos[ "empty" ]( elem ); |
2220 | Â | }, |
2221 | Â | |
2222 | Â | // Element/input types |
2223 | Â | "header": function( elem ) { |
2224 | Â | return rheader.test( elem.nodeName ); |
2225 | Â | }, |
2226 | Â | |
2227 | Â | "input": function( elem ) { |
2228 | Â | return rinputs.test( elem.nodeName ); |
2229 | Â | }, |
2230 | Â | |
2231 | Â | "button": function( elem ) { |
2232 | Â | var name = elem.nodeName.toLowerCase(); |
2233 | Â | return name === "input" && elem.type === "button" || name === "button"; |
2234 | Â | }, |
2235 | Â | |
2236 | Â | "text": function( elem ) { |
2237 | Â | var attr; |
2238 | Â | return elem.nodeName.toLowerCase() === "input" && |
2239 | Â | elem.type === "text" && |
2240 | Â | |
2241 | Â | // Support: IE<8 |
2242 | Â | // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" |
2243 | Â | ( ( attr = elem.getAttribute( "type" ) ) == null || |
2244 | Â | attr.toLowerCase() === "text" ); |
2245 | Â | }, |
2246 | Â | |
2247 | Â | // Position-in-collection |
2248 | Â | "first": createPositionalPseudo( function() { |
2249 | Â | return [ 0 ]; |
2250 | Â | } ), |
2251 | Â | |
2252 | Â | "last": createPositionalPseudo( function( _matchIndexes, length ) { |
2253 | Â | return [ length - 1 ]; |
2254 | Â | } ), |
2255 | Â | |
2256 | Â | "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) { |
2257 | Â | return [ argument < 0 ? argument + length : argument ]; |
2258 | Â | } ), |
2259 | Â | |
2260 | Â | "even": createPositionalPseudo( function( matchIndexes, length ) { |
2261 | Â | var i = 0; |
2262 | Â | for ( ; i < length; i += 2 ) { |
2263 | Â | matchIndexes.push( i ); |
2264 | Â | } |
2265 | Â | return matchIndexes; |
2266 | Â | } ), |
2267 | Â | |
2268 | Â | "odd": createPositionalPseudo( function( matchIndexes, length ) { |
2269 | Â | var i = 1; |
2270 | Â | for ( ; i < length; i += 2 ) { |
2271 | Â | matchIndexes.push( i ); |
2272 | Â | } |
2273 | Â | return matchIndexes; |
2274 | Â | } ), |
2275 | Â | |
2276 | Â | "lt": createPositionalPseudo( function( matchIndexes, length, argument ) { |
2277 | Â | var i = argument < 0 ? |
2278 | Â | argument + length : |
2279 | Â | argument > length ? |
2280 | Â | length : |
2281 | Â | argument; |
2282 | Â | for ( ; --i >= 0; ) { |
2283 | Â | matchIndexes.push( i ); |
2284 | Â | } |
2285 | Â | return matchIndexes; |
2286 | Â | } ), |
2287 | Â | |
2288 | Â | "gt": createPositionalPseudo( function( matchIndexes, length, argument ) { |
2289 | Â | var i = argument < 0 ? argument + length : argument; |
2290 | Â | for ( ; ++i < length; ) { |
2291 | Â | matchIndexes.push( i ); |
2292 | Â | } |
2293 | Â | return matchIndexes; |
2294 | Â | } ) |
2295 | Â | } |
2296 | Â | }; |
2297 | Â | |
2298 | Â | Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ]; |
2299 | Â | |
2300 | Â | // Add button/input type pseudos |
2301 | Â | for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { |
2302 | Â | Expr.pseudos[ i ] = createInputPseudo( i ); |
2303 | Â | } |
2304 | Â | for ( i in { submit: true, reset: true } ) { |
2305 | Â | Expr.pseudos[ i ] = createButtonPseudo( i ); |
2306 | Â | } |
2307 | Â | |
2308 | Â | // Easy API for creating new setFilters |
2309 | Â | function setFilters() {} |
2310 | Â | setFilters.prototype = Expr.filters = Expr.pseudos; |
2311 | Â | Expr.setFilters = new setFilters(); |
2312 | Â | |
2313 | Â | tokenize = Sizzle.tokenize = function( selector, parseOnly ) { |
2314 | Â | var matched, match, tokens, type, |
2315 | Â | soFar, groups, preFilters, |
2316 | Â | cached = tokenCache[ selector + " " ]; |
2317 | Â | |
2318 | Â | if ( cached ) { |
2319 | Â | return parseOnly ? 0 : cached.slice( 0 ); |
2320 | Â | } |
2321 | Â | |
2322 | Â | soFar = selector; |
2323 | Â | groups = []; |
2324 | Â | preFilters = Expr.preFilter; |
2325 | Â | |
2326 | Â | while ( soFar ) { |
2327 | Â | |
2328 | Â | // Comma and first run |
2329 | Â | if ( !matched || ( match = rcomma.exec( soFar ) ) ) { |
2330 | Â | if ( match ) { |
2331 | Â | |
2332 | Â | // Don't consume trailing commas as valid |
2333 | Â | soFar = soFar.slice( match[ 0 ].length ) || soFar; |
2334 | Â | } |
2335 | Â | groups.push( ( tokens = [] ) ); |
2336 | Â | } |
2337 | Â | |
2338 | Â | matched = false; |
2339 | Â | |
2340 | Â | // Combinators |
2341 | Â | if ( ( match = rcombinators.exec( soFar ) ) ) { |
2342 | Â | matched = match.shift(); |
2343 | Â | tokens.push( { |
2344 | Â | value: matched, |
2345 | Â | |
2346 | Â | // Cast descendant combinators to space |
2347 | Â | type: match[ 0 ].replace( rtrim, " " ) |
2348 | Â | } ); |
2349 | Â | soFar = soFar.slice( matched.length ); |
2350 | Â | } |
2351 | Â | |
2352 | Â | // Filters |
2353 | Â | for ( type in Expr.filter ) { |
2354 | Â | if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] || |
2355 | Â | ( match = preFilters[ type ]( match ) ) ) ) { |
2356 | Â | matched = match.shift(); |
2357 | Â | tokens.push( { |
2358 | Â | value: matched, |
2359 | Â | type: type, |
2360 | Â | matches: match |
2361 | Â | } ); |
2362 | Â | soFar = soFar.slice( matched.length ); |
2363 | Â | } |
2364 | Â | } |
2365 | Â | |
2366 | Â | if ( !matched ) { |
2367 | Â | break; |
2368 | Â | } |
2369 | Â | } |
2370 | Â | |
2371 | Â | // Return the length of the invalid excess |
2372 | Â | // if we're just parsing |
2373 | Â | // Otherwise, throw an error or return tokens |
2374 | Â | return parseOnly ? |
2375 | Â | soFar.length : |
2376 | Â | soFar ? |
2377 | Â | Sizzle.error( selector ) : |
2378 | Â | |
2379 | Â | // Cache the tokens |
2380 | Â | tokenCache( selector, groups ).slice( 0 ); |
2381 | Â | }; |
2382 | Â | |
2383 | Â | function toSelector( tokens ) { |
2384 | Â | var i = 0, |
2385 | Â | len = tokens.length, |
2386 | Â | selector = ""; |
2387 | Â | for ( ; i < len; i++ ) { |
2388 | Â | selector += tokens[ i ].value; |
2389 | Â | } |
2390 | Â | return selector; |
2391 | Â | } |
2392 | Â | |
2393 | Â | function addCombinator( matcher, combinator, base ) { |
2394 | Â | var dir = combinator.dir, |
2395 | Â | skip = combinator.next, |
2396 | Â | key = skip || dir, |
2397 | Â | checkNonElements = base && key === "parentNode", |
2398 | Â | doneName = done++; |
2399 | Â | |
2400 | Â | return combinator.first ? |
2401 | Â | |
2402 | Â | // Check against closest ancestor/preceding element |
2403 | Â | function( elem, context, xml ) { |
2404 | Â | while ( ( elem = elem[ dir ] ) ) { |
2405 | Â | if ( elem.nodeType === 1 || checkNonElements ) { |
2406 | Â | return matcher( elem, context, xml ); |
2407 | Â | } |
2408 | Â | } |
2409 | Â | return false; |
2410 | Â | } : |
2411 | Â | |
2412 | Â | // Check against all ancestor/preceding elements |
2413 | Â | function( elem, context, xml ) { |
2414 | Â | var oldCache, uniqueCache, outerCache, |
2415 | Â | newCache = [ dirruns, doneName ]; |
2416 | Â | |
2417 | Â | // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching |
2418 | Â | if ( xml ) { |
2419 | Â | while ( ( elem = elem[ dir ] ) ) { |
2420 | Â | if ( elem.nodeType === 1 || checkNonElements ) { |
2421 | Â | if ( matcher( elem, context, xml ) ) { |
2422 | Â | return true; |
2423 | Â | } |
2424 | Â | } |
2425 | Â | } |
2426 | Â | } else { |
2427 | Â | while ( ( elem = elem[ dir ] ) ) { |
2428 | Â | if ( elem.nodeType === 1 || checkNonElements ) { |
2429 | Â | outerCache = elem[ expando ] || ( elem[ expando ] = {} ); |
2430 | Â | |
2431 | Â | // Support: IE <9 only |
2432 | Â | // Defend against cloned attroperties (jQuery gh-1709) |
2433 | Â | uniqueCache = outerCache[ elem.uniqueID ] || |
2434 | Â | ( outerCache[ elem.uniqueID ] = {} ); |
2435 | Â | |
2436 | Â | if ( skip && skip === elem.nodeName.toLowerCase() ) { |
2437 | Â | elem = elem[ dir ] || elem; |
2438 | Â | } else if ( ( oldCache = uniqueCache[ key ] ) && |
2439 | Â | oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { |
2440 | Â | |
2441 | Â | // Assign to newCache so results back-propagate to previous elements |
2442 | Â | return ( newCache[ 2 ] = oldCache[ 2 ] ); |
2443 | Â | } else { |
2444 | Â | |
2445 | Â | // Reuse newcache so results back-propagate to previous elements |
2446 | Â | uniqueCache[ key ] = newCache; |
2447 | Â | |
2448 | Â | // A match means we're done; a fail means we have to keep checking |
2449 | Â | if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) { |
2450 | Â | return true; |
2451 | Â | } |
2452 | Â | } |
2453 | Â | } |
2454 | Â | } |
2455 | Â | } |
2456 | Â | return false; |
2457 | Â | }; |
2458 | Â | } |
2459 | Â | |
2460 | Â | function elementMatcher( matchers ) { |
2461 | Â | return matchers.length > 1 ? |
2462 | Â | function( elem, context, xml ) { |
2463 | Â | var i = matchers.length; |
2464 | Â | while ( i-- ) { |
2465 | Â | if ( !matchers[ i ]( elem, context, xml ) ) { |
2466 | Â | return false; |
2467 | Â | } |
2468 | Â | } |
2469 | Â | return true; |
2470 | Â | } : |
2471 | Â | matchers[ 0 ]; |
2472 | Â | } |
2473 | Â | |
2474 | Â | function multipleContexts( selector, contexts, results ) { |
2475 | Â | var i = 0, |
2476 | Â | len = contexts.length; |
2477 | Â | for ( ; i < len; i++ ) { |
2478 | Â | Sizzle( selector, contexts[ i ], results ); |
2479 | Â | } |
2480 | Â | return results; |
2481 | Â | } |
2482 | Â | |
2483 | Â | function condense( unmatched, map, filter, context, xml ) { |
2484 | Â | var elem, |
2485 | Â | newUnmatched = [], |
2486 | Â | i = 0, |
2487 | Â | len = unmatched.length, |
2488 | Â | mapped = map != null; |
2489 | Â | |
2490 | Â | for ( ; i < len; i++ ) { |
2491 | Â | if ( ( elem = unmatched[ i ] ) ) { |
2492 | Â | if ( !filter || filter( elem, context, xml ) ) { |
2493 | Â | newUnmatched.push( elem ); |
2494 | Â | if ( mapped ) { |
2495 | Â | map.push( i ); |
2496 | Â | } |
2497 | Â | } |
2498 | Â | } |
2499 | Â | } |
2500 | Â | |
2501 | Â | return newUnmatched; |
2502 | Â | } |
2503 | Â | |
2504 | Â | function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { |
2505 | Â | if ( postFilter && !postFilter[ expando ] ) { |
2506 | Â | postFilter = setMatcher( postFilter ); |
2507 | Â | } |
2508 | Â | if ( postFinder && !postFinder[ expando ] ) { |
2509 | Â | postFinder = setMatcher( postFinder, postSelector ); |
2510 | Â | } |
2511 | Â | return markFunction( function( seed, results, context, xml ) { |
2512 | Â | var temp, i, elem, |
2513 | Â | preMap = [], |
2514 | Â | postMap = [], |
2515 | Â | preexisting = results.length, |
2516 | Â | |
2517 | Â | // Get initial elements from seed or context |
2518 | Â | elems = seed || multipleContexts( |
2519 | Â | selector || "*", |
2520 | Â | context.nodeType ? [ context ] : context, |
2521 | Â | [] |
2522 | Â | ), |
2523 | Â | |
2524 | Â | // Prefilter to get matcher input, preserving a map for seed-results synchronization |
2525 | Â | matcherIn = preFilter && ( seed || !selector ) ? |
2526 | Â | condense( elems, preMap, preFilter, context, xml ) : |
2527 | Â | elems, |
2528 | Â | |
2529 | Â | matcherOut = matcher ? |
2530 | Â | |
2531 | Â | // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, |
2532 | Â | postFinder || ( seed ? preFilter : preexisting || postFilter ) ? |
2533 | Â | |
2534 | Â | // ...intermediate processing is necessary |
2535 | Â | [] : |
2536 | Â | |
2537 | Â | // ...otherwise use results directly |
2538 | Â | results : |
2539 | Â | matcherIn; |
2540 | Â | |
2541 | Â | // Find primary matches |
2542 | Â | if ( matcher ) { |
2543 | Â | matcher( matcherIn, matcherOut, context, xml ); |
2544 | Â | } |
2545 | Â | |
2546 | Â | // Apply postFilter |
2547 | Â | if ( postFilter ) { |
2548 | Â | temp = condense( matcherOut, postMap ); |
2549 | Â | postFilter( temp, [], context, xml ); |
2550 | Â | |
2551 | Â | // Un-match failing elements by moving them back to matcherIn |
2552 | Â | i = temp.length; |
2553 | Â | while ( i-- ) { |
2554 | Â | if ( ( elem = temp[ i ] ) ) { |
2555 | Â | matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem ); |
2556 | Â | } |
2557 | Â | } |
2558 | Â | } |
2559 | Â | |
2560 | Â | if ( seed ) { |
2561 | Â | if ( postFinder || preFilter ) { |
2562 | Â | if ( postFinder ) { |
2563 | Â | |
2564 | Â | // Get the final matcherOut by condensing this intermediate into postFinder contexts |
2565 | Â | temp = []; |
2566 | Â | i = matcherOut.length; |
2567 | Â | while ( i-- ) { |
2568 | Â | if ( ( elem = matcherOut[ i ] ) ) { |
2569 | Â | |
2570 | Â | // Restore matcherIn since elem is not yet a final match |
2571 | Â | temp.push( ( matcherIn[ i ] = elem ) ); |
2572 | Â | } |
2573 | Â | } |
2574 | Â | postFinder( null, ( matcherOut = [] ), temp, xml ); |
2575 | Â | } |
2576 | Â | |
2577 | Â | // Move matched elements from seed to results to keep them synchronized |
2578 | Â | i = matcherOut.length; |
2579 | Â | while ( i-- ) { |
2580 | Â | if ( ( elem = matcherOut[ i ] ) && |
2581 | Â | ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) { |
2582 | Â | |
2583 | Â | seed[ temp ] = !( results[ temp ] = elem ); |
2584 | Â | } |
2585 | Â | } |
2586 | Â | } |
2587 | Â | |
2588 | Â | // Add elements to results, through postFinder if defined |
2589 | Â | } else { |
2590 | Â | matcherOut = condense( |
2591 | Â | matcherOut === results ? |
2592 | Â | matcherOut.splice( preexisting, matcherOut.length ) : |
2593 | Â | matcherOut |
2594 | Â | ); |
2595 | Â | if ( postFinder ) { |
2596 | Â | postFinder( null, results, matcherOut, xml ); |
2597 | Â | } else { |
2598 | Â | push.apply( results, matcherOut ); |
2599 | Â | } |
2600 | Â | } |
2601 | Â | } ); |
2602 | Â | } |
2603 | Â | |
2604 | Â | function matcherFromTokens( tokens ) { |
2605 | Â | var checkContext, matcher, j, |
2606 | Â | len = tokens.length, |
2607 | Â | leadingRelative = Expr.relative[ tokens[ 0 ].type ], |
2608 | Â | implicitRelative = leadingRelative || Expr.relative[ " " ], |
2609 | Â | i = leadingRelative ? 1 : 0, |
2610 | Â | |
2611 | Â | // The foundational matcher ensures that elements are reachable from top-level context(s) |
2612 | Â | matchContext = addCombinator( function( elem ) { |
2613 | Â | return elem === checkContext; |
2614 | Â | }, implicitRelative, true ), |
2615 | Â | matchAnyContext = addCombinator( function( elem ) { |
2616 | Â | return indexOf( checkContext, elem ) > -1; |
2617 | Â | }, implicitRelative, true ), |
2618 | Â | matchers = [ function( elem, context, xml ) { |
2619 | Â | var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( |
2620 | Â | ( checkContext = context ).nodeType ? |
2621 | Â | matchContext( elem, context, xml ) : |
2622 | Â | matchAnyContext( elem, context, xml ) ); |
2623 | Â | |
2624 | Â | // Avoid hanging onto element (issue #299) |
2625 | Â | checkContext = null; |
2626 | Â | return ret; |
2627 | Â | } ]; |
2628 | Â | |
2629 | Â | for ( ; i < len; i++ ) { |
2630 | Â | if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) { |
2631 | Â | matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ]; |
2632 | Â | } else { |
2633 | Â | matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches ); |
2634 | Â | |
2635 | Â | // Return special upon seeing a positional matcher |
2636 | Â | if ( matcher[ expando ] ) { |
2637 | Â | |
2638 | Â | // Find the next relative operator (if any) for proper handling |
2639 | Â | j = ++i; |
2640 | Â | for ( ; j < len; j++ ) { |
2641 | Â | if ( Expr.relative[ tokens[ j ].type ] ) { |
2642 | Â | break; |
2643 | Â | } |
2644 | Â | } |
2645 | Â | return setMatcher( |
2646 | Â | i > 1 && elementMatcher( matchers ), |
2647 | Â | i > 1 && toSelector( |
2648 | Â | |
2649 | Â | // If the preceding token was a descendant combinator, insert an implicit any-element `*` |
2650 | Â | tokens |
2651 | Â | .slice( 0, i - 1 ) |
2652 | Â | .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } ) |
2653 | Â | ).replace( rtrim, "$1" ), |
2654 | Â | matcher, |
2655 | Â | i < j && matcherFromTokens( tokens.slice( i, j ) ), |
2656 | Â | j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ), |
2657 | Â | j < len && toSelector( tokens ) |
2658 | Â | ); |
2659 | Â | } |
2660 | Â | matchers.push( matcher ); |
2661 | Â | } |
2662 | Â | } |
2663 | Â | |
2664 | Â | return elementMatcher( matchers ); |
2665 | Â | } |
2666 | Â | |
2667 | Â | function matcherFromGroupMatchers( elementMatchers, setMatchers ) { |
2668 | Â | var bySet = setMatchers.length > 0, |
2669 | Â | byElement = elementMatchers.length > 0, |
2670 | Â | superMatcher = function( seed, context, xml, results, outermost ) { |
2671 | Â | var elem, j, matcher, |
2672 | Â | matchedCount = 0, |
2673 | Â | i = "0", |
2674 | Â | unmatched = seed && [], |
2675 | Â | setMatched = [], |
2676 | Â | contextBackup = outermostContext, |
2677 | Â | |
2678 | Â | // We must always have either seed elements or outermost context |
2679 | Â | elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ), |
2680 | Â | |
2681 | Â | // Use integer dirruns iff this is the outermost matcher |
2682 | Â | dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ), |
2683 | Â | len = elems.length; |
2684 | Â | |
2685 | Â | if ( outermost ) { |
2686 | Â | |
2687 | Â | // Support: IE 11+, Edge 17 - 18+ |
2688 | Â | // IE/Edge sometimes throw a "Permission denied" error when strict-comparing |
2689 | Â | // two documents; shallow comparisons work. |
2690 | Â | // eslint-disable-next-line eqeqeq |
2691 | Â | outermostContext = context == document || context || outermost; |
2692 | Â | } |
2693 | Â | |
2694 | Â | // Add elements passing elementMatchers directly to results |
2695 | Â | // Support: IE<9, Safari |
2696 | Â | // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id |
2697 | Â | for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) { |
2698 | Â | if ( byElement && elem ) { |
2699 | Â | j = 0; |
2700 | Â | |
2701 | Â | // Support: IE 11+, Edge 17 - 18+ |
2702 | Â | // IE/Edge sometimes throw a "Permission denied" error when strict-comparing |
2703 | Â | // two documents; shallow comparisons work. |
2704 | Â | // eslint-disable-next-line eqeqeq |
2705 | Â | if ( !context && elem.ownerDocument != document ) { |
2706 | Â | setDocument( elem ); |
2707 | Â | xml = !documentIsHTML; |
2708 | Â | } |
2709 | Â | while ( ( matcher = elementMatchers[ j++ ] ) ) { |
2710 | Â | if ( matcher( elem, context || document, xml ) ) { |
2711 | Â | results.push( elem ); |
2712 | Â | break; |
2713 | Â | } |
2714 | Â | } |
2715 | Â | if ( outermost ) { |
2716 | Â | dirruns = dirrunsUnique; |
2717 | Â | } |
2718 | Â | } |
2719 | Â | |
2720 | Â | // Track unmatched elements for set filters |
2721 | Â | if ( bySet ) { |
2722 | Â | |
2723 | Â | // They will have gone through all possible matchers |
2724 | Â | if ( ( elem = !matcher && elem ) ) { |
2725 | Â | matchedCount--; |
2726 | Â | } |
2727 | Â | |
2728 | Â | // Lengthen the array for every element, matched or not |
2729 | Â | if ( seed ) { |
2730 | Â | unmatched.push( elem ); |
2731 | Â | } |
2732 | Â | } |
2733 | Â | } |
2734 | Â | |
2735 | Â | // `i` is now the count of elements visited above, and adding it to `matchedCount` |
2736 | Â | // makes the latter nonnegative. |
2737 | Â | matchedCount += i; |
2738 | Â | |
2739 | Â | // Apply set filters to unmatched elements |
2740 | Â | // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` |
2741 | Â | // equals `i`), unless we didn't visit _any_ elements in the above loop because we have |
2742 | Â | // no element matchers and no seed. |
2743 | Â | // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that |
2744 | Â | // case, which will result in a "00" `matchedCount` that differs from `i` but is also |
2745 | Â | // numerically zero. |
2746 | Â | if ( bySet && i !== matchedCount ) { |
2747 | Â | j = 0; |
2748 | Â | while ( ( matcher = setMatchers[ j++ ] ) ) { |
2749 | Â | matcher( unmatched, setMatched, context, xml ); |
2750 | Â | } |
2751 | Â | |
2752 | Â | if ( seed ) { |
2753 | Â | |
2754 | Â | // Reintegrate element matches to eliminate the need for sorting |
2755 | Â | if ( matchedCount > 0 ) { |
2756 | Â | while ( i-- ) { |
2757 | Â | if ( !( unmatched[ i ] || setMatched[ i ] ) ) { |
2758 | Â | setMatched[ i ] = pop.call( results ); |
2759 | Â | } |
2760 | Â | } |
2761 | Â | } |
2762 | Â | |
2763 | Â | // Discard index placeholder values to get only actual matches |
2764 | Â | setMatched = condense( setMatched ); |
2765 | Â | } |
2766 | Â | |
2767 | Â | // Add matches to results |
2768 | Â | push.apply( results, setMatched ); |
2769 | Â | |
2770 | Â | // Seedless set matches succeeding multiple successful matchers stipulate sorting |
2771 | Â | if ( outermost && !seed && setMatched.length > 0 && |
2772 | Â | ( matchedCount + setMatchers.length ) > 1 ) { |
2773 | Â | |
2774 | Â | Sizzle.uniqueSort( results ); |
2775 | Â | } |
2776 | Â | } |
2777 | Â | |
2778 | Â | // Override manipulation of globals by nested matchers |
2779 | Â | if ( outermost ) { |
2780 | Â | dirruns = dirrunsUnique; |
2781 | Â | outermostContext = contextBackup; |
2782 | Â | } |
2783 | Â | |
2784 | Â | return unmatched; |
2785 | Â | }; |
2786 | Â | |
2787 | Â | return bySet ? |
2788 | Â | markFunction( superMatcher ) : |
2789 | Â | superMatcher; |
2790 | Â | } |
2791 | Â | |
2792 | Â | compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { |
2793 | Â | var i, |
2794 | Â | setMatchers = [], |
2795 | Â | elementMatchers = [], |
2796 | Â | cached = compilerCache[ selector + " " ]; |
2797 | Â | |
2798 | Â | if ( !cached ) { |
2799 | Â | |
2800 | Â | // Generate a function of recursive functions that can be used to check each element |
2801 | Â | if ( !match ) { |
2802 | Â | match = tokenize( selector ); |
2803 | Â | } |
2804 | Â | i = match.length; |
2805 | Â | while ( i-- ) { |
2806 | Â | cached = matcherFromTokens( match[ i ] ); |
2807 | Â | if ( cached[ expando ] ) { |
2808 | Â | setMatchers.push( cached ); |
2809 | Â | } else { |
2810 | Â | elementMatchers.push( cached ); |
2811 | Â | } |
2812 | Â | } |
2813 | Â | |
2814 | Â | // Cache the compiled function |
2815 | Â | cached = compilerCache( |
2816 | Â | selector, |
2817 | Â | matcherFromGroupMatchers( elementMatchers, setMatchers ) |
2818 | Â | ); |
2819 | Â | |
2820 | Â | // Save selector and tokenization |
2821 | Â | cached.selector = selector; |
2822 | Â | } |
2823 | Â | return cached; |
2824 | Â | }; |
2825 | Â | |
2826 | Â | /** |
2827 | Â | * A low-level selection function that works with Sizzle's compiled |
2828 | Â | * selector functions |
2829 | Â | * @param {String|Function} selector A selector or a pre-compiled |
2830 | Â | * selector function built with Sizzle.compile |
2831 | Â | * @param {Element} context |
2832 | Â | * @param {Array} [results] |
2833 | Â | * @param {Array} [seed] A set of elements to match against |
2834 | Â | */ |
2835 | Â | select = Sizzle.select = function( selector, context, results, seed ) { |
2836 | Â | var i, tokens, token, type, find, |
2837 | Â | compiled = typeof selector === "function" && selector, |
2838 | Â | match = !seed && tokenize( ( selector = compiled.selector || selector ) ); |
2839 | Â | |
2840 | Â | results = results || []; |
2841 | Â | |
2842 | Â | // Try to minimize operations if there is only one selector in the list and no seed |
2843 | Â | // (the latter of which guarantees us context) |
2844 | Â | if ( match.length === 1 ) { |
2845 | Â | |
2846 | Â | // Reduce context if the leading compound selector is an ID |
2847 | Â | tokens = match[ 0 ] = match[ 0 ].slice( 0 ); |
2848 | Â | if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" && |
2849 | Â | context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) { |
2850 | Â | |
2851 | Â | context = ( Expr.find[ "ID" ]( token.matches[ 0 ] |
2852 | Â | .replace( runescape, funescape ), context ) || [] )[ 0 ]; |
2853 | Â | if ( !context ) { |
2854 | Â | return results; |
2855 | Â | |
2856 | Â | // Precompiled matchers will still verify ancestry, so step up a level |
2857 | Â | } else if ( compiled ) { |
2858 | Â | context = context.parentNode; |
2859 | Â | } |
2860 | Â | |
2861 | Â | selector = selector.slice( tokens.shift().value.length ); |
2862 | Â | } |
2863 | Â | |
2864 | Â | // Fetch a seed set for right-to-left matching |
2865 | Â | i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length; |
2866 | Â | while ( i-- ) { |
2867 | Â | token = tokens[ i ]; |
2868 | Â | |
2869 | Â | // Abort if we hit a combinator |
2870 | Â | if ( Expr.relative[ ( type = token.type ) ] ) { |
2871 | Â | break; |
2872 | Â | } |
2873 | Â | if ( ( find = Expr.find[ type ] ) ) { |
2874 | Â | |
2875 | Â | // Search, expanding context for leading sibling combinators |
2876 | Â | if ( ( seed = find( |
2877 | Â | token.matches[ 0 ].replace( runescape, funescape ), |
2878 | Â | rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) || |
2879 | Â | context |
2880 | Â | ) ) ) { |
2881 | Â | |
2882 | Â | // If seed is empty or no tokens remain, we can return early |
2883 | Â | tokens.splice( i, 1 ); |
2884 | Â | selector = seed.length && toSelector( tokens ); |
2885 | Â | if ( !selector ) { |
2886 | Â | push.apply( results, seed ); |
2887 | Â | return results; |
2888 | Â | } |
2889 | Â | |
2890 | Â | break; |
2891 | Â | } |
2892 | Â | } |
2893 | Â | } |
2894 | Â | } |
2895 | Â | |
2896 | Â | // Compile and execute a filtering function if one is not provided |
2897 | Â | // Provide `match` to avoid retokenization if we modified the selector above |
2898 | Â | ( compiled || compile( selector, match ) )( |
2899 | Â | seed, |
2900 | Â | context, |
2901 | Â | !documentIsHTML, |
2902 | Â | results, |
2903 | Â | !context || rsibling.test( selector ) && testContext( context.parentNode ) || context |
2904 | Â | ); |
2905 | Â | return results; |
2906 | Â | }; |
2907 | Â | |
2908 | Â | // One-time assignments |
2909 | Â | |
2910 | Â | // Sort stability |
2911 | Â | support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando; |
2912 | Â | |
2913 | Â | // Support: Chrome 14-35+ |
2914 | Â | // Always assume duplicates if they aren't passed to the comparison function |
2915 | Â | support.detectDuplicates = !!hasDuplicate; |
2916 | Â | |
2917 | Â | // Initialize against the default document |
2918 | Â | setDocument(); |
2919 | Â | |
2920 | Â | // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) |
2921 | Â | // Detached nodes confoundingly follow *each other* |
2922 | Â | support.sortDetached = assert( function( el ) { |
2923 | Â | |
2924 | Â | // Should return 1, but returns 4 (following) |
2925 | Â | return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1; |
2926 | Â | } ); |
2927 | Â | |
2928 | Â | // Support: IE<8 |
2929 | Â | // Prevent attribute/property "interpolation" |
2930 | Â | // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx |
2931 | Â | if ( !assert( function( el ) { |
2932 | Â | el.innerHTML = "<a href='#'></a>"; |
2933 | Â | return el.firstChild.getAttribute( "href" ) === "#"; |
2934 | Â | } ) ) { |
2935 | Â | addHandle( "type|href|height|width", function( elem, name, isXML ) { |
2936 | Â | if ( !isXML ) { |
2937 | Â | return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); |
2938 | Â | } |
2939 | Â | } ); |
2940 | Â | } |
2941 | Â | |
2942 | Â | // Support: IE<9 |
2943 | Â | // Use defaultValue in place of getAttribute("value") |
2944 | Â | if ( !support.attributes || !assert( function( el ) { |
2945 | Â | el.innerHTML = "<input/>"; |
2946 | Â | el.firstChild.setAttribute( "value", "" ); |
2947 | Â | return el.firstChild.getAttribute( "value" ) === ""; |
2948 | Â | } ) ) { |
2949 | Â | addHandle( "value", function( elem, _name, isXML ) { |
2950 | Â | if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { |
2951 | Â | return elem.defaultValue; |
2952 | Â | } |
2953 | Â | } ); |
2954 | Â | } |
2955 | Â | |
2956 | Â | // Support: IE<9 |
2957 | Â | // Use getAttributeNode to fetch booleans when getAttribute lies |
2958 | Â | if ( !assert( function( el ) { |
2959 | Â | return el.getAttribute( "disabled" ) == null; |
2960 | Â | } ) ) { |
2961 | Â | addHandle( booleans, function( elem, name, isXML ) { |
2962 | Â | var val; |
2963 | Â | if ( !isXML ) { |
2964 | Â | return elem[ name ] === true ? name.toLowerCase() : |
2965 | Â | ( val = elem.getAttributeNode( name ) ) && val.specified ? |
2966 | Â | val.value : |
2967 | Â | null; |
2968 | Â | } |
2969 | Â | } ); |
2970 | Â | } |
2971 | Â | |
2972 | Â | return Sizzle; |
2973 | Â | |
2974 | Â | } )( window ); |
2975 | Â | |
2976 | Â | |
2977 | Â | |
2978 | Â | jQuery.find = Sizzle; |
2979 | Â | jQuery.expr = Sizzle.selectors; |
2980 | Â | |
2981 | Â | // Deprecated |
2982 | Â | jQuery.expr[ ":" ] = jQuery.expr.pseudos; |
2983 | Â | jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; |
2984 | Â | jQuery.text = Sizzle.getText; |
2985 | Â | jQuery.isXMLDoc = Sizzle.isXML; |
2986 | Â | jQuery.contains = Sizzle.contains; |
2987 | Â | jQuery.escapeSelector = Sizzle.escape; |
2988 | Â | |
2989 | Â | |
2990 | Â | |
2991 | Â | |
2992 | Â | var dir = function( elem, dir, until ) { |
2993 | Â | var matched = [], |
2994 | Â | truncate = until !== undefined; |
2995 | Â | |
2996 | Â | while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { |
2997 | Â | if ( elem.nodeType === 1 ) { |
2998 | Â | if ( truncate && jQuery( elem ).is( until ) ) { |
2999 | Â | break; |
3000 | Â | } |
3001 | Â | matched.push( elem ); |
3002 | Â | } |
3003 | Â | } |
3004 | Â | return matched; |
3005 | Â | }; |
3006 | Â | |
3007 | Â | |
3008 | Â | var siblings = function( n, elem ) { |
3009 | Â | var matched = []; |
3010 | Â | |
3011 | Â | for ( ; n; n = n.nextSibling ) { |
3012 | Â | if ( n.nodeType === 1 && n !== elem ) { |
3013 | Â | matched.push( n ); |
3014 | Â | } |
3015 | Â | } |
3016 | Â | |
3017 | Â | return matched; |
3018 | Â | }; |
3019 | Â | |
3020 | Â | |
3021 | Â | var rneedsContext = jQuery.expr.match.needsContext; |
3022 | Â | |
3023 | Â | |
3024 | Â | |
3025 | Â | function nodeName( elem, name ) { |
3026 | Â | |
3027 | Â | return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); |
3028 | Â | |
3029 | Â | }; |
3030 | Â | var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); |
3031 | Â | |
3032 | Â | |
3033 | Â | |
3034 | Â | // Implement the identical functionality for filter and not |
3035 | Â | function winnow( elements, qualifier, not ) { |
3036 | Â | if ( isFunction( qualifier ) ) { |
3037 | Â | return jQuery.grep( elements, function( elem, i ) { |
3038 | Â | return !!qualifier.call( elem, i, elem ) !== not; |
3039 | Â | } ); |
3040 | Â | } |
3041 | Â | |
3042 | Â | // Single element |
3043 | Â | if ( qualifier.nodeType ) { |
3044 | Â | return jQuery.grep( elements, function( elem ) { |
3045 | Â | return ( elem === qualifier ) !== not; |
3046 | Â | } ); |
3047 | Â | } |
3048 | Â | |
3049 | Â | // Arraylike of elements (jQuery, arguments, Array) |
3050 | Â | if ( typeof qualifier !== "string" ) { |
3051 | Â | return jQuery.grep( elements, function( elem ) { |
3052 | Â | return ( indexOf.call( qualifier, elem ) > -1 ) !== not; |
3053 | Â | } ); |
3054 | Â | } |
3055 | Â | |
3056 | Â | // Filtered directly for both simple and complex selectors |
3057 | Â | return jQuery.filter( qualifier, elements, not ); |
3058 | Â | } |
3059 | Â | |
3060 | Â | jQuery.filter = function( expr, elems, not ) { |
3061 | Â | var elem = elems[ 0 ]; |
3062 | Â | |
3063 | Â | if ( not ) { |
3064 | Â | expr = ":not(" + expr + ")"; |
3065 | Â | } |
3066 | Â | |
3067 | Â | if ( elems.length === 1 && elem.nodeType === 1 ) { |
3068 | Â | return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : []; |
3069 | Â | } |
3070 | Â | |
3071 | Â | return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { |
3072 | Â | return elem.nodeType === 1; |
3073 | Â | } ) ); |
3074 | Â | }; |
3075 | Â | |
3076 | Â | jQuery.fn.extend( { |
3077 | Â | find: function( selector ) { |
3078 | Â | var i, ret, |
3079 | Â | len = this.length, |
3080 | Â | self = this; |
3081 | Â | |
3082 | Â | if ( typeof selector !== "string" ) { |
3083 | Â | return this.pushStack( jQuery( selector ).filter( function() { |
3084 | Â | for ( i = 0; i < len; i++ ) { |
3085 | Â | if ( jQuery.contains( self[ i ], this ) ) { |
3086 | Â | return true; |
3087 | Â | } |
3088 | Â | } |
3089 | Â | } ) ); |
3090 | Â | } |
3091 | Â | |
3092 | Â | ret = this.pushStack( [] ); |
3093 | Â | |
3094 | Â | for ( i = 0; i < len; i++ ) { |
3095 | Â | jQuery.find( selector, self[ i ], ret ); |
3096 | Â | } |
3097 | Â | |
3098 | Â | return len > 1 ? jQuery.uniqueSort( ret ) : ret; |
3099 | Â | }, |
3100 | Â | filter: function( selector ) { |
3101 | Â | return this.pushStack( winnow( this, selector || [], false ) ); |
3102 | Â | }, |
3103 | Â | not: function( selector ) { |
3104 | Â | return this.pushStack( winnow( this, selector || [], true ) ); |
3105 | Â | }, |
3106 | Â | is: function( selector ) { |
3107 | Â | return !!winnow( |
3108 | Â | this, |
3109 | Â | |
3110 | Â | // If this is a positional/relative selector, check membership in the returned set |
3111 | Â | // so $("p:first").is("p:last") won't return true for a doc with two "p". |
3112 | Â | typeof selector === "string" && rneedsContext.test( selector ) ? |
3113 | Â | jQuery( selector ) : |
3114 | Â | selector || [], |
3115 | Â | false |
3116 | Â | ).length; |
3117 | Â | } |
3118 | Â | } ); |
3119 | Â | |
3120 | Â | |
3121 | Â | // Initialize a jQuery object |
3122 | Â | |
3123 | Â | |
3124 | Â | // A central reference to the root jQuery(document) |
3125 | Â | var rootjQuery, |
3126 | Â | |
3127 | Â | // A simple way to check for HTML strings |
3128 | Â | // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) |
3129 | Â | // Strict HTML recognition (#11290: must start with <) |
3130 | Â | // Shortcut simple #id case for speed |
3131 | Â | rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, |
3132 | Â | |
3133 | Â | init = jQuery.fn.init = function( selector, context, root ) { |
3134 | Â | var match, elem; |
3135 | Â | |
3136 | Â | // HANDLE: $(""), $(null), $(undefined), $(false) |
3137 | Â | if ( !selector ) { |
3138 | Â | return this; |
3139 | Â | } |
3140 | Â | |
3141 | Â | // Method init() accepts an alternate rootjQuery |
3142 | Â | // so migrate can support jQuery.sub (gh-2101) |
3143 | Â | root = root || rootjQuery; |
3144 | Â | |
3145 | Â | // Handle HTML strings |
3146 | Â | if ( typeof selector === "string" ) { |
3147 | Â | if ( selector[ 0 ] === "<" && |
3148 | Â | selector[ selector.length - 1 ] === ">" && |
3149 | Â | selector.length >= 3 ) { |
3150 | Â | |
3151 | Â | // Assume that strings that start and end with <> are HTML and skip the regex check |
3152 | Â | match = [ null, selector, null ]; |
3153 | Â | |
3154 | Â | } else { |
3155 | Â | match = rquickExpr.exec( selector ); |
3156 | Â | } |
3157 | Â | |
3158 | Â | // Match html or make sure no context is specified for #id |
3159 | Â | if ( match && ( match[ 1 ] || !context ) ) { |
3160 | Â | |
3161 | Â | // HANDLE: $(html) -> $(array) |
3162 | Â | if ( match[ 1 ] ) { |
3163 | Â | context = context instanceof jQuery ? context[ 0 ] : context; |
3164 | Â | |
3165 | Â | // Option to run scripts is true for back-compat |
3166 | Â | // Intentionally let the error be thrown if parseHTML is not present |
3167 | Â | jQuery.merge( this, jQuery.parseHTML( |
3168 | Â | match[ 1 ], |
3169 | Â | context && context.nodeType ? context.ownerDocument || context : document, |
3170 | Â | true |
3171 | Â | ) ); |
3172 | Â | |
3173 | Â | // HANDLE: $(html, props) |
3174 | Â | if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { |
3175 | Â | for ( match in context ) { |
3176 | Â | |
3177 | Â | // Properties of context are called as methods if possible |
3178 | Â | if ( isFunction( this[ match ] ) ) { |
3179 | Â | this[ match ]( context[ match ] ); |
3180 | Â | |
3181 | Â | // ...and otherwise set as attributes |
3182 | Â | } else { |
3183 | Â | this.attr( match, context[ match ] ); |
3184 | Â | } |
3185 | Â | } |
3186 | Â | } |
3187 | Â | |
3188 | Â | return this; |
3189 | Â | |
3190 | Â | // HANDLE: $(#id) |
3191 | Â | } else { |
3192 | Â | elem = document.getElementById( match[ 2 ] ); |
3193 | Â | |
3194 | Â | if ( elem ) { |
3195 | Â | |
3196 | Â | // Inject the element directly into the jQuery object |
3197 | Â | this[ 0 ] = elem; |
3198 | Â | this.length = 1; |
3199 | Â | } |
3200 | Â | return this; |
3201 | Â | } |
3202 | Â | |
3203 | Â | // HANDLE: $(expr, $(...)) |
3204 | Â | } else if ( !context || context.jquery ) { |
3205 | Â | return ( context || root ).find( selector ); |
3206 | Â | |
3207 | Â | // HANDLE: $(expr, context) |
3208 | Â | // (which is just equivalent to: $(context).find(expr) |
3209 | Â | } else { |
3210 | Â | return this.constructor( context ).find( selector ); |
3211 | Â | } |
3212 | Â | |
3213 | Â | // HANDLE: $(DOMElement) |
3214 | Â | } else if ( selector.nodeType ) { |
3215 | Â | this[ 0 ] = selector; |
3216 | Â | this.length = 1; |
3217 | Â | return this; |
3218 | Â | |
3219 | Â | // HANDLE: $(function) |
3220 | Â | // Shortcut for document ready |
3221 | Â | } else if ( isFunction( selector ) ) { |
3222 | Â | return root.ready !== undefined ? |
3223 | Â | root.ready( selector ) : |
3224 | Â | |
3225 | Â | // Execute immediately if ready is not present |
3226 | Â | selector( jQuery ); |
3227 | Â | } |
3228 | Â | |
3229 | Â | return jQuery.makeArray( selector, this ); |
3230 | Â | }; |
3231 | Â | |
3232 | Â | // Give the init function the jQuery prototype for later instantiation |
3233 | Â | init.prototype = jQuery.fn; |
3234 | Â | |
3235 | Â | // Initialize central reference |
3236 | Â | rootjQuery = jQuery( document ); |
3237 | Â | |
3238 | Â | |
3239 | Â | var rparentsprev = /^(?:parents|prev(?:Until|All))/, |
3240 | Â | |
3241 | Â | // Methods guaranteed to produce a unique set when starting from a unique set |
3242 | Â | guaranteedUnique = { |
3243 | Â | children: true, |
3244 | Â | contents: true, |
3245 | Â | next: true, |
3246 | Â | prev: true |
3247 | Â | }; |
3248 | Â | |
3249 | Â | jQuery.fn.extend( { |
3250 | Â | has: function( target ) { |
3251 | Â | var targets = jQuery( target, this ), |
3252 | Â | l = targets.length; |
3253 | Â | |
3254 | Â | return this.filter( function() { |
3255 | Â | var i = 0; |
3256 | Â | for ( ; i < l; i++ ) { |
3257 | Â | if ( jQuery.contains( this, targets[ i ] ) ) { |
3258 | Â | return true; |
3259 | Â | } |
3260 | Â | } |
3261 | Â | } ); |
3262 | Â | }, |
3263 | Â | |
3264 | Â | closest: function( selectors, context ) { |
3265 | Â | var cur, |
3266 | Â | i = 0, |
3267 | Â | l = this.length, |
3268 | Â | matched = [], |
3269 | Â | targets = typeof selectors !== "string" && jQuery( selectors ); |
3270 | Â | |
3271 | Â | // Positional selectors never match, since there's no _selection_ context |
3272 | Â | if ( !rneedsContext.test( selectors ) ) { |
3273 | Â | for ( ; i < l; i++ ) { |
3274 | Â | for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { |
3275 | Â | |
3276 | Â | // Always skip document fragments |
3277 | Â | if ( cur.nodeType < 11 && ( targets ? |
3278 | Â | targets.index( cur ) > -1 : |
3279 | Â | |
3280 | Â | // Don't pass non-elements to Sizzle |
3281 | Â | cur.nodeType === 1 && |
3282 | Â | jQuery.find.matchesSelector( cur, selectors ) ) ) { |
3283 | Â | |
3284 | Â | matched.push( cur ); |
3285 | Â | break; |
3286 | Â | } |
3287 | Â | } |
3288 | Â | } |
3289 | Â | } |
3290 | Â | |
3291 | Â | return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); |
3292 | Â | }, |
3293 | Â | |
3294 | Â | // Determine the position of an element within the set |
3295 | Â | index: function( elem ) { |
3296 | Â | |
3297 | Â | // No argument, return index in parent |
3298 | Â | if ( !elem ) { |
3299 | Â | return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; |
3300 | Â | } |
3301 | Â | |
3302 | Â | // Index in selector |
3303 | Â | if ( typeof elem === "string" ) { |
3304 | Â | return indexOf.call( jQuery( elem ), this[ 0 ] ); |
3305 | Â | } |
3306 | Â | |
3307 | Â | // Locate the position of the desired element |
3308 | Â | return indexOf.call( this, |
3309 | Â | |
3310 | Â | // If it receives a jQuery object, the first element is used |
3311 | Â | elem.jquery ? elem[ 0 ] : elem |
3312 | Â | ); |
3313 | Â | }, |
3314 | Â | |
3315 | Â | add: function( selector, context ) { |
3316 | Â | return this.pushStack( |
3317 | Â | jQuery.uniqueSort( |
3318 | Â | jQuery.merge( this.get(), jQuery( selector, context ) ) |
3319 | Â | ) |
3320 | Â | ); |
3321 | Â | }, |
3322 | Â | |
3323 | Â | addBack: function( selector ) { |
3324 | Â | return this.add( selector == null ? |
3325 | Â | this.prevObject : this.prevObject.filter( selector ) |
3326 | Â | ); |
3327 | Â | } |
3328 | Â | } ); |
3329 | Â | |
3330 | Â | function sibling( cur, dir ) { |
3331 | Â | while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} |
3332 | Â | return cur; |
3333 | Â | } |
3334 | Â | |
3335 | Â | jQuery.each( { |
3336 | Â | parent: function( elem ) { |
3337 | Â | var parent = elem.parentNode; |
3338 | Â | return parent && parent.nodeType !== 11 ? parent : null; |
3339 | Â | }, |
3340 | Â | parents: function( elem ) { |
3341 | Â | return dir( elem, "parentNode" ); |
3342 | Â | }, |
3343 | Â | parentsUntil: function( elem, _i, until ) { |
3344 | Â | return dir( elem, "parentNode", until ); |
3345 | Â | }, |
3346 | Â | next: function( elem ) { |
3347 | Â | return sibling( elem, "nextSibling" ); |
3348 | Â | }, |
3349 | Â | prev: function( elem ) { |
3350 | Â | return sibling( elem, "previousSibling" ); |
3351 | Â | }, |
3352 | Â | nextAll: function( elem ) { |
3353 | Â | return dir( elem, "nextSibling" ); |
3354 | Â | }, |
3355 | Â | prevAll: function( elem ) { |
3356 | Â | return dir( elem, "previousSibling" ); |
3357 | Â | }, |
3358 | Â | nextUntil: function( elem, _i, until ) { |
3359 | Â | return dir( elem, "nextSibling", until ); |
3360 | Â | }, |
3361 | Â | prevUntil: function( elem, _i, until ) { |
3362 | Â | return dir( elem, "previousSibling", until ); |
3363 | Â | }, |
3364 | Â | siblings: function( elem ) { |
3365 | Â | return siblings( ( elem.parentNode || {} ).firstChild, elem ); |
3366 | Â | }, |
3367 | Â | children: function( elem ) { |
3368 | Â | return siblings( elem.firstChild ); |
3369 | Â | }, |
3370 | Â | contents: function( elem ) { |
3371 | Â | if ( elem.contentDocument != null && |
3372 | Â | |
3373 | Â | // Support: IE 11+ |
3374 | Â | // <object> elements with no `data` attribute has an object |
3375 | Â | // `contentDocument` with a `null` prototype. |
3376 | Â | getProto( elem.contentDocument ) ) { |
3377 | Â | |
3378 | Â | return elem.contentDocument; |
3379 | Â | } |
3380 | Â | |
3381 | Â | // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only |
3382 | Â | // Treat the template element as a regular one in browsers that |
3383 | Â | // don't support it. |
3384 | Â | if ( nodeName( elem, "template" ) ) { |
3385 | Â | elem = elem.content || elem; |
3386 | Â | } |
3387 | Â | |
3388 | Â | return jQuery.merge( [], elem.childNodes ); |
3389 | Â | } |
3390 | Â | }, function( name, fn ) { |
3391 | Â | jQuery.fn[ name ] = function( until, selector ) { |
3392 | Â | var matched = jQuery.map( this, fn, until ); |
3393 | Â | |
3394 | Â | if ( name.slice( -5 ) !== "Until" ) { |
3395 | Â | selector = until; |
3396 | Â | } |
3397 | Â | |
3398 | Â | if ( selector && typeof selector === "string" ) { |
3399 | Â | matched = jQuery.filter( selector, matched ); |
3400 | Â | } |
3401 | Â | |
3402 | Â | if ( this.length > 1 ) { |
3403 | Â | |
3404 | Â | // Remove duplicates |
3405 | Â | if ( !guaranteedUnique[ name ] ) { |
3406 | Â | jQuery.uniqueSort( matched ); |
3407 | Â | } |
3408 | Â | |
3409 | Â | // Reverse order for parents* and prev-derivatives |
3410 | Â | if ( rparentsprev.test( name ) ) { |
3411 | Â | matched.reverse(); |
3412 | Â | } |
3413 | Â | } |
3414 | Â | |
3415 | Â | return this.pushStack( matched ); |
3416 | Â | }; |
3417 | Â | } ); |
3418 | Â | var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g ); |
3419 | Â | |
3420 | Â | |
3421 | Â | |
3422 | Â | // Convert String-formatted options into Object-formatted ones |
3423 | Â | function createOptions( options ) { |
3424 | Â | var object = {}; |
3425 | Â | jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) { |
3426 | Â | object[ flag ] = true; |
3427 | Â | } ); |
3428 | Â | return object; |
3429 | Â | } |
3430 | Â | |
3431 | Â | /* |
3432 | Â | * Create a callback list using the following parameters: |
3433 | Â | * |
3434 | Â | * options: an optional list of space-separated options that will change how |
3435 | Â | * the callback list behaves or a more traditional option object |
3436 | Â | * |
3437 | Â | * By default a callback list will act like an event callback list and can be |
3438 | Â | * "fired" multiple times. |
3439 | Â | * |
3440 | Â | * Possible options: |
3441 | Â | * |
3442 | Â | * once: will ensure the callback list can only be fired once (like a Deferred) |
3443 | Â | * |
3444 | Â | * memory: will keep track of previous values and will call any callback added |
3445 | Â | * after the list has been fired right away with the latest "memorized" |
3446 | Â | * values (like a Deferred) |
3447 | Â | * |
3448 | Â | * unique: will ensure a callback can only be added once (no duplicate in the list) |
3449 | Â | * |
3450 | Â | * stopOnFalse: interrupt callings when a callback returns false |
3451 | Â | * |
3452 | Â | */ |
3453 | Â | jQuery.Callbacks = function( options ) { |
3454 | Â | |
3455 | Â | // Convert options from String-formatted to Object-formatted if needed |
3456 | Â | // (we check in cache first) |
3457 | Â | options = typeof options === "string" ? |
3458 | Â | createOptions( options ) : |
3459 | Â | jQuery.extend( {}, options ); |
3460 | Â | |
3461 | Â | var // Flag to know if list is currently firing |
3462 | Â | firing, |
3463 | Â | |
3464 | Â | // Last fire value for non-forgettable lists |
3465 | Â | memory, |
3466 | Â | |
3467 | Â | // Flag to know if list was already fired |
3468 | Â | fired, |
3469 | Â | |
3470 | Â | // Flag to prevent firing |
3471 | Â | locked, |
3472 | Â | |
3473 | Â | // Actual callback list |
3474 | Â | list = [], |
3475 | Â | |
3476 | Â | // Queue of execution data for repeatable lists |
3477 | Â | queue = [], |
3478 | Â | |
3479 | Â | // Index of currently firing callback (modified by add/remove as needed) |
3480 | Â | firingIndex = -1, |
3481 | Â | |
3482 | Â | // Fire callbacks |
3483 | Â | fire = function() { |
3484 | Â | |
3485 | Â | // Enforce single-firing |
3486 | Â | locked = locked || options.once; |
3487 | Â | |
3488 | Â | // Execute callbacks for all pending executions, |
3489 | Â | // respecting firingIndex overrides and runtime changes |
3490 | Â | fired = firing = true; |
3491 | Â | for ( ; queue.length; firingIndex = -1 ) { |
3492 | Â | memory = queue.shift(); |
3493 | Â | while ( ++firingIndex < list.length ) { |
3494 | Â | |
3495 | Â | // Run callback and check for early termination |
3496 | Â | if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && |
3497 | Â | options.stopOnFalse ) { |
3498 | Â | |
3499 | Â | // Jump to end and forget the data so .add doesn't re-fire |
3500 | Â | firingIndex = list.length; |
3501 | Â | memory = false; |
3502 | Â | } |
3503 | Â | } |
3504 | Â | } |
3505 | Â | |
3506 | Â | // Forget the data if we're done with it |
3507 | Â | if ( !options.memory ) { |
3508 | Â | memory = false; |
3509 | Â | } |
3510 | Â | |
3511 | Â | firing = false; |
3512 | Â | |
3513 | Â | // Clean up if we're done firing for good |
3514 | Â | if ( locked ) { |
3515 | Â | |
3516 | Â | // Keep an empty list if we have data for future add calls |
3517 | Â | if ( memory ) { |
3518 | Â | list = []; |
3519 | Â | |
3520 | Â | // Otherwise, this object is spent |
3521 | Â | } else { |
3522 | Â | list = ""; |
3523 | Â | } |
3524 | Â | } |
3525 | Â | }, |
3526 | Â | |
3527 | Â | // Actual Callbacks object |
3528 | Â | self = { |
3529 | Â | |
3530 | Â | // Add a callback or a collection of callbacks to the list |
3531 | Â | add: function() { |
3532 | Â | if ( list ) { |
3533 | Â | |
3534 | Â | // If we have memory from a past run, we should fire after adding |
3535 | Â | if ( memory && !firing ) { |
3536 | Â | firingIndex = list.length - 1; |
3537 | Â | queue.push( memory ); |
3538 | Â | } |
3539 | Â | |
3540 | Â | ( function add( args ) { |
3541 | Â | jQuery.each( args, function( _, arg ) { |
3542 | Â | if ( isFunction( arg ) ) { |
3543 | Â | if ( !options.unique || !self.has( arg ) ) { |
3544 | Â | list.push( arg ); |
3545 | Â | } |
3546 | Â | } else if ( arg && arg.length && toType( arg ) !== "string" ) { |
3547 | Â | |
3548 | Â | // Inspect recursively |
3549 | Â | add( arg ); |
3550 | Â | } |
3551 | Â | } ); |
3552 | Â | } )( arguments ); |
3553 | Â | |
3554 | Â | if ( memory && !firing ) { |
3555 | Â | fire(); |
3556 | Â | } |
3557 | Â | } |
3558 | Â | return this; |
3559 | Â | }, |
3560 | Â | |
3561 | Â | // Remove a callback from the list |
3562 | Â | remove: function() { |
3563 | Â | jQuery.each( arguments, function( _, arg ) { |
3564 | Â | var index; |
3565 | Â | while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { |
3566 | Â | list.splice( index, 1 ); |
3567 | Â | |
3568 | Â | // Handle firing indexes |
3569 | Â | if ( index <= firingIndex ) { |
3570 | Â | firingIndex--; |
3571 | Â | } |
3572 | Â | } |
3573 | Â | } ); |
3574 | Â | return this; |
3575 | Â | }, |
3576 | Â | |
3577 | Â | // Check if a given callback is in the list. |
3578 | Â | // If no argument is given, return whether or not list has callbacks attached. |
3579 | Â | has: function( fn ) { |
3580 | Â | return fn ? |
3581 | Â | jQuery.inArray( fn, list ) > -1 : |
3582 | Â | list.length > 0; |
3583 | Â | }, |
3584 | Â | |
3585 | Â | // Remove all callbacks from the list |
3586 | Â | empty: function() { |
3587 | Â | if ( list ) { |
3588 | Â | list = []; |
3589 | Â | } |
3590 | Â | return this; |
3591 | Â | }, |
3592 | Â | |
3593 | Â | // Disable .fire and .add |
3594 | Â | // Abort any current/pending executions |
3595 | Â | // Clear all callbacks and values |
3596 | Â | disable: function() { |
3597 | Â | locked = queue = []; |
3598 | Â | list = memory = ""; |
3599 | Â | return this; |
3600 | Â | }, |
3601 | Â | disabled: function() { |
3602 | Â | return !list; |
3603 | Â | }, |
3604 | Â | |
3605 | Â | // Disable .fire |
3606 | Â | // Also disable .add unless we have memory (since it would have no effect) |
3607 | Â | // Abort any pending executions |
3608 | Â | lock: function() { |
3609 | Â | locked = queue = []; |
3610 | Â | if ( !memory && !firing ) { |
3611 | Â | list = memory = ""; |
3612 | Â | } |
3613 | Â | return this; |
3614 | Â | }, |
3615 | Â | locked: function() { |
3616 | Â | return !!locked; |
3617 | Â | }, |
3618 | Â | |
3619 | Â | // Call all callbacks with the given context and arguments |
3620 | Â | fireWith: function( context, args ) { |
3621 | Â | if ( !locked ) { |
3622 | Â | args = args || []; |
3623 | Â | args = [ context, args.slice ? args.slice() : args ]; |
3624 | Â | queue.push( args ); |
3625 | Â | if ( !firing ) { |
3626 | Â | fire(); |
3627 | Â | } |
3628 | Â | } |
3629 | Â | return this; |
3630 | Â | }, |
3631 | Â | |
3632 | Â | // Call all the callbacks with the given arguments |
3633 | Â | fire: function() { |
3634 | Â | self.fireWith( this, arguments ); |
3635 | Â | return this; |
3636 | Â | }, |
3637 | Â | |
3638 | Â | // To know if the callbacks have already been called at least once |
3639 | Â | fired: function() { |
3640 | Â | return !!fired; |
3641 | Â | } |
3642 | Â | }; |
3643 | Â | |
3644 | Â | return self; |
3645 | Â | }; |
3646 | Â | |
3647 | Â | |
3648 | Â | function Identity( v ) { |
3649 | Â | return v; |
3650 | Â | } |
3651 | Â | function Thrower( ex ) { |
3652 | Â | throw ex; |
3653 | Â | } |
3654 | Â | |
3655 | Â | function adoptValue( value, resolve, reject, noValue ) { |
3656 | Â | var method; |
3657 | Â | |
3658 | Â | try { |
3659 | Â | |
3660 | Â | // Check for promise aspect first to privilege synchronous behavior |
3661 | Â | if ( value && isFunction( ( method = value.promise ) ) ) { |
3662 | Â | method.call( value ).done( resolve ).fail( reject ); |
3663 | Â | |
3664 | Â | // Other thenables |
3665 | Â | } else if ( value && isFunction( ( method = value.then ) ) ) { |
3666 | Â | method.call( value, resolve, reject ); |
3667 | Â | |
3668 | Â | // Other non-thenables |
3669 | Â | } else { |
3670 | Â | |
3671 | Â | // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: |
3672 | Â | // * false: [ value ].slice( 0 ) => resolve( value ) |
3673 | Â | // * true: [ value ].slice( 1 ) => resolve() |
3674 | Â | resolve.apply( undefined, [ value ].slice( noValue ) ); |
3675 | Â | } |
3676 | Â | |
3677 | Â | // For Promises/A+, convert exceptions into rejections |
3678 | Â | // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in |
3679 | Â | // Deferred#then to conditionally suppress rejection. |
3680 | Â | } catch ( value ) { |
3681 | Â | |
3682 | Â | // Support: Android 4.0 only |
3683 | Â | // Strict mode functions invoked without .call/.apply get global-object context |
3684 | Â | reject.apply( undefined, [ value ] ); |
3685 | Â | } |
3686 | Â | } |
3687 | Â | |
3688 | Â | jQuery.extend( { |
3689 | Â | |
3690 | Â | Deferred: function( func ) { |
3691 | Â | var tuples = [ |
3692 | Â | |
3693 | Â | // action, add listener, callbacks, |
3694 | Â | // ... .then handlers, argument index, [final state] |
3695 | Â | [ "notify", "progress", jQuery.Callbacks( "memory" ), |
3696 | Â | jQuery.Callbacks( "memory" ), 2 ], |
3697 | Â | [ "resolve", "done", jQuery.Callbacks( "once memory" ), |
3698 | Â | jQuery.Callbacks( "once memory" ), 0, "resolved" ], |
3699 | Â | [ "reject", "fail", jQuery.Callbacks( "once memory" ), |
3700 | Â | jQuery.Callbacks( "once memory" ), 1, "rejected" ] |
3701 | Â | ], |
3702 | Â | state = "pending", |
3703 | Â | promise = { |
3704 | Â | state: function() { |
3705 | Â | return state; |
3706 | Â | }, |
3707 | Â | always: function() { |
3708 | Â | deferred.done( arguments ).fail( arguments ); |
3709 | Â | return this; |
3710 | Â | }, |
3711 | Â | "catch": function( fn ) { |
3712 | Â | return promise.then( null, fn ); |
3713 | Â | }, |
3714 | Â | |
3715 | Â | // Keep pipe for back-compat |
3716 | Â | pipe: function( /* fnDone, fnFail, fnProgress */ ) { |
3717 | Â | var fns = arguments; |
3718 | Â | |
3719 | Â | return jQuery.Deferred( function( newDefer ) { |
3720 | Â | jQuery.each( tuples, function( _i, tuple ) { |
3721 | Â | |
3722 | Â | // Map tuples (progress, done, fail) to arguments (done, fail, progress) |
3723 | Â | var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; |
3724 | Â | |
3725 | Â | // deferred.progress(function() { bind to newDefer or newDefer.notify }) |
3726 | Â | // deferred.done(function() { bind to newDefer or newDefer.resolve }) |
3727 | Â | // deferred.fail(function() { bind to newDefer or newDefer.reject }) |
3728 | Â | deferred[ tuple[ 1 ] ]( function() { |
3729 | Â | var returned = fn && fn.apply( this, arguments ); |
3730 | Â | if ( returned && isFunction( returned.promise ) ) { |
3731 | Â | returned.promise() |
3732 | Â | .progress( newDefer.notify ) |
3733 | Â | .done( newDefer.resolve ) |
3734 | Â | .fail( newDefer.reject ); |
3735 | Â | } else { |
3736 | Â | newDefer[ tuple[ 0 ] + "With" ]( |
3737 | Â | this, |
3738 | Â | fn ? [ returned ] : arguments |
3739 | Â | ); |
3740 | Â | } |
3741 | Â | } ); |
3742 | Â | } ); |
3743 | Â | fns = null; |
3744 | Â | } ).promise(); |
3745 | Â | }, |
3746 | Â | then: function( onFulfilled, onRejected, onProgress ) { |
3747 | Â | var maxDepth = 0; |
3748 | Â | function resolve( depth, deferred, handler, special ) { |
3749 | Â | return function() { |
3750 | Â | var that = this, |
3751 | Â | args = arguments, |
3752 | Â | mightThrow = function() { |
3753 | Â | var returned, then; |
3754 | Â | |
3755 | Â | // Support: Promises/A+ section 2.3.3.3.3 |
3756 | Â | // https://promisesaplus.com/#point-59 |
3757 | Â | // Ignore double-resolution attempts |
3758 | Â | if ( depth < maxDepth ) { |
3759 | Â | return; |
3760 | Â | } |
3761 | Â | |
3762 | Â | returned = handler.apply( that, args ); |
3763 | Â | |
3764 | Â | // Support: Promises/A+ section 2.3.1 |
3765 | Â | // https://promisesaplus.com/#point-48 |
3766 | Â | if ( returned === deferred.promise() ) { |
3767 | Â | throw new TypeError( "Thenable self-resolution" ); |
3768 | Â | } |
3769 | Â | |
3770 | Â | // Support: Promises/A+ sections 2.3.3.1, 3.5 |
3771 | Â | // https://promisesaplus.com/#point-54 |
3772 | Â | // https://promisesaplus.com/#point-75 |
3773 | Â | // Retrieve `then` only once |
3774 | Â | then = returned && |
3775 | Â | |
3776 | Â | // Support: Promises/A+ section 2.3.4 |
3777 | Â | // https://promisesaplus.com/#point-64 |
3778 | Â | // Only check objects and functions for thenability |
3779 | Â | ( typeof returned === "object" || |
3780 | Â | typeof returned === "function" ) && |
3781 | Â | returned.then; |
3782 | Â | |
3783 | Â | // Handle a returned thenable |
3784 | Â | if ( isFunction( then ) ) { |
3785 | Â | |
3786 | Â | // Special processors (notify) just wait for resolution |
3787 | Â | if ( special ) { |
3788 | Â | then.call( |
3789 | Â | returned, |
3790 | Â | resolve( maxDepth, deferred, Identity, special ), |
3791 | Â | resolve( maxDepth, deferred, Thrower, special ) |
3792 | Â | ); |
3793 | Â | |
3794 | Â | // Normal processors (resolve) also hook into progress |
3795 | Â | } else { |
3796 | Â | |
3797 | Â | // ...and disregard older resolution values |
3798 | Â | maxDepth++; |
3799 | Â | |
3800 | Â | then.call( |
3801 | Â | returned, |
3802 | Â | resolve( maxDepth, deferred, Identity, special ), |
3803 | Â | resolve( maxDepth, deferred, Thrower, special ), |
3804 | Â | resolve( maxDepth, deferred, Identity, |
3805 | Â | deferred.notifyWith ) |
3806 | Â | ); |
3807 | Â | } |
3808 | Â | |
3809 | Â | // Handle all other returned values |
3810 | Â | } else { |
3811 | Â | |
3812 | Â | // Only substitute handlers pass on context |
3813 | Â | // and multiple values (non-spec behavior) |
3814 | Â | if ( handler !== Identity ) { |
3815 | Â | that = undefined; |
3816 | Â | args = [ returned ]; |
3817 | Â | } |
3818 | Â | |
3819 | Â | // Process the value(s) |
3820 | Â | // Default process is resolve |
3821 | Â | ( special || deferred.resolveWith )( that, args ); |
3822 | Â | } |
3823 | Â | }, |
3824 | Â | |
3825 | Â | // Only normal processors (resolve) catch and reject exceptions |
3826 | Â | process = special ? |
3827 | Â | mightThrow : |
3828 | Â | function() { |
3829 | Â | try { |
3830 | Â | mightThrow(); |
3831 | Â | } catch ( e ) { |
3832 | Â | |
3833 | Â | if ( jQuery.Deferred.exceptionHook ) { |
3834 | Â | jQuery.Deferred.exceptionHook( e, |
3835 | Â | process.stackTrace ); |
3836 | Â | } |
3837 | Â | |
3838 | Â | // Support: Promises/A+ section 2.3.3.3.4.1 |
3839 | Â | // https://promisesaplus.com/#point-61 |
3840 | Â | // Ignore post-resolution exceptions |
3841 | Â | if ( depth + 1 >= maxDepth ) { |
3842 | Â | |
3843 | Â | // Only substitute handlers pass on context |
3844 | Â | // and multiple values (non-spec behavior) |
3845 | Â | if ( handler !== Thrower ) { |
3846 | Â | that = undefined; |
3847 | Â | args = [ e ]; |
3848 | Â | } |
3849 | Â | |
3850 | Â | deferred.rejectWith( that, args ); |
3851 | Â | } |
3852 | Â | } |
3853 | Â | }; |
3854 | Â | |
3855 | Â | // Support: Promises/A+ section 2.3.3.3.1 |
3856 | Â | // https://promisesaplus.com/#point-57 |
3857 | Â | // Re-resolve promises immediately to dodge false rejection from |
3858 | Â | // subsequent errors |
3859 | Â | if ( depth ) { |
3860 | Â | process(); |
3861 | Â | } else { |
3862 | Â | |
3863 | Â | // Call an optional hook to record the stack, in case of exception |
3864 | Â | // since it's otherwise lost when execution goes async |
3865 | Â | if ( jQuery.Deferred.getStackHook ) { |
3866 | Â | process.stackTrace = jQuery.Deferred.getStackHook(); |
3867 | Â | } |
3868 | Â | window.setTimeout( process ); |
3869 | Â | } |
3870 | Â | }; |
3871 | Â | } |
3872 | Â | |
3873 | Â | return jQuery.Deferred( function( newDefer ) { |
3874 | Â | |
3875 | Â | // progress_handlers.add( ... ) |
3876 | Â | tuples[ 0 ][ 3 ].add( |
3877 | Â | resolve( |
3878 | Â | 0, |
3879 | Â | newDefer, |
3880 | Â | isFunction( onProgress ) ? |
3881 | Â | onProgress : |
3882 | Â | Identity, |
3883 | Â | newDefer.notifyWith |
3884 | Â | ) |
3885 | Â | ); |
3886 | Â | |
3887 | Â | // fulfilled_handlers.add( ... ) |
3888 | Â | tuples[ 1 ][ 3 ].add( |
3889 | Â | resolve( |
3890 | Â | 0, |
3891 | Â | newDefer, |
3892 | Â | isFunction( onFulfilled ) ? |
3893 | Â | onFulfilled : |
3894 | Â | Identity |
3895 | Â | ) |
3896 | Â | ); |
3897 | Â | |
3898 | Â | // rejected_handlers.add( ... ) |
3899 | Â | tuples[ 2 ][ 3 ].add( |
3900 | Â | resolve( |
3901 | Â | 0, |
3902 | Â | newDefer, |
3903 | Â | isFunction( onRejected ) ? |
3904 | Â | onRejected : |
3905 | Â | Thrower |
3906 | Â | ) |
3907 | Â | ); |
3908 | Â | } ).promise(); |
3909 | Â | }, |
3910 | Â | |
3911 | Â | // Get a promise for this deferred |
3912 | Â | // If obj is provided, the promise aspect is added to the object |
3913 | Â | promise: function( obj ) { |
3914 | Â | return obj != null ? jQuery.extend( obj, promise ) : promise; |
3915 | Â | } |
3916 | Â | }, |
3917 | Â | deferred = {}; |
3918 | Â | |
3919 | Â | // Add list-specific methods |
3920 | Â | jQuery.each( tuples, function( i, tuple ) { |
3921 | Â | var list = tuple[ 2 ], |
3922 | Â | stateString = tuple[ 5 ]; |
3923 | Â | |
3924 | Â | // promise.progress = list.add |
3925 | Â | // promise.done = list.add |
3926 | Â | // promise.fail = list.add |
3927 | Â | promise[ tuple[ 1 ] ] = list.add; |
3928 | Â | |
3929 | Â | // Handle state |
3930 | Â | if ( stateString ) { |
3931 | Â | list.add( |
3932 | Â | function() { |
3933 | Â | |
3934 | Â | // state = "resolved" (i.e., fulfilled) |
3935 | Â | // state = "rejected" |
3936 | Â | state = stateString; |
3937 | Â | }, |
3938 | Â | |
3939 | Â | // rejected_callbacks.disable |
3940 | Â | // fulfilled_callbacks.disable |
3941 | Â | tuples[ 3 - i ][ 2 ].disable, |
3942 | Â | |
3943 | Â | // rejected_handlers.disable |
3944 | Â | // fulfilled_handlers.disable |
3945 | Â | tuples[ 3 - i ][ 3 ].disable, |
3946 | Â | |
3947 | Â | // progress_callbacks.lock |
3948 | Â | tuples[ 0 ][ 2 ].lock, |
3949 | Â | |
3950 | Â | // progress_handlers.lock |
3951 | Â | tuples[ 0 ][ 3 ].lock |
3952 | Â | ); |
3953 | Â | } |
3954 | Â | |
3955 | Â | // progress_handlers.fire |
3956 | Â | // fulfilled_handlers.fire |
3957 | Â | // rejected_handlers.fire |
3958 | Â | list.add( tuple[ 3 ].fire ); |
3959 | Â | |
3960 | Â | // deferred.notify = function() { deferred.notifyWith(...) } |
3961 | Â | // deferred.resolve = function() { deferred.resolveWith(...) } |
3962 | Â | // deferred.reject = function() { deferred.rejectWith(...) } |
3963 | Â | deferred[ tuple[ 0 ] ] = function() { |
3964 | Â | deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments ); |
3965 | Â | return this; |
3966 | Â | }; |
3967 | Â | |
3968 | Â | // deferred.notifyWith = list.fireWith |
3969 | Â | // deferred.resolveWith = list.fireWith |
3970 | Â | // deferred.rejectWith = list.fireWith |
3971 | Â | deferred[ tuple[ 0 ] + "With" ] = list.fireWith; |
3972 | Â | } ); |
3973 | Â | |
3974 | Â | // Make the deferred a promise |
3975 | Â | promise.promise( deferred ); |
3976 | Â | |
3977 | Â | // Call given func if any |
3978 | Â | if ( func ) { |
3979 | Â | func.call( deferred, deferred ); |
3980 | Â | } |
3981 | Â | |
3982 | Â | // All done! |
3983 | Â | return deferred; |
3984 | Â | }, |
3985 | Â | |
3986 | Â | // Deferred helper |
3987 | Â | when: function( singleValue ) { |
3988 | Â | var |
3989 | Â | |
3990 | Â | // count of uncompleted subordinates |
3991 | Â | remaining = arguments.length, |
3992 | Â | |
3993 | Â | // count of unprocessed arguments |
3994 | Â | i = remaining, |
3995 | Â | |
3996 | Â | // subordinate fulfillment data |
3997 | Â | resolveContexts = Array( i ), |
3998 | Â | resolveValues = slice.call( arguments ), |
3999 | Â | |
4000 | Â | // the master Deferred |
4001 | Â | master = jQuery.Deferred(), |
4002 | Â | |
4003 | Â | // subordinate callback factory |
4004 | Â | updateFunc = function( i ) { |
4005 | Â | return function( value ) { |
4006 | Â | resolveContexts[ i ] = this; |
4007 | Â | resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; |
4008 | Â | if ( !( --remaining ) ) { |
4009 | Â | master.resolveWith( resolveContexts, resolveValues ); |
4010 | Â | } |
4011 | Â | }; |
4012 | Â | }; |
4013 | Â | |
4014 | Â | // Single- and empty arguments are adopted like Promise.resolve |
4015 | Â | if ( remaining <= 1 ) { |
4016 | Â | adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject, |
4017 | Â | !remaining ); |
4018 | Â | |
4019 | Â | // Use .then() to unwrap secondary thenables (cf. gh-3000) |
4020 | Â | if ( master.state() === "pending" || |
4021 | Â | isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { |
4022 | Â | |
4023 | Â | return master.then(); |
4024 | Â | } |
4025 | Â | } |
4026 | Â | |
4027 | Â | // Multiple arguments are aggregated like Promise.all array elements |
4028 | Â | while ( i-- ) { |
4029 | Â | adoptValue( resolveValues[ i ], updateFunc( i ), master.reject ); |
4030 | Â | } |
4031 | Â | |
4032 | Â | return master.promise(); |
4033 | Â | } |
4034 | Â | } ); |
4035 | Â | |
4036 | Â | |
4037 | Â | // These usually indicate a programmer mistake during development, |
4038 | Â | // warn about them ASAP rather than swallowing them by default. |
4039 | Â | var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; |
4040 | Â | |
4041 | Â | jQuery.Deferred.exceptionHook = function( error, stack ) { |
4042 | Â | |
4043 | Â | // Support: IE 8 - 9 only |
4044 | Â | // Console exists when dev tools are open, which can happen at any time |
4045 | Â | if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { |
4046 | Â | window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack ); |
4047 | Â | } |
4048 | Â | }; |
4049 | Â | |
4050 | Â | |
4051 | Â | |
4052 | Â | |
4053 | Â | jQuery.readyException = function( error ) { |
4054 | Â | window.setTimeout( function() { |
4055 | Â | throw error; |
4056 | Â | } ); |
4057 | Â | }; |
4058 | Â | |
4059 | Â | |
4060 | Â | |
4061 | Â | |
4062 | Â | // The deferred used on DOM ready |
4063 | Â | var readyList = jQuery.Deferred(); |
4064 | Â | |
4065 | Â | jQuery.fn.ready = function( fn ) { |
4066 | Â | |
4067 | Â | readyList |
4068 | Â | .then( fn ) |
4069 | Â | |
4070 | Â | // Wrap jQuery.readyException in a function so that the lookup |
4071 | Â | // happens at the time of error handling instead of callback |
4072 | Â | // registration. |
4073 | Â | .catch( function( error ) { |
4074 | Â | jQuery.readyException( error ); |
4075 | Â | } ); |
4076 | Â | |
4077 | Â | return this; |
4078 | Â | }; |
4079 | Â | |
4080 | Â | jQuery.extend( { |
4081 | Â | |
4082 | Â | // Is the DOM ready to be used? Set to true once it occurs. |
4083 | Â | isReady: false, |
4084 | Â | |
4085 | Â | // A counter to track how many items to wait for before |
4086 | Â | // the ready event fires. See #6781 |
4087 | Â | readyWait: 1, |
4088 | Â | |
4089 | Â | // Handle when the DOM is ready |
4090 | Â | ready: function( wait ) { |
4091 | Â | |
4092 | Â | // Abort if there are pending holds or we're already ready |
4093 | Â | if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { |
4094 | Â | return; |
4095 | Â | } |
4096 | Â | |
4097 | Â | // Remember that the DOM is ready |
4098 | Â | jQuery.isReady = true; |
4099 | Â | |
4100 | Â | // If a normal DOM Ready event fired, decrement, and wait if need be |
4101 | Â | if ( wait !== true && --jQuery.readyWait > 0 ) { |
4102 | Â | return; |
4103 | Â | } |
4104 | Â | |
4105 | Â | // If there are functions bound, to execute |
4106 | Â | readyList.resolveWith( document, [ jQuery ] ); |
4107 | Â | } |
4108 | Â | } ); |
4109 | Â | |
4110 | Â | jQuery.ready.then = readyList.then; |
4111 | Â | |
4112 | Â | // The ready event handler and self cleanup method |
4113 | Â | function completed() { |
4114 | Â | document.removeEventListener( "DOMContentLoaded", completed ); |
4115 | Â | window.removeEventListener( "load", completed ); |
4116 | Â | jQuery.ready(); |
4117 | Â | } |
4118 | Â | |
4119 | Â | // Catch cases where $(document).ready() is called |
4120 | Â | // after the browser event has already occurred. |
4121 | Â | // Support: IE <=9 - 10 only |
4122 | Â | // Older IE sometimes signals "interactive" too soon |
4123 | Â | if ( document.readyState === "complete" || |
4124 | Â | ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { |
4125 | Â | |
4126 | Â | // Handle it asynchronously to allow scripts the opportunity to delay ready |
4127 | Â | window.setTimeout( jQuery.ready ); |
4128 | Â | |
4129 | Â | } else { |
4130 | Â | |
4131 | Â | // Use the handy event callback |
4132 | Â | document.addEventListener( "DOMContentLoaded", completed ); |
4133 | Â | |
4134 | Â | // A fallback to window.onload, that will always work |
4135 | Â | window.addEventListener( "load", completed ); |
4136 | Â | } |
4137 | Â | |
4138 | Â | |
4139 | Â | |
4140 | Â | |
4141 | Â | // Multifunctional method to get and set values of a collection |
4142 | Â | // The value/s can optionally be executed if it's a function |
4143 | Â | var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { |
4144 | Â | var i = 0, |
4145 | Â | len = elems.length, |
4146 | Â | bulk = key == null; |
4147 | Â | |
4148 | Â | // Sets many values |
4149 | Â | if ( toType( key ) === "object" ) { |
4150 | Â | chainable = true; |
4151 | Â | for ( i in key ) { |
4152 | Â | access( elems, fn, i, key[ i ], true, emptyGet, raw ); |
4153 | Â | } |
4154 | Â | |
4155 | Â | // Sets one value |
4156 | Â | } else if ( value !== undefined ) { |
4157 | Â | chainable = true; |
4158 | Â | |
4159 | Â | if ( !isFunction( value ) ) { |
4160 | Â | raw = true; |
4161 | Â | } |
4162 | Â | |
4163 | Â | if ( bulk ) { |
4164 | Â | |
4165 | Â | // Bulk operations run against the entire set |
4166 | Â | if ( raw ) { |
4167 | Â | fn.call( elems, value ); |
4168 | Â | fn = null; |
4169 | Â | |
4170 | Â | // ...except when executing function values |
4171 | Â | } else { |
4172 | Â | bulk = fn; |
4173 | Â | fn = function( elem, _key, value ) { |
4174 | Â | return bulk.call( jQuery( elem ), value ); |
4175 | Â | }; |
4176 | Â | } |
4177 | Â | } |
4178 | Â | |
4179 | Â | if ( fn ) { |
4180 | Â | for ( ; i < len; i++ ) { |
4181 | Â | fn( |
4182 | Â | elems[ i ], key, raw ? |
4183 | Â | value : |
4184 | Â | value.call( elems[ i ], i, fn( elems[ i ], key ) ) |
4185 | Â | ); |
4186 | Â | } |
4187 | Â | } |
4188 | Â | } |
4189 | Â | |
4190 | Â | if ( chainable ) { |
4191 | Â | return elems; |
4192 | Â | } |
4193 | Â | |
4194 | Â | // Gets |
4195 | Â | if ( bulk ) { |
4196 | Â | return fn.call( elems ); |
4197 | Â | } |
4198 | Â | |
4199 | Â | return len ? fn( elems[ 0 ], key ) : emptyGet; |
4200 | Â | }; |
4201 | Â | |
4202 | Â | |
4203 | Â | // Matches dashed string for camelizing |
4204 | Â | var rmsPrefix = /^-ms-/, |
4205 | Â | rdashAlpha = /-([a-z])/g; |
4206 | Â | |
4207 | Â | // Used by camelCase as callback to replace() |
4208 | Â | function fcamelCase( _all, letter ) { |
4209 | Â | return letter.toUpperCase(); |
4210 | Â | } |
4211 | Â | |
4212 | Â | // Convert dashed to camelCase; used by the css and data modules |
4213 | Â | // Support: IE <=9 - 11, Edge 12 - 15 |
4214 | Â | // Microsoft forgot to hump their vendor prefix (#9572) |
4215 | Â | function camelCase( string ) { |
4216 | Â | return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); |
4217 | Â | } |
4218 | Â | var acceptData = function( owner ) { |
4219 | Â | |
4220 | Â | // Accepts only: |
4221 | Â | // - Node |
4222 | Â | // - Node.ELEMENT_NODE |
4223 | Â | // - Node.DOCUMENT_NODE |
4224 | Â | // - Object |
4225 | Â | // - Any |
4226 | Â | return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); |
4227 | Â | }; |
4228 | Â | |
4229 | Â | |
4230 | Â | |
4231 | Â | |
4232 | Â | function Data() { |
4233 | Â | this.expando = jQuery.expando + Data.uid++; |
4234 | Â | } |
4235 | Â | |
4236 | Â | Data.uid = 1; |
4237 | Â | |
4238 | Â | Data.prototype = { |
4239 | Â | |
4240 | Â | cache: function( owner ) { |
4241 | Â | |
4242 | Â | // Check if the owner object already has a cache |
4243 | Â | var value = owner[ this.expando ]; |
4244 | Â | |
4245 | Â | // If not, create one |
4246 | Â | if ( !value ) { |
4247 | Â | value = {}; |
4248 | Â | |
4249 | Â | // We can accept data for non-element nodes in modern browsers, |
4250 | Â | // but we should not, see #8335. |
4251 | Â | // Always return an empty object. |
4252 | Â | if ( acceptData( owner ) ) { |
4253 | Â | |
4254 | Â | // If it is a node unlikely to be stringify-ed or looped over |
4255 | Â | // use plain assignment |
4256 | Â | if ( owner.nodeType ) { |
4257 | Â | owner[ this.expando ] = value; |
4258 | Â | |
4259 | Â | // Otherwise secure it in a non-enumerable property |
4260 | Â | // configurable must be true to allow the property to be |
4261 | Â | // deleted when data is removed |
4262 | Â | } else { |
4263 | Â | Object.defineProperty( owner, this.expando, { |
4264 | Â | value: value, |
4265 | Â | configurable: true |
4266 | Â | } ); |
4267 | Â | } |
4268 | Â | } |
4269 | Â | } |
4270 | Â | |
4271 | Â | return value; |
4272 | Â | }, |
4273 | Â | set: function( owner, data, value ) { |
4274 | Â | var prop, |
4275 | Â | cache = this.cache( owner ); |
4276 | Â | |
4277 | Â | // Handle: [ owner, key, value ] args |
4278 | Â | // Always use camelCase key (gh-2257) |
4279 | Â | if ( typeof data === "string" ) { |
4280 | Â | cache[ camelCase( data ) ] = value; |
4281 | Â | |
4282 | Â | // Handle: [ owner, { properties } ] args |
4283 | Â | } else { |
4284 | Â | |
4285 | Â | // Copy the properties one-by-one to the cache object |
4286 | Â | for ( prop in data ) { |
4287 | Â | cache[ camelCase( prop ) ] = data[ prop ]; |
4288 | Â | } |
4289 | Â | } |
4290 | Â | return cache; |
4291 | Â | }, |
4292 | Â | get: function( owner, key ) { |
4293 | Â | return key === undefined ? |
4294 | Â | this.cache( owner ) : |
4295 | Â | |
4296 | Â | // Always use camelCase key (gh-2257) |
4297 | Â | owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ]; |
4298 | Â | }, |
4299 | Â | access: function( owner, key, value ) { |
4300 | Â | |
4301 | Â | // In cases where either: |
4302 | Â | // |
4303 | Â | // 1. No key was specified |
4304 | Â | // 2. A string key was specified, but no value provided |
4305 | Â | // |
4306 | Â | // Take the "read" path and allow the get method to determine |
4307 | Â | // which value to return, respectively either: |
4308 | Â | // |
4309 | Â | // 1. The entire cache object |
4310 | Â | // 2. The data stored at the key |
4311 | Â | // |
4312 | Â | if ( key === undefined || |
4313 | Â | ( ( key && typeof key === "string" ) && value === undefined ) ) { |
4314 | Â | |
4315 | Â | return this.get( owner, key ); |
4316 | Â | } |
4317 | Â | |
4318 | Â | // When the key is not a string, or both a key and value |
4319 | Â | // are specified, set or extend (existing objects) with either: |
4320 | Â | // |
4321 | Â | // 1. An object of properties |
4322 | Â | // 2. A key and value |
4323 | Â | // |
4324 | Â | this.set( owner, key, value ); |
4325 | Â | |
4326 | Â | // Since the "set" path can have two possible entry points |
4327 | Â | // return the expected data based on which path was taken[*] |
4328 | Â | return value !== undefined ? value : key; |
4329 | Â | }, |
4330 | Â | remove: function( owner, key ) { |
4331 | Â | var i, |
4332 | Â | cache = owner[ this.expando ]; |
4333 | Â | |
4334 | Â | if ( cache === undefined ) { |
4335 | Â | return; |
4336 | Â | } |
4337 | Â | |
4338 | Â | if ( key !== undefined ) { |
4339 | Â | |
4340 | Â | // Support array or space separated string of keys |
4341 | Â | if ( Array.isArray( key ) ) { |
4342 | Â | |
4343 | Â | // If key is an array of keys... |
4344 | Â | // We always set camelCase keys, so remove that. |
4345 | Â | key = key.map( camelCase ); |
4346 | Â | } else { |
4347 | Â | key = camelCase( key ); |
4348 | Â | |
4349 | Â | // If a key with the spaces exists, use it. |
4350 | Â | // Otherwise, create an array by matching non-whitespace |
4351 | Â | key = key in cache ? |
4352 | Â | [ key ] : |
4353 | Â | ( key.match( rnothtmlwhite ) || [] ); |
4354 | Â | } |
4355 | Â | |
4356 | Â | i = key.length; |
4357 | Â | |
4358 | Â | while ( i-- ) { |
4359 | Â | delete cache[ key[ i ] ]; |
4360 | Â | } |
4361 | Â | } |
4362 | Â | |
4363 | Â | // Remove the expando if there's no more data |
4364 | Â | if ( key === undefined || jQuery.isEmptyObject( cache ) ) { |
4365 | Â | |
4366 | Â | // Support: Chrome <=35 - 45 |
4367 | Â | // Webkit & Blink performance suffers when deleting properties |
4368 | Â | // from DOM nodes, so set to undefined instead |
4369 | Â | // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted) |
4370 | Â | if ( owner.nodeType ) { |
4371 | Â | owner[ this.expando ] = undefined; |
4372 | Â | } else { |
4373 | Â | delete owner[ this.expando ]; |
4374 | Â | } |
4375 | Â | } |
4376 | Â | }, |
4377 | Â | hasData: function( owner ) { |
4378 | Â | var cache = owner[ this.expando ]; |
4379 | Â | return cache !== undefined && !jQuery.isEmptyObject( cache ); |
4380 | Â | } |
4381 | Â | }; |
4382 | Â | var dataPriv = new Data(); |
4383 | Â | |
4384 | Â | var dataUser = new Data(); |
4385 | Â | |
4386 | Â | |
4387 | Â | |
4388 | Â | // Implementation Summary |
4389 | Â | // |
4390 | Â | // 1. Enforce API surface and semantic compatibility with 1.9.x branch |
4391 | Â | // 2. Improve the module's maintainability by reducing the storage |
4392 | Â | // paths to a single mechanism. |
4393 | Â | // 3. Use the same single mechanism to support "private" and "user" data. |
4394 | Â | // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) |
4395 | Â | // 5. Avoid exposing implementation details on user objects (eg. expando properties) |
4396 | Â | // 6. Provide a clear path for implementation upgrade to WeakMap in 2014 |
4397 | Â | |
4398 | Â | var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, |
4399 | Â | rmultiDash = /[A-Z]/g; |
4400 | Â | |
4401 | Â | function getData( data ) { |
4402 | Â | if ( data === "true" ) { |
4403 | Â | return true; |
4404 | Â | } |
4405 | Â | |
4406 | Â | if ( data === "false" ) { |
4407 | Â | return false; |
4408 | Â | } |
4409 | Â | |
4410 | Â | if ( data === "null" ) { |
4411 | Â | return null; |
4412 | Â | } |
4413 | Â | |
4414 | Â | // Only convert to a number if it doesn't change the string |
4415 | Â | if ( data === +data + "" ) { |
4416 | Â | return +data; |
4417 | Â | } |
4418 | Â | |
4419 | Â | if ( rbrace.test( data ) ) { |
4420 | Â | return JSON.parse( data ); |
4421 | Â | } |
4422 | Â | |
4423 | Â | return data; |
4424 | Â | } |
4425 | Â | |
4426 | Â | function dataAttr( elem, key, data ) { |
4427 | Â | var name; |
4428 | Â | |
4429 | Â | // If nothing was found internally, try to fetch any |
4430 | Â | // data from the HTML5 data-* attribute |
4431 | Â | if ( data === undefined && elem.nodeType === 1 ) { |
4432 | Â | name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); |
4433 | Â | data = elem.getAttribute( name ); |
4434 | Â | |
4435 | Â | if ( typeof data === "string" ) { |
4436 | Â | try { |
4437 | Â | data = getData( data ); |
4438 | Â | } catch ( e ) {} |
4439 | Â | |
4440 | Â | // Make sure we set the data so it isn't changed later |
4441 | Â | dataUser.set( elem, key, data ); |
4442 | Â | } else { |
4443 | Â | data = undefined; |
4444 | Â | } |
4445 | Â | } |
4446 | Â | return data; |
4447 | Â | } |
4448 | Â | |
4449 | Â | jQuery.extend( { |
4450 | Â | hasData: function( elem ) { |
4451 | Â | return dataUser.hasData( elem ) || dataPriv.hasData( elem ); |
4452 | Â | }, |
4453 | Â | |
4454 | Â | data: function( elem, name, data ) { |
4455 | Â | return dataUser.access( elem, name, data ); |
4456 | Â | }, |
4457 | Â | |
4458 | Â | removeData: function( elem, name ) { |
4459 | Â | dataUser.remove( elem, name ); |
4460 | Â | }, |
4461 | Â | |
4462 | Â | // TODO: Now that all calls to _data and _removeData have been replaced |
4463 | Â | // with direct calls to dataPriv methods, these can be deprecated. |
4464 | Â | _data: function( elem, name, data ) { |
4465 | Â | return dataPriv.access( elem, name, data ); |
4466 | Â | }, |
4467 | Â | |
4468 | Â | _removeData: function( elem, name ) { |
4469 | Â | dataPriv.remove( elem, name ); |
4470 | Â | } |
4471 | Â | } ); |
4472 | Â | |
4473 | Â | jQuery.fn.extend( { |
4474 | Â | data: function( key, value ) { |
4475 | Â | var i, name, data, |
4476 | Â | elem = this[ 0 ], |
4477 | Â | attrs = elem && elem.attributes; |
4478 | Â | |
4479 | Â | // Gets all values |
4480 | Â | if ( key === undefined ) { |
4481 | Â | if ( this.length ) { |
4482 | Â | data = dataUser.get( elem ); |
4483 | Â | |
4484 | Â | if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { |
4485 | Â | i = attrs.length; |
4486 | Â | while ( i-- ) { |
4487 | Â | |
4488 | Â | // Support: IE 11 only |
4489 | Â | // The attrs elements can be null (#14894) |
4490 | Â | if ( attrs[ i ] ) { |
4491 | Â | name = attrs[ i ].name; |
4492 | Â | if ( name.indexOf( "data-" ) === 0 ) { |
4493 | Â | name = camelCase( name.slice( 5 ) ); |
4494 | Â | dataAttr( elem, name, data[ name ] ); |
4495 | Â | } |
4496 | Â | } |
4497 | Â | } |
4498 | Â | dataPriv.set( elem, "hasDataAttrs", true ); |
4499 | Â | } |
4500 | Â | } |
4501 | Â | |
4502 | Â | return data; |
4503 | Â | } |
4504 | Â | |
4505 | Â | // Sets multiple values |
4506 | Â | if ( typeof key === "object" ) { |
4507 | Â | return this.each( function() { |
4508 | Â | dataUser.set( this, key ); |
4509 | Â | } ); |
4510 | Â | } |
4511 | Â | |
4512 | Â | return access( this, function( value ) { |
4513 | Â | var data; |
4514 | Â | |
4515 | Â | // The calling jQuery object (element matches) is not empty |
4516 | Â | // (and therefore has an element appears at this[ 0 ]) and the |
4517 | Â | // `value` parameter was not undefined. An empty jQuery object |
4518 | Â | // will result in `undefined` for elem = this[ 0 ] which will |
4519 | Â | // throw an exception if an attempt to read a data cache is made. |
4520 | Â | if ( elem && value === undefined ) { |
4521 | Â | |
4522 | Â | // Attempt to get data from the cache |
4523 | Â | // The key will always be camelCased in Data |
4524 | Â | data = dataUser.get( elem, key ); |
4525 | Â | if ( data !== undefined ) { |
4526 | Â | return data; |
4527 | Â | } |
4528 | Â | |
4529 | Â | // Attempt to "discover" the data in |
4530 | Â | // HTML5 custom data-* attrs |
4531 | Â | data = dataAttr( elem, key ); |
4532 | Â | if ( data !== undefined ) { |
4533 | Â | return data; |
4534 | Â | } |
4535 | Â | |
4536 | Â | // We tried really hard, but the data doesn't exist. |
4537 | Â | return; |
4538 | Â | } |
4539 | Â | |
4540 | Â | // Set the data... |
4541 | Â | this.each( function() { |
4542 | Â | |
4543 | Â | // We always store the camelCased key |
4544 | Â | dataUser.set( this, key, value ); |
4545 | Â | } ); |
4546 | Â | }, null, value, arguments.length > 1, null, true ); |
4547 | Â | }, |
4548 | Â | |
4549 | Â | removeData: function( key ) { |
4550 | Â | return this.each( function() { |
4551 | Â | dataUser.remove( this, key ); |
4552 | Â | } ); |
4553 | Â | } |
4554 | Â | } ); |
4555 | Â | |
4556 | Â | |
4557 | Â | jQuery.extend( { |
4558 | Â | queue: function( elem, type, data ) { |
4559 | Â | var queue; |
4560 | Â | |
4561 | Â | if ( elem ) { |
4562 | Â | type = ( type || "fx" ) + "queue"; |
4563 | Â | queue = dataPriv.get( elem, type ); |
4564 | Â | |
4565 | Â | // Speed up dequeue by getting out quickly if this is just a lookup |
4566 | Â | if ( data ) { |
4567 | Â | if ( !queue || Array.isArray( data ) ) { |
4568 | Â | queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); |
4569 | Â | } else { |
4570 | Â | queue.push( data ); |
4571 | Â | } |
4572 | Â | } |
4573 | Â | return queue || []; |
4574 | Â | } |
4575 | Â | }, |
4576 | Â | |
4577 | Â | dequeue: function( elem, type ) { |
4578 | Â | type = type || "fx"; |
4579 | Â | |
4580 | Â | var queue = jQuery.queue( elem, type ), |
4581 | Â | startLength = queue.length, |
4582 | Â | fn = queue.shift(), |
4583 | Â | hooks = jQuery._queueHooks( elem, type ), |
4584 | Â | next = function() { |
4585 | Â | jQuery.dequeue( elem, type ); |
4586 | Â | }; |
4587 | Â | |
4588 | Â | // If the fx queue is dequeued, always remove the progress sentinel |
4589 | Â | if ( fn === "inprogress" ) { |
4590 | Â | fn = queue.shift(); |
4591 | Â | startLength--; |
4592 | Â | } |
4593 | Â | |
4594 | Â | if ( fn ) { |
4595 | Â | |
4596 | Â | // Add a progress sentinel to prevent the fx queue from being |
4597 | Â | // automatically dequeued |
4598 | Â | if ( type === "fx" ) { |
4599 | Â | queue.unshift( "inprogress" ); |
4600 | Â | } |
4601 | Â | |
4602 | Â | // Clear up the last queue stop function |
4603 | Â | delete hooks.stop; |
4604 | Â | fn.call( elem, next, hooks ); |
4605 | Â | } |
4606 | Â | |
4607 | Â | if ( !startLength && hooks ) { |
4608 | Â | hooks.empty.fire(); |
4609 | Â | } |
4610 | Â | }, |
4611 | Â | |
4612 | Â | // Not public - generate a queueHooks object, or return the current one |
4613 | Â | _queueHooks: function( elem, type ) { |
4614 | Â | var key = type + "queueHooks"; |
4615 | Â | return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { |
4616 | Â | empty: jQuery.Callbacks( "once memory" ).add( function() { |
4617 | Â | dataPriv.remove( elem, [ type + "queue", key ] ); |
4618 | Â | } ) |
4619 | Â | } ); |
4620 | Â | } |
4621 | Â | } ); |
4622 | Â | |
4623 | Â | jQuery.fn.extend( { |
4624 | Â | queue: function( type, data ) { |
4625 | Â | var setter = 2; |
4626 | Â | |
4627 | Â | if ( typeof type !== "string" ) { |
4628 | Â | data = type; |
4629 | Â | type = "fx"; |
4630 | Â | setter--; |
4631 | Â | } |
4632 | Â | |
4633 | Â | if ( arguments.length < setter ) { |
4634 | Â | return jQuery.queue( this[ 0 ], type ); |
4635 | Â | } |
4636 | Â | |
4637 | Â | return data === undefined ? |
4638 | Â | this : |
4639 | Â | this.each( function() { |
4640 | Â | var queue = jQuery.queue( this, type, data ); |
4641 | Â | |
4642 | Â | // Ensure a hooks for this queue |
4643 | Â | jQuery._queueHooks( this, type ); |
4644 | Â | |
4645 | Â | if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { |
4646 | Â | jQuery.dequeue( this, type ); |
4647 | Â | } |
4648 | Â | } ); |
4649 | Â | }, |
4650 | Â | dequeue: function( type ) { |
4651 | Â | return this.each( function() { |
4652 | Â | jQuery.dequeue( this, type ); |
4653 | Â | } ); |
4654 | Â | }, |
4655 | Â | clearQueue: function( type ) { |
4656 | Â | return this.queue( type || "fx", [] ); |
4657 | Â | }, |
4658 | Â | |
4659 | Â | // Get a promise resolved when queues of a certain type |
4660 | Â | // are emptied (fx is the type by default) |
4661 | Â | promise: function( type, obj ) { |
4662 | Â | var tmp, |
4663 | Â | count = 1, |
4664 | Â | defer = jQuery.Deferred(), |
4665 | Â | elements = this, |
4666 | Â | i = this.length, |
4667 | Â | resolve = function() { |
4668 | Â | if ( !( --count ) ) { |
4669 | Â | defer.resolveWith( elements, [ elements ] ); |
4670 | Â | } |
4671 | Â | }; |
4672 | Â | |
4673 | Â | if ( typeof type !== "string" ) { |
4674 | Â | obj = type; |
4675 | Â | type = undefined; |
4676 | Â | } |
4677 | Â | type = type || "fx"; |
4678 | Â | |
4679 | Â | while ( i-- ) { |
4680 | Â | tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); |
4681 | Â | if ( tmp && tmp.empty ) { |
4682 | Â | count++; |
4683 | Â | tmp.empty.add( resolve ); |
4684 | Â | } |
4685 | Â | } |
4686 | Â | resolve(); |
4687 | Â | return defer.promise( obj ); |
4688 | Â | } |
4689 | Â | } ); |
4690 | Â | var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; |
4691 | Â | |
4692 | Â | var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); |
4693 | Â | |
4694 | Â | |
4695 | Â | var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; |
4696 | Â | |
4697 | Â | var documentElement = document.documentElement; |
4698 | Â | |
4699 | Â | |
4700 | Â | |
4701 | Â | var isAttached = function( elem ) { |
4702 | Â | return jQuery.contains( elem.ownerDocument, elem ); |
4703 | Â | }, |
4704 | Â | composed = { composed: true }; |
4705 | Â | |
4706 | Â | // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only |
4707 | Â | // Check attachment across shadow DOM boundaries when possible (gh-3504) |
4708 | Â | // Support: iOS 10.0-10.2 only |
4709 | Â | // Early iOS 10 versions support `attachShadow` but not `getRootNode`, |
4710 | Â | // leading to errors. We need to check for `getRootNode`. |
4711 | Â | if ( documentElement.getRootNode ) { |
4712 | Â | isAttached = function( elem ) { |
4713 | Â | return jQuery.contains( elem.ownerDocument, elem ) || |
4714 | Â | elem.getRootNode( composed ) === elem.ownerDocument; |
4715 | Â | }; |
4716 | Â | } |
4717 | Â | var isHiddenWithinTree = function( elem, el ) { |
4718 | Â | |
4719 | Â | // isHiddenWithinTree might be called from jQuery#filter function; |
4720 | Â | // in that case, element will be second argument |
4721 | Â | elem = el || elem; |
4722 | Â | |
4723 | Â | // Inline style trumps all |
4724 | Â | return elem.style.display === "none" || |
4725 | Â | elem.style.display === "" && |
4726 | Â | |
4727 | Â | // Otherwise, check computed style |
4728 | Â | // Support: Firefox <=43 - 45 |
4729 | Â | // Disconnected elements can have computed display: none, so first confirm that elem is |
4730 | Â | // in the document. |
4731 | Â | isAttached( elem ) && |
4732 | Â | |
4733 | Â | jQuery.css( elem, "display" ) === "none"; |
4734 | Â | }; |
4735 | Â | |
4736 | Â | |
4737 | Â | |
4738 | Â | function adjustCSS( elem, prop, valueParts, tween ) { |
4739 | Â | var adjusted, scale, |
4740 | Â | maxIterations = 20, |
4741 | Â | currentValue = tween ? |
4742 | Â | function() { |
4743 | Â | return tween.cur(); |
4744 | Â | } : |
4745 | Â | function() { |
4746 | Â | return jQuery.css( elem, prop, "" ); |
4747 | Â | }, |
4748 | Â | initial = currentValue(), |
4749 | Â | unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), |
4750 | Â | |
4751 | Â | // Starting value computation is required for potential unit mismatches |
4752 | Â | initialInUnit = elem.nodeType && |
4753 | Â | ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && |
4754 | Â | rcssNum.exec( jQuery.css( elem, prop ) ); |
4755 | Â | |
4756 | Â | if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { |
4757 | Â | |
4758 | Â | // Support: Firefox <=54 |
4759 | Â | // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) |
4760 | Â | initial = initial / 2; |
4761 | Â | |
4762 | Â | // Trust units reported by jQuery.css |
4763 | Â | unit = unit || initialInUnit[ 3 ]; |
4764 | Â | |
4765 | Â | // Iteratively approximate from a nonzero starting point |
4766 | Â | initialInUnit = +initial || 1; |
4767 | Â | |
4768 | Â | while ( maxIterations-- ) { |
4769 | Â | |
4770 | Â | // Evaluate and update our best guess (doubling guesses that zero out). |
4771 | Â | // Finish if the scale equals or crosses 1 (making the old*new product non-positive). |
4772 | Â | jQuery.style( elem, prop, initialInUnit + unit ); |
4773 | Â | if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { |
4774 | Â | maxIterations = 0; |
4775 | Â | } |
4776 | Â | initialInUnit = initialInUnit / scale; |
4777 | Â | |
4778 | Â | } |
4779 | Â | |
4780 | Â | initialInUnit = initialInUnit * 2; |
4781 | Â | jQuery.style( elem, prop, initialInUnit + unit ); |
4782 | Â | |
4783 | Â | // Make sure we update the tween properties later on |
4784 | Â | valueParts = valueParts || []; |
4785 | Â | } |
4786 | Â | |
4787 | Â | if ( valueParts ) { |
4788 | Â | initialInUnit = +initialInUnit || +initial || 0; |
4789 | Â | |
4790 | Â | // Apply relative offset (+=/-=) if specified |
4791 | Â | adjusted = valueParts[ 1 ] ? |
4792 | Â | initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : |
4793 | Â | +valueParts[ 2 ]; |
4794 | Â | if ( tween ) { |
4795 | Â | tween.unit = unit; |
4796 | Â | tween.start = initialInUnit; |
4797 | Â | tween.end = adjusted; |
4798 | Â | } |
4799 | Â | } |
4800 | Â | return adjusted; |
4801 | Â | } |
4802 | Â | |
4803 | Â | |
4804 | Â | var defaultDisplayMap = {}; |
4805 | Â | |
4806 | Â | function getDefaultDisplay( elem ) { |
4807 | Â | var temp, |
4808 | Â | doc = elem.ownerDocument, |
4809 | Â | nodeName = elem.nodeName, |
4810 | Â | display = defaultDisplayMap[ nodeName ]; |
4811 | Â | |
4812 | Â | if ( display ) { |
4813 | Â | return display; |
4814 | Â | } |
4815 | Â | |
4816 | Â | temp = doc.body.appendChild( doc.createElement( nodeName ) ); |
4817 | Â | display = jQuery.css( temp, "display" ); |
4818 | Â | |
4819 | Â | temp.parentNode.removeChild( temp ); |
4820 | Â | |
4821 | Â | if ( display === "none" ) { |
4822 | Â | display = "block"; |
4823 | Â | } |
4824 | Â | defaultDisplayMap[ nodeName ] = display; |
4825 | Â | |
4826 | Â | return display; |
4827 | Â | } |
4828 | Â | |
4829 | Â | function showHide( elements, show ) { |
4830 | Â | var display, elem, |
4831 | Â | values = [], |
4832 | Â | index = 0, |
4833 | Â | length = elements.length; |
4834 | Â | |
4835 | Â | // Determine new display value for elements that need to change |
4836 | Â | for ( ; index < length; index++ ) { |
4837 | Â | elem = elements[ index ]; |
4838 | Â | if ( !elem.style ) { |
4839 | Â | continue; |
4840 | Â | } |
4841 | Â | |
4842 | Â | display = elem.style.display; |
4843 | Â | if ( show ) { |
4844 | Â | |
4845 | Â | // Since we force visibility upon cascade-hidden elements, an immediate (and slow) |
4846 | Â | // check is required in this first loop unless we have a nonempty display value (either |
4847 | Â | // inline or about-to-be-restored) |
4848 | Â | if ( display === "none" ) { |
4849 | Â | values[ index ] = dataPriv.get( elem, "display" ) || null; |
4850 | Â | if ( !values[ index ] ) { |
4851 | Â | elem.style.display = ""; |
4852 | Â | } |
4853 | Â | } |
4854 | Â | if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { |
4855 | Â | values[ index ] = getDefaultDisplay( elem ); |
4856 | Â | } |
4857 | Â | } else { |
4858 | Â | if ( display !== "none" ) { |
4859 | Â | values[ index ] = "none"; |
4860 | Â | |
4861 | Â | // Remember what we're overwriting |
4862 | Â | dataPriv.set( elem, "display", display ); |
4863 | Â | } |
4864 | Â | } |
4865 | Â | } |
4866 | Â | |
4867 | Â | // Set the display of the elements in a second loop to avoid constant reflow |
4868 | Â | for ( index = 0; index < length; index++ ) { |
4869 | Â | if ( values[ index ] != null ) { |
4870 | Â | elements[ index ].style.display = values[ index ]; |
4871 | Â | } |
4872 | Â | } |
4873 | Â | |
4874 | Â | return elements; |
4875 | Â | } |
4876 | Â | |
4877 | Â | jQuery.fn.extend( { |
4878 | Â | show: function() { |
4879 | Â | return showHide( this, true ); |
4880 | Â | }, |
4881 | Â | hide: function() { |
4882 | Â | return showHide( this ); |
4883 | Â | }, |
4884 | Â | toggle: function( state ) { |
4885 | Â | if ( typeof state === "boolean" ) { |
4886 | Â | return state ? this.show() : this.hide(); |
4887 | Â | } |
4888 | Â | |
4889 | Â | return this.each( function() { |
4890 | Â | if ( isHiddenWithinTree( this ) ) { |
4891 | Â | jQuery( this ).show(); |
4892 | Â | } else { |
4893 | Â | jQuery( this ).hide(); |
4894 | Â | } |
4895 | Â | } ); |
4896 | Â | } |
4897 | Â | } ); |
4898 | Â | var rcheckableType = ( /^(?:checkbox|radio)$/i ); |
4899 | Â | |
4900 | Â | var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i ); |
4901 | Â | |
4902 | Â | var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); |
4903 | Â | |
4904 | Â | |
4905 | Â | |
4906 | Â | ( function() { |
4907 | Â | var fragment = document.createDocumentFragment(), |
4908 | Â | div = fragment.appendChild( document.createElement( "div" ) ), |
4909 | Â | input = document.createElement( "input" ); |
4910 | Â | |
4911 | Â | // Support: Android 4.0 - 4.3 only |
4912 | Â | // Check state lost if the name is set (#11217) |
4913 | Â | // Support: Windows Web Apps (WWA) |
4914 | Â | // `name` and `type` must use .setAttribute for WWA (#14901) |
4915 | Â | input.setAttribute( "type", "radio" ); |
4916 | Â | input.setAttribute( "checked", "checked" ); |
4917 | Â | input.setAttribute( "name", "t" ); |
4918 | Â | |
4919 | Â | div.appendChild( input ); |
4920 | Â | |
4921 | Â | // Support: Android <=4.1 only |
4922 | Â | // Older WebKit doesn't clone checked state correctly in fragments |
4923 | Â | support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; |
4924 | Â | |
4925 | Â | // Support: IE <=11 only |
4926 | Â | // Make sure textarea (and checkbox) defaultValue is properly cloned |
4927 | Â | div.innerHTML = "<textarea>x</textarea>"; |
4928 | Â | support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; |
4929 | Â | |
4930 | Â | // Support: IE <=9 only |
4931 | Â | // IE <=9 replaces <option> tags with their contents when inserted outside of |
4932 | Â | // the select element. |
4933 | Â | div.innerHTML = "<option></option>"; |
4934 | Â | support.option = !!div.lastChild; |
4935 | Â | } )(); |
4936 | Â | |
4937 | Â | |
4938 | Â | // We have to close these tags to support XHTML (#13200) |
4939 | Â | var wrapMap = { |
4940 | Â | |
4941 | Â | // XHTML parsers do not magically insert elements in the |
4942 | Â | // same way that tag soup parsers do. So we cannot shorten |
4943 | Â | // this by omitting <tbody> or other required elements. |
4944 | Â | thead: [ 1, "<table>", "</table>" ], |
4945 | Â | col: [ 2, "<table><colgroup>", "</colgroup></table>" ], |
4946 | Â | tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
4947 | Â | td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
4948 | Â | |
4949 | Â | _default: [ 0, "", "" ] |
4950 | Â | }; |
4951 | Â | |
4952 | Â | wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
4953 | Â | wrapMap.th = wrapMap.td; |
4954 | Â | |
4955 | Â | // Support: IE <=9 only |
4956 | Â | if ( !support.option ) { |
4957 | Â | wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ]; |
4958 | Â | } |
4959 | Â | |
4960 | Â | |
4961 | Â | function getAll( context, tag ) { |
4962 | Â | |
4963 | Â | // Support: IE <=9 - 11 only |
4964 | Â | // Use typeof to avoid zero-argument method invocation on host objects (#15151) |
4965 | Â | var ret; |
4966 | Â | |
4967 | Â | if ( typeof context.getElementsByTagName !== "undefined" ) { |
4968 | Â | ret = context.getElementsByTagName( tag || "*" ); |
4969 | Â | |
4970 | Â | } else if ( typeof context.querySelectorAll !== "undefined" ) { |
4971 | Â | ret = context.querySelectorAll( tag || "*" ); |
4972 | Â | |
4973 | Â | } else { |
4974 | Â | ret = []; |
4975 | Â | } |
4976 | Â | |
4977 | Â | if ( tag === undefined || tag && nodeName( context, tag ) ) { |
4978 | Â | return jQuery.merge( [ context ], ret ); |
4979 | Â | } |
4980 | Â | |
4981 | Â | return ret; |
4982 | Â | } |
4983 | Â | |
4984 | Â | |
4985 | Â | // Mark scripts as having already been evaluated |
4986 | Â | function setGlobalEval( elems, refElements ) { |
4987 | Â | var i = 0, |
4988 | Â | l = elems.length; |
4989 | Â | |
4990 | Â | for ( ; i < l; i++ ) { |
4991 | Â | dataPriv.set( |
4992 | Â | elems[ i ], |
4993 | Â | "globalEval", |
4994 | Â | !refElements || dataPriv.get( refElements[ i ], "globalEval" ) |
4995 | Â | ); |
4996 | Â | } |
4997 | Â | } |
4998 | Â | |
4999 | Â | |
5000 | Â | var rhtml = /<|&#?\w+;/; |
5001 | Â | |
5002 | Â | function buildFragment( elems, context, scripts, selection, ignored ) { |
5003 | Â | var elem, tmp, tag, wrap, attached, j, |
5004 | Â | fragment = context.createDocumentFragment(), |
5005 | Â | nodes = [], |
5006 | Â | i = 0, |
5007 | Â |