UNPKG

73.3 kBJavaScriptView Raw
1/*!
2 * Sizzle CSS Selector Engine v2.3.9
3 * https://sizzlejs.com/
4 *
5 * Copyright JS Foundation and other contributors
6 * Released under the MIT license
7 * https://js.foundation/
8 *
9 * Date: 2022-12-19
10 */
11( function( window ) {
12var i,
13 support,
14 Expr,
15 getText,
16 isXML,
17 tokenize,
18 compile,
19 select,
20 outermostContext,
21 sortInput,
22 hasDuplicate,
23
24 // Local document vars
25 setDocument,
26 document,
27 docElem,
28 documentIsHTML,
29 rbuggyQSA,
30 rbuggyMatches,
31 matches,
32 contains,
33
34 // Instance-specific data
35 expando = "sizzle" + 1 * new Date(),
36 preferredDoc = window.document,
37 dirruns = 0,
38 done = 0,
39 classCache = createCache(),
40 tokenCache = createCache(),
41 compilerCache = createCache(),
42 nonnativeSelectorCache = createCache(),
43 sortOrder = function( a, b ) {
44 if ( a === b ) {
45 hasDuplicate = true;
46 }
47 return 0;
48 },
49
50 // Instance methods
51 hasOwn = ( {} ).hasOwnProperty,
52 arr = [],
53 pop = arr.pop,
54 pushNative = arr.push,
55 push = arr.push,
56 slice = arr.slice,
57
58 // Use a stripped-down indexOf as it's faster than native
59 // https://jsperf.com/thor-indexof-vs-for/5
60 indexOf = function( list, elem ) {
61 var i = 0,
62 len = list.length;
63 for ( ; i < len; i++ ) {
64 if ( list[ i ] === elem ) {
65 return i;
66 }
67 }
68 return -1;
69 },
70
71 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" +
72 "ismap|loop|multiple|open|readonly|required|scoped",
73
74 // Regular expressions
75
76 // http://www.w3.org/TR/css3-selectors/#whitespace
77 whitespace = "[\\x20\\t\\r\\n\\f]",
78
79 // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
80 identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace +
81 "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+",
82
83 // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
84 attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
85
86 // Operator (capture 2)
87 "*([*^$|!~]?=)" + whitespace +
88
89 // "Attribute values must be CSS identifiers [capture 5]
90 // or strings [capture 3 or capture 4]"
91 "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" +
92 whitespace + "*\\]",
93
94 pseudos = ":(" + identifier + ")(?:\\((" +
95
96 // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
97 // 1. quoted (capture 3; capture 4 or capture 5)
98 "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
99
100 // 2. simple (capture 6)
101 "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
102
103 // 3. anything else (capture 2)
104 ".*" +
105 ")\\)|)",
106
107 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
108 rwhitespace = new RegExp( whitespace + "+", "g" ),
109 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" +
110 whitespace + "+$", "g" ),
111
112 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
113 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace +
114 "*" ),
115 rdescend = new RegExp( whitespace + "|>" ),
116
117 rpseudo = new RegExp( pseudos ),
118 ridentifier = new RegExp( "^" + identifier + "$" ),
119
120 matchExpr = {
121 "ID": new RegExp( "^#(" + identifier + ")" ),
122 "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
123 "TAG": new RegExp( "^(" + identifier + "|[*])" ),
124 "ATTR": new RegExp( "^" + attributes ),
125 "PSEUDO": new RegExp( "^" + pseudos ),
126 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" +
127 whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" +
128 whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
129 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
130
131 // For use in libraries implementing .is()
132 // We use this for POS matching in `select`
133 "needsContext": new RegExp( "^" + whitespace +
134 "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
135 "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
136 },
137
138 rhtml = /HTML$/i,
139 rinputs = /^(?:input|select|textarea|button)$/i,
140 rheader = /^h\d$/i,
141
142 rnative = /^[^{]+\{\s*\[native \w/,
143
144 // Easily-parseable/retrievable ID or TAG or CLASS selectors
145 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
146
147 rsibling = /[+~]/,
148
149 // CSS escapes
150 // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
151 runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ),
152 funescape = function( escape, nonHex ) {
153 var high = "0x" + escape.slice( 1 ) - 0x10000;
154
155 return nonHex ?
156
157 // Strip the backslash prefix from a non-hex escape sequence
158 nonHex :
159
160 // Replace a hexadecimal escape sequence with the encoded Unicode code point
161 // Support: IE <=11+
162 // For values outside the Basic Multilingual Plane (BMP), manually construct a
163 // surrogate pair
164 high < 0 ?
165 String.fromCharCode( high + 0x10000 ) :
166 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
167 },
168
169 // CSS string/identifier serialization
170 // https://drafts.csswg.org/cssom/#common-serializing-idioms
171 rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
172 fcssescape = function( ch, asCodePoint ) {
173 if ( asCodePoint ) {
174
175 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
176 if ( ch === "\0" ) {
177 return "\uFFFD";
178 }
179
180 // Control characters and (dependent upon position) numbers get escaped as code points
181 return ch.slice( 0, -1 ) + "\\" +
182 ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
183 }
184
185 // Other potentially-special ASCII characters get backslash-escaped
186 return "\\" + ch;
187 },
188
189 // Used for iframes
190 // See setDocument()
191 // Removing the function wrapper causes a "Permission Denied"
192 // error in IE
193 unloadHandler = function() {
194 setDocument();
195 },
196
197 inDisabledFieldset = addCombinator(
198 function( elem ) {
199 return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
200 },
201 { dir: "parentNode", next: "legend" }
202 );
203
204// Optimize for push.apply( _, NodeList )
205try {
206 push.apply(
207 ( arr = slice.call( preferredDoc.childNodes ) ),
208 preferredDoc.childNodes
209 );
210
211 // Support: Android<4.0
212 // Detect silently failing push.apply
213 // eslint-disable-next-line no-unused-expressions
214 arr[ preferredDoc.childNodes.length ].nodeType;
215} catch ( e ) {
216 push = { apply: arr.length ?
217
218 // Leverage slice if possible
219 function( target, els ) {
220 pushNative.apply( target, slice.call( els ) );
221 } :
222
223 // Support: IE<9
224 // Otherwise append directly
225 function( target, els ) {
226 var j = target.length,
227 i = 0;
228
229 // Can't trust NodeList.length
230 while ( ( target[ j++ ] = els[ i++ ] ) ) {}
231 target.length = j - 1;
232 }
233 };
234}
235
236function Sizzle( selector, context, results, seed ) {
237 var m, i, elem, nid, match, groups, newSelector,
238 newContext = context && context.ownerDocument,
239
240 // nodeType defaults to 9, since context defaults to document
241 nodeType = context ? context.nodeType : 9;
242
243 results = results || [];
244
245 // Return early from calls with invalid selector or context
246 if ( typeof selector !== "string" || !selector ||
247 nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
248
249 return results;
250 }
251
252 // Try to shortcut find operations (as opposed to filters) in HTML documents
253 if ( !seed ) {
254 setDocument( context );
255 context = context || document;
256
257 if ( documentIsHTML ) {
258
259 // If the selector is sufficiently simple, try using a "get*By*" DOM method
260 // (excepting DocumentFragment context, where the methods don't exist)
261 if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) {
262
263 // ID selector
264 if ( ( m = match[ 1 ] ) ) {
265
266 // Document context
267 if ( nodeType === 9 ) {
268 if ( ( elem = context.getElementById( m ) ) ) {
269
270 // Support: IE, Opera, Webkit
271 // TODO: identify versions
272 // getElementById can match elements by name instead of ID
273 if ( elem.id === m ) {
274 results.push( elem );
275 return results;
276 }
277 } else {
278 return results;
279 }
280
281 // Element context
282 } else {
283
284 // Support: IE, Opera, Webkit
285 // TODO: identify versions
286 // getElementById can match elements by name instead of ID
287 if ( newContext && ( elem = newContext.getElementById( m ) ) &&
288 contains( context, elem ) &&
289 elem.id === m ) {
290
291 results.push( elem );
292 return results;
293 }
294 }
295
296 // Type selector
297 } else if ( match[ 2 ] ) {
298 push.apply( results, context.getElementsByTagName( selector ) );
299 return results;
300
301 // Class selector
302 } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName &&
303 context.getElementsByClassName ) {
304
305 push.apply( results, context.getElementsByClassName( m ) );
306 return results;
307 }
308 }
309
310 // Take advantage of querySelectorAll
311 if ( support.qsa &&
312 !nonnativeSelectorCache[ selector + " " ] &&
313 ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) &&
314
315 // Support: IE 8 only
316 // Exclude object elements
317 ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) {
318
319 newSelector = selector;
320 newContext = context;
321
322 // qSA considers elements outside a scoping root when evaluating child or
323 // descendant combinators, which is not what we want.
324 // In such cases, we work around the behavior by prefixing every selector in the
325 // list with an ID selector referencing the scope context.
326 // The technique has to be used as well when a leading combinator is used
327 // as such selectors are not recognized by querySelectorAll.
328 // Thanks to Andrew Dupont for this technique.
329 if ( nodeType === 1 &&
330 ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) {
331
332 // Expand context for sibling selectors
333 newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
334 context;
335
336 // We can use :scope instead of the ID hack if the browser
337 // supports it & if we're not changing the context.
338 if ( newContext !== context || !support.scope ) {
339
340 // Capture the context ID, setting it first if necessary
341 if ( ( nid = context.getAttribute( "id" ) ) ) {
342 nid = nid.replace( rcssescape, fcssescape );
343 } else {
344 context.setAttribute( "id", ( nid = expando ) );
345 }
346 }
347
348 // Prefix every selector in the list
349 groups = tokenize( selector );
350 i = groups.length;
351 while ( i-- ) {
352 groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " +
353 toSelector( groups[ i ] );
354 }
355 newSelector = groups.join( "," );
356 }
357
358 try {
359
360 // `qSA` may not throw for unrecognized parts using forgiving parsing:
361 // https://drafts.csswg.org/selectors/#forgiving-selector
362 // like the `:has()` pseudo-class:
363 // https://drafts.csswg.org/selectors/#relational
364 // `CSS.supports` is still expected to return `false` then:
365 // https://drafts.csswg.org/css-conditional-4/#typedef-supports-selector-fn
366 // https://drafts.csswg.org/css-conditional-4/#dfn-support-selector
367 if ( support.cssSupportsSelector &&
368
369 // eslint-disable-next-line no-undef
370 !CSS.supports( "selector(:is(" + newSelector + "))" ) ) {
371
372 // Support: IE 11+
373 // Throw to get to the same code path as an error directly in qSA.
374 // Note: once we only support browser supporting
375 // `CSS.supports('selector(...)')`, we can most likely drop
376 // the `try-catch`. IE doesn't implement the API.
377 throw new Error();
378 }
379
380 push.apply( results,
381 newContext.querySelectorAll( newSelector )
382 );
383 return results;
384 } catch ( qsaError ) {
385 nonnativeSelectorCache( selector, true );
386 } finally {
387 if ( nid === expando ) {
388 context.removeAttribute( "id" );
389 }
390 }
391 }
392 }
393 }
394
395 // All others
396 return select( selector.replace( rtrim, "$1" ), context, results, seed );
397}
398
399/**
400 * Create key-value caches of limited size
401 * @returns {function(string, object)} Returns the Object data after storing it on itself with
402 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
403 * deleting the oldest entry
404 */
405function createCache() {
406 var keys = [];
407
408 function cache( key, value ) {
409
410 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
411 if ( keys.push( key + " " ) > Expr.cacheLength ) {
412
413 // Only keep the most recent entries
414 delete cache[ keys.shift() ];
415 }
416 return ( cache[ key + " " ] = value );
417 }
418 return cache;
419}
420
421/**
422 * Mark a function for special use by Sizzle
423 * @param {Function} fn The function to mark
424 */
425function markFunction( fn ) {
426 fn[ expando ] = true;
427 return fn;
428}
429
430/**
431 * Support testing using an element
432 * @param {Function} fn Passed the created element and returns a boolean result
433 */
434function assert( fn ) {
435 var el = document.createElement( "fieldset" );
436
437 try {
438 return !!fn( el );
439 } catch ( e ) {
440 return false;
441 } finally {
442
443 // Remove from its parent by default
444 if ( el.parentNode ) {
445 el.parentNode.removeChild( el );
446 }
447
448 // release memory in IE
449 el = null;
450 }
451}
452
453/**
454 * Adds the same handler for all of the specified attrs
455 * @param {String} attrs Pipe-separated list of attributes
456 * @param {Function} handler The method that will be applied
457 */
458function addHandle( attrs, handler ) {
459 var arr = attrs.split( "|" ),
460 i = arr.length;
461
462 while ( i-- ) {
463 Expr.attrHandle[ arr[ i ] ] = handler;
464 }
465}
466
467/**
468 * Checks document order of two siblings
469 * @param {Element} a
470 * @param {Element} b
471 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
472 */
473function siblingCheck( a, b ) {
474 var cur = b && a,
475 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
476 a.sourceIndex - b.sourceIndex;
477
478 // Use IE sourceIndex if available on both nodes
479 if ( diff ) {
480 return diff;
481 }
482
483 // Check if b follows a
484 if ( cur ) {
485 while ( ( cur = cur.nextSibling ) ) {
486 if ( cur === b ) {
487 return -1;
488 }
489 }
490 }
491
492 return a ? 1 : -1;
493}
494
495/**
496 * Returns a function to use in pseudos for input types
497 * @param {String} type
498 */
499function createInputPseudo( type ) {
500 return function( elem ) {
501 var name = elem.nodeName.toLowerCase();
502 return name === "input" && elem.type === type;
503 };
504}
505
506/**
507 * Returns a function to use in pseudos for buttons
508 * @param {String} type
509 */
510function createButtonPseudo( type ) {
511 return function( elem ) {
512 var name = elem.nodeName.toLowerCase();
513 return ( name === "input" || name === "button" ) && elem.type === type;
514 };
515}
516
517/**
518 * Returns a function to use in pseudos for :enabled/:disabled
519 * @param {Boolean} disabled true for :disabled; false for :enabled
520 */
521function createDisabledPseudo( disabled ) {
522
523 // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
524 return function( elem ) {
525
526 // Only certain elements can match :enabled or :disabled
527 // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
528 // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
529 if ( "form" in elem ) {
530
531 // Check for inherited disabledness on relevant non-disabled elements:
532 // * listed form-associated elements in a disabled fieldset
533 // https://html.spec.whatwg.org/multipage/forms.html#category-listed
534 // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
535 // * option elements in a disabled optgroup
536 // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
537 // All such elements have a "form" property.
538 if ( elem.parentNode && elem.disabled === false ) {
539
540 // Option elements defer to a parent optgroup if present
541 if ( "label" in elem ) {
542 if ( "label" in elem.parentNode ) {
543 return elem.parentNode.disabled === disabled;
544 } else {
545 return elem.disabled === disabled;
546 }
547 }
548
549 // Support: IE 6 - 11
550 // Use the isDisabled shortcut property to check for disabled fieldset ancestors
551 return elem.isDisabled === disabled ||
552
553 // Where there is no isDisabled, check manually
554 /* jshint -W018 */
555 elem.isDisabled !== !disabled &&
556 inDisabledFieldset( elem ) === disabled;
557 }
558
559 return elem.disabled === disabled;
560
561 // Try to winnow out elements that can't be disabled before trusting the disabled property.
562 // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
563 // even exist on them, let alone have a boolean value.
564 } else if ( "label" in elem ) {
565 return elem.disabled === disabled;
566 }
567
568 // Remaining elements are neither :enabled nor :disabled
569 return false;
570 };
571}
572
573/**
574 * Returns a function to use in pseudos for positionals
575 * @param {Function} fn
576 */
577function createPositionalPseudo( fn ) {
578 return markFunction( function( argument ) {
579 argument = +argument;
580 return markFunction( function( seed, matches ) {
581 var j,
582 matchIndexes = fn( [], seed.length, argument ),
583 i = matchIndexes.length;
584
585 // Match elements found at the specified indexes
586 while ( i-- ) {
587 if ( seed[ ( j = matchIndexes[ i ] ) ] ) {
588 seed[ j ] = !( matches[ j ] = seed[ j ] );
589 }
590 }
591 } );
592 } );
593}
594
595/**
596 * Checks a node for validity as a Sizzle context
597 * @param {Element|Object=} context
598 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
599 */
600function testContext( context ) {
601 return context && typeof context.getElementsByTagName !== "undefined" && context;
602}
603
604// Expose support vars for convenience
605support = Sizzle.support = {};
606
607/**
608 * Detects XML nodes
609 * @param {Element|Object} elem An element or a document
610 * @returns {Boolean} True iff elem is a non-HTML XML node
611 */
612isXML = Sizzle.isXML = function( elem ) {
613 var namespace = elem && elem.namespaceURI,
614 docElem = elem && ( elem.ownerDocument || elem ).documentElement;
615
616 // Support: IE <=8
617 // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
618 // https://bugs.jquery.com/ticket/4833
619 return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
620};
621
622/**
623 * Sets document-related variables once based on the current document
624 * @param {Element|Object} [doc] An element or document object to use to set the document
625 * @returns {Object} Returns the current document
626 */
627setDocument = Sizzle.setDocument = function( node ) {
628 var hasCompare, subWindow,
629 doc = node ? node.ownerDocument || node : preferredDoc;
630
631 // Return early if doc is invalid or already selected
632 // Support: IE 11+, Edge 17 - 18+
633 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
634 // two documents; shallow comparisons work.
635 // eslint-disable-next-line eqeqeq
636 if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) {
637 return document;
638 }
639
640 // Update global variables
641 document = doc;
642 docElem = document.documentElement;
643 documentIsHTML = !isXML( document );
644
645 // Support: IE 9 - 11+, Edge 12 - 18+
646 // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
647 // Support: IE 11+, Edge 17 - 18+
648 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
649 // two documents; shallow comparisons work.
650 // eslint-disable-next-line eqeqeq
651 if ( preferredDoc != document &&
652 ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) {
653
654 // Support: IE 11, Edge
655 if ( subWindow.addEventListener ) {
656 subWindow.addEventListener( "unload", unloadHandler, false );
657
658 // Support: IE 9 - 10 only
659 } else if ( subWindow.attachEvent ) {
660 subWindow.attachEvent( "onunload", unloadHandler );
661 }
662 }
663
664 // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only,
665 // Safari 4 - 5 only, Opera <=11.6 - 12.x only
666 // IE/Edge & older browsers don't support the :scope pseudo-class.
667 // Support: Safari 6.0 only
668 // Safari 6.0 supports :scope but it's an alias of :root there.
669 support.scope = assert( function( el ) {
670 docElem.appendChild( el ).appendChild( document.createElement( "div" ) );
671 return typeof el.querySelectorAll !== "undefined" &&
672 !el.querySelectorAll( ":scope fieldset div" ).length;
673 } );
674
675 // Support: Chrome 105+, Firefox 104+, Safari 15.4+
676 // Make sure forgiving mode is not used in `CSS.supports( "selector(...)" )`.
677 //
678 // `:is()` uses a forgiving selector list as an argument and is widely
679 // implemented, so it's a good one to test against.
680 support.cssSupportsSelector = assert( function() {
681 /* eslint-disable no-undef */
682
683 return CSS.supports( "selector(*)" ) &&
684
685 // Support: Firefox 78-81 only
686 // In old Firefox, `:is()` didn't use forgiving parsing. In that case,
687 // fail this test as there's no selector to test against that.
688 // `CSS.supports` uses unforgiving parsing
689 document.querySelectorAll( ":is(:jqfake)" ) &&
690
691 // `*` is needed as Safari & newer Chrome implemented something in between
692 // for `:has()` - it throws in `qSA` if it only contains an unsupported
693 // argument but multiple ones, one of which is supported, are fine.
694 // We want to play safe in case `:is()` gets the same treatment.
695 !CSS.supports( "selector(:is(*,:jqfake))" );
696
697 /* eslint-enable */
698 } );
699
700 /* Attributes
701 ---------------------------------------------------------------------- */
702
703 // Support: IE<8
704 // Verify that getAttribute really returns attributes and not properties
705 // (excepting IE8 booleans)
706 support.attributes = assert( function( el ) {
707 el.className = "i";
708 return !el.getAttribute( "className" );
709 } );
710
711 /* getElement(s)By*
712 ---------------------------------------------------------------------- */
713
714 // Check if getElementsByTagName("*") returns only elements
715 support.getElementsByTagName = assert( function( el ) {
716 el.appendChild( document.createComment( "" ) );
717 return !el.getElementsByTagName( "*" ).length;
718 } );
719
720 // Support: IE<9
721 support.getElementsByClassName = rnative.test( document.getElementsByClassName );
722
723 // Support: IE<10
724 // Check if getElementById returns elements by name
725 // The broken getElementById methods don't pick up programmatically-set names,
726 // so use a roundabout getElementsByName test
727 support.getById = assert( function( el ) {
728 docElem.appendChild( el ).id = expando;
729 return !document.getElementsByName || !document.getElementsByName( expando ).length;
730 } );
731
732 // ID filter and find
733 if ( support.getById ) {
734 Expr.filter[ "ID" ] = function( id ) {
735 var attrId = id.replace( runescape, funescape );
736 return function( elem ) {
737 return elem.getAttribute( "id" ) === attrId;
738 };
739 };
740 Expr.find[ "ID" ] = function( id, context ) {
741 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
742 var elem = context.getElementById( id );
743 return elem ? [ elem ] : [];
744 }
745 };
746 } else {
747 Expr.filter[ "ID" ] = function( id ) {
748 var attrId = id.replace( runescape, funescape );
749 return function( elem ) {
750 var node = typeof elem.getAttributeNode !== "undefined" &&
751 elem.getAttributeNode( "id" );
752 return node && node.value === attrId;
753 };
754 };
755
756 // Support: IE 6 - 7 only
757 // getElementById is not reliable as a find shortcut
758 Expr.find[ "ID" ] = function( id, context ) {
759 if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
760 var node, i, elems,
761 elem = context.getElementById( id );
762
763 if ( elem ) {
764
765 // Verify the id attribute
766 node = elem.getAttributeNode( "id" );
767 if ( node && node.value === id ) {
768 return [ elem ];
769 }
770
771 // Fall back on getElementsByName
772 elems = context.getElementsByName( id );
773 i = 0;
774 while ( ( elem = elems[ i++ ] ) ) {
775 node = elem.getAttributeNode( "id" );
776 if ( node && node.value === id ) {
777 return [ elem ];
778 }
779 }
780 }
781
782 return [];
783 }
784 };
785 }
786
787 // Tag
788 Expr.find[ "TAG" ] = support.getElementsByTagName ?
789 function( tag, context ) {
790 if ( typeof context.getElementsByTagName !== "undefined" ) {
791 return context.getElementsByTagName( tag );
792
793 // DocumentFragment nodes don't have gEBTN
794 } else if ( support.qsa ) {
795 return context.querySelectorAll( tag );
796 }
797 } :
798
799 function( tag, context ) {
800 var elem,
801 tmp = [],
802 i = 0,
803
804 // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
805 results = context.getElementsByTagName( tag );
806
807 // Filter out possible comments
808 if ( tag === "*" ) {
809 while ( ( elem = results[ i++ ] ) ) {
810 if ( elem.nodeType === 1 ) {
811 tmp.push( elem );
812 }
813 }
814
815 return tmp;
816 }
817 return results;
818 };
819
820 // Class
821 Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) {
822 if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
823 return context.getElementsByClassName( className );
824 }
825 };
826
827 /* QSA/matchesSelector
828 ---------------------------------------------------------------------- */
829
830 // QSA and matchesSelector support
831
832 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
833 rbuggyMatches = [];
834
835 // qSa(:focus) reports false when true (Chrome 21)
836 // We allow this because of a bug in IE8/9 that throws an error
837 // whenever `document.activeElement` is accessed on an iframe
838 // So, we allow :focus to pass through QSA all the time to avoid the IE error
839 // See https://bugs.jquery.com/ticket/13378
840 rbuggyQSA = [];
841
842 if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) {
843
844 // Build QSA regex
845 // Regex strategy adopted from Diego Perini
846 assert( function( el ) {
847
848 var input;
849
850 // Select is set to empty string on purpose
851 // This is to test IE's treatment of not explicitly
852 // setting a boolean content attribute,
853 // since its presence should be enough
854 // https://bugs.jquery.com/ticket/12359
855 docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
856 "<select id='" + expando + "-\r\\' msallowcapture=''>" +
857 "<option selected=''></option></select>";
858
859 // Support: IE8, Opera 11-12.16
860 // Nothing should be selected when empty strings follow ^= or $= or *=
861 // The test attribute must be unknown in Opera but "safe" for WinRT
862 // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
863 if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) {
864 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
865 }
866
867 // Support: IE8
868 // Boolean attributes and "value" are not treated correctly
869 if ( !el.querySelectorAll( "[selected]" ).length ) {
870 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
871 }
872
873 // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
874 if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
875 rbuggyQSA.push( "~=" );
876 }
877
878 // Support: IE 11+, Edge 15 - 18+
879 // IE 11/Edge don't find elements on a `[name='']` query in some cases.
880 // Adding a temporary attribute to the document before the selection works
881 // around the issue.
882 // Interestingly, IE 10 & older don't seem to have the issue.
883 input = document.createElement( "input" );
884 input.setAttribute( "name", "" );
885 el.appendChild( input );
886 if ( !el.querySelectorAll( "[name='']" ).length ) {
887 rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" +
888 whitespace + "*(?:''|\"\")" );
889 }
890
891 // Webkit/Opera - :checked should return selected option elements
892 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
893 // IE8 throws error here and will not see later tests
894 if ( !el.querySelectorAll( ":checked" ).length ) {
895 rbuggyQSA.push( ":checked" );
896 }
897
898 // Support: Safari 8+, iOS 8+
899 // https://bugs.webkit.org/show_bug.cgi?id=136851
900 // In-page `selector#id sibling-combinator selector` fails
901 if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
902 rbuggyQSA.push( ".#.+[+~]" );
903 }
904
905 // Support: Firefox <=3.6 - 5 only
906 // Old Firefox doesn't throw on a badly-escaped identifier.
907 el.querySelectorAll( "\\\f" );
908 rbuggyQSA.push( "[\\r\\n\\f]" );
909 } );
910
911 assert( function( el ) {
912 el.innerHTML = "<a href='' disabled='disabled'></a>" +
913 "<select disabled='disabled'><option/></select>";
914
915 // Support: Windows 8 Native Apps
916 // The type and name attributes are restricted during .innerHTML assignment
917 var input = document.createElement( "input" );
918 input.setAttribute( "type", "hidden" );
919 el.appendChild( input ).setAttribute( "name", "D" );
920
921 // Support: IE8
922 // Enforce case-sensitivity of name attribute
923 if ( el.querySelectorAll( "[name=d]" ).length ) {
924 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
925 }
926
927 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
928 // IE8 throws error here and will not see later tests
929 if ( el.querySelectorAll( ":enabled" ).length !== 2 ) {
930 rbuggyQSA.push( ":enabled", ":disabled" );
931 }
932
933 // Support: IE9-11+
934 // IE's :disabled selector does not pick up the children of disabled fieldsets
935 docElem.appendChild( el ).disabled = true;
936 if ( el.querySelectorAll( ":disabled" ).length !== 2 ) {
937 rbuggyQSA.push( ":enabled", ":disabled" );
938 }
939
940 // Support: Opera 10 - 11 only
941 // Opera 10-11 does not throw on post-comma invalid pseudos
942 el.querySelectorAll( "*,:x" );
943 rbuggyQSA.push( ",.*:" );
944 } );
945 }
946
947 if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches ||
948 docElem.webkitMatchesSelector ||
949 docElem.mozMatchesSelector ||
950 docElem.oMatchesSelector ||
951 docElem.msMatchesSelector ) ) ) ) {
952
953 assert( function( el ) {
954
955 // Check to see if it's possible to do matchesSelector
956 // on a disconnected node (IE 9)
957 support.disconnectedMatch = matches.call( el, "*" );
958
959 // This should fail with an exception
960 // Gecko does not error, returns false instead
961 matches.call( el, "[s!='']:x" );
962 rbuggyMatches.push( "!=", pseudos );
963 } );
964 }
965
966 if ( !support.cssSupportsSelector ) {
967
968 // Support: Chrome 105+, Safari 15.4+
969 // `:has()` uses a forgiving selector list as an argument so our regular
970 // `try-catch` mechanism fails to catch `:has()` with arguments not supported
971 // natively like `:has(:contains("Foo"))`. Where supported & spec-compliant,
972 // we now use `CSS.supports("selector(:is(SELECTOR_TO_BE_TESTED))")`, but
973 // outside that we mark `:has` as buggy.
974 rbuggyQSA.push( ":has" );
975 }
976
977 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) );
978 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) );
979
980 /* Contains
981 ---------------------------------------------------------------------- */
982 hasCompare = rnative.test( docElem.compareDocumentPosition );
983
984 // Element contains another
985 // Purposefully self-exclusive
986 // As in, an element does not contain itself
987 contains = hasCompare || rnative.test( docElem.contains ) ?
988 function( a, b ) {
989
990 // Support: IE <9 only
991 // IE doesn't have `contains` on `document` so we need to check for
992 // `documentElement` presence.
993 // We need to fall back to `a` when `documentElement` is missing
994 // as `ownerDocument` of elements within `<template/>` may have
995 // a null one - a default behavior of all modern browsers.
996 var adown = a.nodeType === 9 && a.documentElement || a,
997 bup = b && b.parentNode;
998 return a === bup || !!( bup && bup.nodeType === 1 && (
999 adown.contains ?
1000 adown.contains( bup ) :
1001 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
1002 ) );
1003 } :
1004 function( a, b ) {
1005 if ( b ) {
1006 while ( ( b = b.parentNode ) ) {
1007 if ( b === a ) {
1008 return true;
1009 }
1010 }
1011 }
1012 return false;
1013 };
1014
1015 /* Sorting
1016 ---------------------------------------------------------------------- */
1017
1018 // Document order sorting
1019 sortOrder = hasCompare ?
1020 function( a, b ) {
1021
1022 // Flag for duplicate removal
1023 if ( a === b ) {
1024 hasDuplicate = true;
1025 return 0;
1026 }
1027
1028 // Sort on method existence if only one input has compareDocumentPosition
1029 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
1030 if ( compare ) {
1031 return compare;
1032 }
1033
1034 // Calculate position if both inputs belong to the same document
1035 // Support: IE 11+, Edge 17 - 18+
1036 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1037 // two documents; shallow comparisons work.
1038 // eslint-disable-next-line eqeqeq
1039 compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ?
1040 a.compareDocumentPosition( b ) :
1041
1042 // Otherwise we know they are disconnected
1043 1;
1044
1045 // Disconnected nodes
1046 if ( compare & 1 ||
1047 ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) {
1048
1049 // Choose the first element that is related to our preferred document
1050 // Support: IE 11+, Edge 17 - 18+
1051 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1052 // two documents; shallow comparisons work.
1053 // eslint-disable-next-line eqeqeq
1054 if ( a == document || a.ownerDocument == preferredDoc &&
1055 contains( preferredDoc, a ) ) {
1056 return -1;
1057 }
1058
1059 // Support: IE 11+, Edge 17 - 18+
1060 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1061 // two documents; shallow comparisons work.
1062 // eslint-disable-next-line eqeqeq
1063 if ( b == document || b.ownerDocument == preferredDoc &&
1064 contains( preferredDoc, b ) ) {
1065 return 1;
1066 }
1067
1068 // Maintain original order
1069 return sortInput ?
1070 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1071 0;
1072 }
1073
1074 return compare & 4 ? -1 : 1;
1075 } :
1076 function( a, b ) {
1077
1078 // Exit early if the nodes are identical
1079 if ( a === b ) {
1080 hasDuplicate = true;
1081 return 0;
1082 }
1083
1084 var cur,
1085 i = 0,
1086 aup = a.parentNode,
1087 bup = b.parentNode,
1088 ap = [ a ],
1089 bp = [ b ];
1090
1091 // Parentless nodes are either documents or disconnected
1092 if ( !aup || !bup ) {
1093
1094 // Support: IE 11+, Edge 17 - 18+
1095 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1096 // two documents; shallow comparisons work.
1097 /* eslint-disable eqeqeq */
1098 return a == document ? -1 :
1099 b == document ? 1 :
1100 /* eslint-enable eqeqeq */
1101 aup ? -1 :
1102 bup ? 1 :
1103 sortInput ?
1104 ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
1105 0;
1106
1107 // If the nodes are siblings, we can do a quick check
1108 } else if ( aup === bup ) {
1109 return siblingCheck( a, b );
1110 }
1111
1112 // Otherwise we need full lists of their ancestors for comparison
1113 cur = a;
1114 while ( ( cur = cur.parentNode ) ) {
1115 ap.unshift( cur );
1116 }
1117 cur = b;
1118 while ( ( cur = cur.parentNode ) ) {
1119 bp.unshift( cur );
1120 }
1121
1122 // Walk down the tree looking for a discrepancy
1123 while ( ap[ i ] === bp[ i ] ) {
1124 i++;
1125 }
1126
1127 return i ?
1128
1129 // Do a sibling check if the nodes have a common ancestor
1130 siblingCheck( ap[ i ], bp[ i ] ) :
1131
1132 // Otherwise nodes in our document sort first
1133 // Support: IE 11+, Edge 17 - 18+
1134 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1135 // two documents; shallow comparisons work.
1136 /* eslint-disable eqeqeq */
1137 ap[ i ] == preferredDoc ? -1 :
1138 bp[ i ] == preferredDoc ? 1 :
1139 /* eslint-enable eqeqeq */
1140 0;
1141 };
1142
1143 return document;
1144};
1145
1146Sizzle.matches = function( expr, elements ) {
1147 return Sizzle( expr, null, null, elements );
1148};
1149
1150Sizzle.matchesSelector = function( elem, expr ) {
1151 setDocument( elem );
1152
1153 if ( support.matchesSelector && documentIsHTML &&
1154 !nonnativeSelectorCache[ expr + " " ] &&
1155 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
1156 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
1157
1158 try {
1159 var ret = matches.call( elem, expr );
1160
1161 // IE 9's matchesSelector returns false on disconnected nodes
1162 if ( ret || support.disconnectedMatch ||
1163
1164 // As well, disconnected nodes are said to be in a document
1165 // fragment in IE 9
1166 elem.document && elem.document.nodeType !== 11 ) {
1167 return ret;
1168 }
1169 } catch ( e ) {
1170 nonnativeSelectorCache( expr, true );
1171 }
1172 }
1173
1174 return Sizzle( expr, document, null, [ elem ] ).length > 0;
1175};
1176
1177Sizzle.contains = function( context, elem ) {
1178
1179 // Set document vars if needed
1180 // Support: IE 11+, Edge 17 - 18+
1181 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1182 // two documents; shallow comparisons work.
1183 // eslint-disable-next-line eqeqeq
1184 if ( ( context.ownerDocument || context ) != document ) {
1185 setDocument( context );
1186 }
1187 return contains( context, elem );
1188};
1189
1190Sizzle.attr = function( elem, name ) {
1191
1192 // Set document vars if needed
1193 // Support: IE 11+, Edge 17 - 18+
1194 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
1195 // two documents; shallow comparisons work.
1196 // eslint-disable-next-line eqeqeq
1197 if ( ( elem.ownerDocument || elem ) != document ) {
1198 setDocument( elem );
1199 }
1200
1201 var fn = Expr.attrHandle[ name.toLowerCase() ],
1202
1203 // Don't get fooled by Object.prototype properties (jQuery #13807)
1204 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
1205 fn( elem, name, !documentIsHTML ) :
1206 undefined;
1207
1208 return val !== undefined ?
1209 val :
1210 support.attributes || !documentIsHTML ?
1211 elem.getAttribute( name ) :
1212 ( val = elem.getAttributeNode( name ) ) && val.specified ?
1213 val.value :
1214 null;
1215};
1216
1217Sizzle.escape = function( sel ) {
1218 return ( sel + "" ).replace( rcssescape, fcssescape );
1219};
1220
1221Sizzle.error = function( msg ) {
1222 throw new Error( "Syntax error, unrecognized expression: " + msg );
1223};
1224
1225/**
1226 * Document sorting and removing duplicates
1227 * @param {ArrayLike} results
1228 */
1229Sizzle.uniqueSort = function( results ) {
1230 var elem,
1231 duplicates = [],
1232 j = 0,
1233 i = 0;
1234
1235 // Unless we *know* we can detect duplicates, assume their presence
1236 hasDuplicate = !support.detectDuplicates;
1237 sortInput = !support.sortStable && results.slice( 0 );
1238 results.sort( sortOrder );
1239
1240 if ( hasDuplicate ) {
1241 while ( ( elem = results[ i++ ] ) ) {
1242 if ( elem === results[ i ] ) {
1243 j = duplicates.push( i );
1244 }
1245 }
1246 while ( j-- ) {
1247 results.splice( duplicates[ j ], 1 );
1248 }
1249 }
1250
1251 // Clear input after sorting to release objects
1252 // See https://github.com/jquery/sizzle/pull/225
1253 sortInput = null;
1254
1255 return results;
1256};
1257
1258/**
1259 * Utility function for retrieving the text value of an array of DOM nodes
1260 * @param {Array|Element} elem
1261 */
1262getText = Sizzle.getText = function( elem ) {
1263 var node,
1264 ret = "",
1265 i = 0,
1266 nodeType = elem.nodeType;
1267
1268 if ( !nodeType ) {
1269
1270 // If no nodeType, this is expected to be an array
1271 while ( ( node = elem[ i++ ] ) ) {
1272
1273 // Do not traverse comment nodes
1274 ret += getText( node );
1275 }
1276 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
1277
1278 // Use textContent for elements
1279 // innerText usage removed for consistency of new lines (jQuery #11153)
1280 if ( typeof elem.textContent === "string" ) {
1281 return elem.textContent;
1282 } else {
1283
1284 // Traverse its children
1285 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1286 ret += getText( elem );
1287 }
1288 }
1289 } else if ( nodeType === 3 || nodeType === 4 ) {
1290 return elem.nodeValue;
1291 }
1292
1293 // Do not include comment or processing instruction nodes
1294
1295 return ret;
1296};
1297
1298Expr = Sizzle.selectors = {
1299
1300 // Can be adjusted by the user
1301 cacheLength: 50,
1302
1303 createPseudo: markFunction,
1304
1305 match: matchExpr,
1306
1307 attrHandle: {},
1308
1309 find: {},
1310
1311 relative: {
1312 ">": { dir: "parentNode", first: true },
1313 " ": { dir: "parentNode" },
1314 "+": { dir: "previousSibling", first: true },
1315 "~": { dir: "previousSibling" }
1316 },
1317
1318 preFilter: {
1319 "ATTR": function( match ) {
1320 match[ 1 ] = match[ 1 ].replace( runescape, funescape );
1321
1322 // Move the given value to match[3] whether quoted or unquoted
1323 match[ 3 ] = ( match[ 3 ] || match[ 4 ] ||
1324 match[ 5 ] || "" ).replace( runescape, funescape );
1325
1326 if ( match[ 2 ] === "~=" ) {
1327 match[ 3 ] = " " + match[ 3 ] + " ";
1328 }
1329
1330 return match.slice( 0, 4 );
1331 },
1332
1333 "CHILD": function( match ) {
1334
1335 /* matches from matchExpr["CHILD"]
1336 1 type (only|nth|...)
1337 2 what (child|of-type)
1338 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
1339 4 xn-component of xn+y argument ([+-]?\d*n|)
1340 5 sign of xn-component
1341 6 x of xn-component
1342 7 sign of y-component
1343 8 y of y-component
1344 */
1345 match[ 1 ] = match[ 1 ].toLowerCase();
1346
1347 if ( match[ 1 ].slice( 0, 3 ) === "nth" ) {
1348
1349 // nth-* requires argument
1350 if ( !match[ 3 ] ) {
1351 Sizzle.error( match[ 0 ] );
1352 }
1353
1354 // numeric x and y parameters for Expr.filter.CHILD
1355 // remember that false/true cast respectively to 0/1
1356 match[ 4 ] = +( match[ 4 ] ?
1357 match[ 5 ] + ( match[ 6 ] || 1 ) :
1358 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) );
1359 match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" );
1360
1361 // other types prohibit arguments
1362 } else if ( match[ 3 ] ) {
1363 Sizzle.error( match[ 0 ] );
1364 }
1365
1366 return match;
1367 },
1368
1369 "PSEUDO": function( match ) {
1370 var excess,
1371 unquoted = !match[ 6 ] && match[ 2 ];
1372
1373 if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) {
1374 return null;
1375 }
1376
1377 // Accept quoted arguments as-is
1378 if ( match[ 3 ] ) {
1379 match[ 2 ] = match[ 4 ] || match[ 5 ] || "";
1380
1381 // Strip excess characters from unquoted arguments
1382 } else if ( unquoted && rpseudo.test( unquoted ) &&
1383
1384 // Get excess from tokenize (recursively)
1385 ( excess = tokenize( unquoted, true ) ) &&
1386
1387 // advance to the next closing parenthesis
1388 ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) {
1389
1390 // excess is a negative index
1391 match[ 0 ] = match[ 0 ].slice( 0, excess );
1392 match[ 2 ] = unquoted.slice( 0, excess );
1393 }
1394
1395 // Return only captures needed by the pseudo filter method (type and argument)
1396 return match.slice( 0, 3 );
1397 }
1398 },
1399
1400 filter: {
1401
1402 "TAG": function( nodeNameSelector ) {
1403 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1404 return nodeNameSelector === "*" ?
1405 function() {
1406 return true;
1407 } :
1408 function( elem ) {
1409 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1410 };
1411 },
1412
1413 "CLASS": function( className ) {
1414 var pattern = classCache[ className + " " ];
1415
1416 return pattern ||
1417 ( pattern = new RegExp( "(^|" + whitespace +
1418 ")" + className + "(" + whitespace + "|$)" ) ) && classCache(
1419 className, function( elem ) {
1420 return pattern.test(
1421 typeof elem.className === "string" && elem.className ||
1422 typeof elem.getAttribute !== "undefined" &&
1423 elem.getAttribute( "class" ) ||
1424 ""
1425 );
1426 } );
1427 },
1428
1429 "ATTR": function( name, operator, check ) {
1430 return function( elem ) {
1431 var result = Sizzle.attr( elem, name );
1432
1433 if ( result == null ) {
1434 return operator === "!=";
1435 }
1436 if ( !operator ) {
1437 return true;
1438 }
1439
1440 result += "";
1441
1442 /* eslint-disable max-len */
1443
1444 return operator === "=" ? result === check :
1445 operator === "!=" ? result !== check :
1446 operator === "^=" ? check && result.indexOf( check ) === 0 :
1447 operator === "*=" ? check && result.indexOf( check ) > -1 :
1448 operator === "$=" ? check && result.slice( -check.length ) === check :
1449 operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
1450 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1451 false;
1452 /* eslint-enable max-len */
1453
1454 };
1455 },
1456
1457 "CHILD": function( type, what, _argument, first, last ) {
1458 var simple = type.slice( 0, 3 ) !== "nth",
1459 forward = type.slice( -4 ) !== "last",
1460 ofType = what === "of-type";
1461
1462 return first === 1 && last === 0 ?
1463
1464 // Shortcut for :nth-*(n)
1465 function( elem ) {
1466 return !!elem.parentNode;
1467 } :
1468
1469 function( elem, _context, xml ) {
1470 var cache, uniqueCache, outerCache, node, nodeIndex, start,
1471 dir = simple !== forward ? "nextSibling" : "previousSibling",
1472 parent = elem.parentNode,
1473 name = ofType && elem.nodeName.toLowerCase(),
1474 useCache = !xml && !ofType,
1475 diff = false;
1476
1477 if ( parent ) {
1478
1479 // :(first|last|only)-(child|of-type)
1480 if ( simple ) {
1481 while ( dir ) {
1482 node = elem;
1483 while ( ( node = node[ dir ] ) ) {
1484 if ( ofType ?
1485 node.nodeName.toLowerCase() === name :
1486 node.nodeType === 1 ) {
1487
1488 return false;
1489 }
1490 }
1491
1492 // Reverse direction for :only-* (if we haven't yet done so)
1493 start = dir = type === "only" && !start && "nextSibling";
1494 }
1495 return true;
1496 }
1497
1498 start = [ forward ? parent.firstChild : parent.lastChild ];
1499
1500 // non-xml :nth-child(...) stores cache data on `parent`
1501 if ( forward && useCache ) {
1502
1503 // Seek `elem` from a previously-cached index
1504
1505 // ...in a gzip-friendly way
1506 node = parent;
1507 outerCache = node[ expando ] || ( node[ expando ] = {} );
1508
1509 // Support: IE <9 only
1510 // Defend against cloned attroperties (jQuery gh-1709)
1511 uniqueCache = outerCache[ node.uniqueID ] ||
1512 ( outerCache[ node.uniqueID ] = {} );
1513
1514 cache = uniqueCache[ type ] || [];
1515 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1516 diff = nodeIndex && cache[ 2 ];
1517 node = nodeIndex && parent.childNodes[ nodeIndex ];
1518
1519 while ( ( node = ++nodeIndex && node && node[ dir ] ||
1520
1521 // Fallback to seeking `elem` from the start
1522 ( diff = nodeIndex = 0 ) || start.pop() ) ) {
1523
1524 // When found, cache indexes on `parent` and break
1525 if ( node.nodeType === 1 && ++diff && node === elem ) {
1526 uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
1527 break;
1528 }
1529 }
1530
1531 } else {
1532
1533 // Use previously-cached element index if available
1534 if ( useCache ) {
1535
1536 // ...in a gzip-friendly way
1537 node = elem;
1538 outerCache = node[ expando ] || ( node[ expando ] = {} );
1539
1540 // Support: IE <9 only
1541 // Defend against cloned attroperties (jQuery gh-1709)
1542 uniqueCache = outerCache[ node.uniqueID ] ||
1543 ( outerCache[ node.uniqueID ] = {} );
1544
1545 cache = uniqueCache[ type ] || [];
1546 nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
1547 diff = nodeIndex;
1548 }
1549
1550 // xml :nth-child(...)
1551 // or :nth-last-child(...) or :nth(-last)?-of-type(...)
1552 if ( diff === false ) {
1553
1554 // Use the same loop as above to seek `elem` from the start
1555 while ( ( node = ++nodeIndex && node && node[ dir ] ||
1556 ( diff = nodeIndex = 0 ) || start.pop() ) ) {
1557
1558 if ( ( ofType ?
1559 node.nodeName.toLowerCase() === name :
1560 node.nodeType === 1 ) &&
1561 ++diff ) {
1562
1563 // Cache the index of each encountered element
1564 if ( useCache ) {
1565 outerCache = node[ expando ] ||
1566 ( node[ expando ] = {} );
1567
1568 // Support: IE <9 only
1569 // Defend against cloned attroperties (jQuery gh-1709)
1570 uniqueCache = outerCache[ node.uniqueID ] ||
1571 ( outerCache[ node.uniqueID ] = {} );
1572
1573 uniqueCache[ type ] = [ dirruns, diff ];
1574 }
1575
1576 if ( node === elem ) {
1577 break;
1578 }
1579 }
1580 }
1581 }
1582 }
1583
1584 // Incorporate the offset, then check against cycle size
1585 diff -= last;
1586 return diff === first || ( diff % first === 0 && diff / first >= 0 );
1587 }
1588 };
1589 },
1590
1591 "PSEUDO": function( pseudo, argument ) {
1592
1593 // pseudo-class names are case-insensitive
1594 // http://www.w3.org/TR/selectors/#pseudo-classes
1595 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1596 // Remember that setFilters inherits from pseudos
1597 var args,
1598 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1599 Sizzle.error( "unsupported pseudo: " + pseudo );
1600
1601 // The user may use createPseudo to indicate that
1602 // arguments are needed to create the filter function
1603 // just as Sizzle does
1604 if ( fn[ expando ] ) {
1605 return fn( argument );
1606 }
1607
1608 // But maintain support for old signatures
1609 if ( fn.length > 1 ) {
1610 args = [ pseudo, pseudo, "", argument ];
1611 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1612 markFunction( function( seed, matches ) {
1613 var idx,
1614 matched = fn( seed, argument ),
1615 i = matched.length;
1616 while ( i-- ) {
1617 idx = indexOf( seed, matched[ i ] );
1618 seed[ idx ] = !( matches[ idx ] = matched[ i ] );
1619 }
1620 } ) :
1621 function( elem ) {
1622 return fn( elem, 0, args );
1623 };
1624 }
1625
1626 return fn;
1627 }
1628 },
1629
1630 pseudos: {
1631
1632 // Potentially complex pseudos
1633 "not": markFunction( function( selector ) {
1634
1635 // Trim the selector passed to compile
1636 // to avoid treating leading and trailing
1637 // spaces as combinators
1638 var input = [],
1639 results = [],
1640 matcher = compile( selector.replace( rtrim, "$1" ) );
1641
1642 return matcher[ expando ] ?
1643 markFunction( function( seed, matches, _context, xml ) {
1644 var elem,
1645 unmatched = matcher( seed, null, xml, [] ),
1646 i = seed.length;
1647
1648 // Match elements unmatched by `matcher`
1649 while ( i-- ) {
1650 if ( ( elem = unmatched[ i ] ) ) {
1651 seed[ i ] = !( matches[ i ] = elem );
1652 }
1653 }
1654 } ) :
1655 function( elem, _context, xml ) {
1656 input[ 0 ] = elem;
1657 matcher( input, null, xml, results );
1658
1659 // Don't keep the element (issue #299)
1660 input[ 0 ] = null;
1661 return !results.pop();
1662 };
1663 } ),
1664
1665 "has": markFunction( function( selector ) {
1666 return function( elem ) {
1667 return Sizzle( selector, elem ).length > 0;
1668 };
1669 } ),
1670
1671 "contains": markFunction( function( text ) {
1672 text = text.replace( runescape, funescape );
1673 return function( elem ) {
1674 return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
1675 };
1676 } ),
1677
1678 // "Whether an element is represented by a :lang() selector
1679 // is based solely on the element's language value
1680 // being equal to the identifier C,
1681 // or beginning with the identifier C immediately followed by "-".
1682 // The matching of C against the element's language value is performed case-insensitively.
1683 // The identifier C does not have to be a valid language name."
1684 // http://www.w3.org/TR/selectors/#lang-pseudo
1685 "lang": markFunction( function( lang ) {
1686
1687 // lang value must be a valid identifier
1688 if ( !ridentifier.test( lang || "" ) ) {
1689 Sizzle.error( "unsupported lang: " + lang );
1690 }
1691 lang = lang.replace( runescape, funescape ).toLowerCase();
1692 return function( elem ) {
1693 var elemLang;
1694 do {
1695 if ( ( elemLang = documentIsHTML ?
1696 elem.lang :
1697 elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) {
1698
1699 elemLang = elemLang.toLowerCase();
1700 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1701 }
1702 } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 );
1703 return false;
1704 };
1705 } ),
1706
1707 // Miscellaneous
1708 "target": function( elem ) {
1709 var hash = window.location && window.location.hash;
1710 return hash && hash.slice( 1 ) === elem.id;
1711 },
1712
1713 "root": function( elem ) {
1714 return elem === docElem;
1715 },
1716
1717 "focus": function( elem ) {
1718 return elem === document.activeElement &&
1719 ( !document.hasFocus || document.hasFocus() ) &&
1720 !!( elem.type || elem.href || ~elem.tabIndex );
1721 },
1722
1723 // Boolean properties
1724 "enabled": createDisabledPseudo( false ),
1725 "disabled": createDisabledPseudo( true ),
1726
1727 "checked": function( elem ) {
1728
1729 // In CSS3, :checked should return both checked and selected elements
1730 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1731 var nodeName = elem.nodeName.toLowerCase();
1732 return ( nodeName === "input" && !!elem.checked ) ||
1733 ( nodeName === "option" && !!elem.selected );
1734 },
1735
1736 "selected": function( elem ) {
1737
1738 // Accessing this property makes selected-by-default
1739 // options in Safari work properly
1740 if ( elem.parentNode ) {
1741 // eslint-disable-next-line no-unused-expressions
1742 elem.parentNode.selectedIndex;
1743 }
1744
1745 return elem.selected === true;
1746 },
1747
1748 // Contents
1749 "empty": function( elem ) {
1750
1751 // http://www.w3.org/TR/selectors/#empty-pseudo
1752 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1753 // but not by others (comment: 8; processing instruction: 7; etc.)
1754 // nodeType < 6 works because attributes (2) do not appear as children
1755 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1756 if ( elem.nodeType < 6 ) {
1757 return false;
1758 }
1759 }
1760 return true;
1761 },
1762
1763 "parent": function( elem ) {
1764 return !Expr.pseudos[ "empty" ]( elem );
1765 },
1766
1767 // Element/input types
1768 "header": function( elem ) {
1769 return rheader.test( elem.nodeName );
1770 },
1771
1772 "input": function( elem ) {
1773 return rinputs.test( elem.nodeName );
1774 },
1775
1776 "button": function( elem ) {
1777 var name = elem.nodeName.toLowerCase();
1778 return name === "input" && elem.type === "button" || name === "button";
1779 },
1780
1781 "text": function( elem ) {
1782 var attr;
1783 return elem.nodeName.toLowerCase() === "input" &&
1784 elem.type === "text" &&
1785
1786 // Support: IE <10 only
1787 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1788 ( ( attr = elem.getAttribute( "type" ) ) == null ||
1789 attr.toLowerCase() === "text" );
1790 },
1791
1792 // Position-in-collection
1793 "first": createPositionalPseudo( function() {
1794 return [ 0 ];
1795 } ),
1796
1797 "last": createPositionalPseudo( function( _matchIndexes, length ) {
1798 return [ length - 1 ];
1799 } ),
1800
1801 "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) {
1802 return [ argument < 0 ? argument + length : argument ];
1803 } ),
1804
1805 "even": createPositionalPseudo( function( matchIndexes, length ) {
1806 var i = 0;
1807 for ( ; i < length; i += 2 ) {
1808 matchIndexes.push( i );
1809 }
1810 return matchIndexes;
1811 } ),
1812
1813 "odd": createPositionalPseudo( function( matchIndexes, length ) {
1814 var i = 1;
1815 for ( ; i < length; i += 2 ) {
1816 matchIndexes.push( i );
1817 }
1818 return matchIndexes;
1819 } ),
1820
1821 "lt": createPositionalPseudo( function( matchIndexes, length, argument ) {
1822 var i = argument < 0 ?
1823 argument + length :
1824 argument > length ?
1825 length :
1826 argument;
1827 for ( ; --i >= 0; ) {
1828 matchIndexes.push( i );
1829 }
1830 return matchIndexes;
1831 } ),
1832
1833 "gt": createPositionalPseudo( function( matchIndexes, length, argument ) {
1834 var i = argument < 0 ? argument + length : argument;
1835 for ( ; ++i < length; ) {
1836 matchIndexes.push( i );
1837 }
1838 return matchIndexes;
1839 } )
1840 }
1841};
1842
1843Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ];
1844
1845// Add button/input type pseudos
1846for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
1847 Expr.pseudos[ i ] = createInputPseudo( i );
1848}
1849for ( i in { submit: true, reset: true } ) {
1850 Expr.pseudos[ i ] = createButtonPseudo( i );
1851}
1852
1853// Easy API for creating new setFilters
1854function setFilters() {}
1855setFilters.prototype = Expr.filters = Expr.pseudos;
1856Expr.setFilters = new setFilters();
1857
1858tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
1859 var matched, match, tokens, type,
1860 soFar, groups, preFilters,
1861 cached = tokenCache[ selector + " " ];
1862
1863 if ( cached ) {
1864 return parseOnly ? 0 : cached.slice( 0 );
1865 }
1866
1867 soFar = selector;
1868 groups = [];
1869 preFilters = Expr.preFilter;
1870
1871 while ( soFar ) {
1872
1873 // Comma and first run
1874 if ( !matched || ( match = rcomma.exec( soFar ) ) ) {
1875 if ( match ) {
1876
1877 // Don't consume trailing commas as valid
1878 soFar = soFar.slice( match[ 0 ].length ) || soFar;
1879 }
1880 groups.push( ( tokens = [] ) );
1881 }
1882
1883 matched = false;
1884
1885 // Combinators
1886 if ( ( match = rcombinators.exec( soFar ) ) ) {
1887 matched = match.shift();
1888 tokens.push( {
1889 value: matched,
1890
1891 // Cast descendant combinators to space
1892 type: match[ 0 ].replace( rtrim, " " )
1893 } );
1894 soFar = soFar.slice( matched.length );
1895 }
1896
1897 // Filters
1898 for ( type in Expr.filter ) {
1899 if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] ||
1900 ( match = preFilters[ type ]( match ) ) ) ) {
1901 matched = match.shift();
1902 tokens.push( {
1903 value: matched,
1904 type: type,
1905 matches: match
1906 } );
1907 soFar = soFar.slice( matched.length );
1908 }
1909 }
1910
1911 if ( !matched ) {
1912 break;
1913 }
1914 }
1915
1916 // Return the length of the invalid excess
1917 // if we're just parsing
1918 // Otherwise, throw an error or return tokens
1919 return parseOnly ?
1920 soFar.length :
1921 soFar ?
1922 Sizzle.error( selector ) :
1923
1924 // Cache the tokens
1925 tokenCache( selector, groups ).slice( 0 );
1926};
1927
1928function toSelector( tokens ) {
1929 var i = 0,
1930 len = tokens.length,
1931 selector = "";
1932 for ( ; i < len; i++ ) {
1933 selector += tokens[ i ].value;
1934 }
1935 return selector;
1936}
1937
1938function addCombinator( matcher, combinator, base ) {
1939 var dir = combinator.dir,
1940 skip = combinator.next,
1941 key = skip || dir,
1942 checkNonElements = base && key === "parentNode",
1943 doneName = done++;
1944
1945 return combinator.first ?
1946
1947 // Check against closest ancestor/preceding element
1948 function( elem, context, xml ) {
1949 while ( ( elem = elem[ dir ] ) ) {
1950 if ( elem.nodeType === 1 || checkNonElements ) {
1951 return matcher( elem, context, xml );
1952 }
1953 }
1954 return false;
1955 } :
1956
1957 // Check against all ancestor/preceding elements
1958 function( elem, context, xml ) {
1959 var oldCache, uniqueCache, outerCache,
1960 newCache = [ dirruns, doneName ];
1961
1962 // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
1963 if ( xml ) {
1964 while ( ( elem = elem[ dir ] ) ) {
1965 if ( elem.nodeType === 1 || checkNonElements ) {
1966 if ( matcher( elem, context, xml ) ) {
1967 return true;
1968 }
1969 }
1970 }
1971 } else {
1972 while ( ( elem = elem[ dir ] ) ) {
1973 if ( elem.nodeType === 1 || checkNonElements ) {
1974 outerCache = elem[ expando ] || ( elem[ expando ] = {} );
1975
1976 // Support: IE <9 only
1977 // Defend against cloned attroperties (jQuery gh-1709)
1978 uniqueCache = outerCache[ elem.uniqueID ] ||
1979 ( outerCache[ elem.uniqueID ] = {} );
1980
1981 if ( skip && skip === elem.nodeName.toLowerCase() ) {
1982 elem = elem[ dir ] || elem;
1983 } else if ( ( oldCache = uniqueCache[ key ] ) &&
1984 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
1985
1986 // Assign to newCache so results back-propagate to previous elements
1987 return ( newCache[ 2 ] = oldCache[ 2 ] );
1988 } else {
1989
1990 // Reuse newcache so results back-propagate to previous elements
1991 uniqueCache[ key ] = newCache;
1992
1993 // A match means we're done; a fail means we have to keep checking
1994 if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) {
1995 return true;
1996 }
1997 }
1998 }
1999 }
2000 }
2001 return false;
2002 };
2003}
2004
2005function elementMatcher( matchers ) {
2006 return matchers.length > 1 ?
2007 function( elem, context, xml ) {
2008 var i = matchers.length;
2009 while ( i-- ) {
2010 if ( !matchers[ i ]( elem, context, xml ) ) {
2011 return false;
2012 }
2013 }
2014 return true;
2015 } :
2016 matchers[ 0 ];
2017}
2018
2019function multipleContexts( selector, contexts, results ) {
2020 var i = 0,
2021 len = contexts.length;
2022 for ( ; i < len; i++ ) {
2023 Sizzle( selector, contexts[ i ], results );
2024 }
2025 return results;
2026}
2027
2028function condense( unmatched, map, filter, context, xml ) {
2029 var elem,
2030 newUnmatched = [],
2031 i = 0,
2032 len = unmatched.length,
2033 mapped = map != null;
2034
2035 for ( ; i < len; i++ ) {
2036 if ( ( elem = unmatched[ i ] ) ) {
2037 if ( !filter || filter( elem, context, xml ) ) {
2038 newUnmatched.push( elem );
2039 if ( mapped ) {
2040 map.push( i );
2041 }
2042 }
2043 }
2044 }
2045
2046 return newUnmatched;
2047}
2048
2049function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
2050 if ( postFilter && !postFilter[ expando ] ) {
2051 postFilter = setMatcher( postFilter );
2052 }
2053 if ( postFinder && !postFinder[ expando ] ) {
2054 postFinder = setMatcher( postFinder, postSelector );
2055 }
2056 return markFunction( function( seed, results, context, xml ) {
2057 var temp, i, elem,
2058 preMap = [],
2059 postMap = [],
2060 preexisting = results.length,
2061
2062 // Get initial elements from seed or context
2063 elems = seed || multipleContexts(
2064 selector || "*",
2065 context.nodeType ? [ context ] : context,
2066 []
2067 ),
2068
2069 // Prefilter to get matcher input, preserving a map for seed-results synchronization
2070 matcherIn = preFilter && ( seed || !selector ) ?
2071 condense( elems, preMap, preFilter, context, xml ) :
2072 elems,
2073
2074 matcherOut = matcher ?
2075
2076 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
2077 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
2078
2079 // ...intermediate processing is necessary
2080 [] :
2081
2082 // ...otherwise use results directly
2083 results :
2084 matcherIn;
2085
2086 // Find primary matches
2087 if ( matcher ) {
2088 matcher( matcherIn, matcherOut, context, xml );
2089 }
2090
2091 // Apply postFilter
2092 if ( postFilter ) {
2093 temp = condense( matcherOut, postMap );
2094 postFilter( temp, [], context, xml );
2095
2096 // Un-match failing elements by moving them back to matcherIn
2097 i = temp.length;
2098 while ( i-- ) {
2099 if ( ( elem = temp[ i ] ) ) {
2100 matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem );
2101 }
2102 }
2103 }
2104
2105 if ( seed ) {
2106 if ( postFinder || preFilter ) {
2107 if ( postFinder ) {
2108
2109 // Get the final matcherOut by condensing this intermediate into postFinder contexts
2110 temp = [];
2111 i = matcherOut.length;
2112 while ( i-- ) {
2113 if ( ( elem = matcherOut[ i ] ) ) {
2114
2115 // Restore matcherIn since elem is not yet a final match
2116 temp.push( ( matcherIn[ i ] = elem ) );
2117 }
2118 }
2119 postFinder( null, ( matcherOut = [] ), temp, xml );
2120 }
2121
2122 // Move matched elements from seed to results to keep them synchronized
2123 i = matcherOut.length;
2124 while ( i-- ) {
2125 if ( ( elem = matcherOut[ i ] ) &&
2126 ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) {
2127
2128 seed[ temp ] = !( results[ temp ] = elem );
2129 }
2130 }
2131 }
2132
2133 // Add elements to results, through postFinder if defined
2134 } else {
2135 matcherOut = condense(
2136 matcherOut === results ?
2137 matcherOut.splice( preexisting, matcherOut.length ) :
2138 matcherOut
2139 );
2140 if ( postFinder ) {
2141 postFinder( null, results, matcherOut, xml );
2142 } else {
2143 push.apply( results, matcherOut );
2144 }
2145 }
2146 } );
2147}
2148
2149function matcherFromTokens( tokens ) {
2150 var checkContext, matcher, j,
2151 len = tokens.length,
2152 leadingRelative = Expr.relative[ tokens[ 0 ].type ],
2153 implicitRelative = leadingRelative || Expr.relative[ " " ],
2154 i = leadingRelative ? 1 : 0,
2155
2156 // The foundational matcher ensures that elements are reachable from top-level context(s)
2157 matchContext = addCombinator( function( elem ) {
2158 return elem === checkContext;
2159 }, implicitRelative, true ),
2160 matchAnyContext = addCombinator( function( elem ) {
2161 return indexOf( checkContext, elem ) > -1;
2162 }, implicitRelative, true ),
2163 matchers = [ function( elem, context, xml ) {
2164 var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
2165 ( checkContext = context ).nodeType ?
2166 matchContext( elem, context, xml ) :
2167 matchAnyContext( elem, context, xml ) );
2168
2169 // Avoid hanging onto element (issue #299)
2170 checkContext = null;
2171 return ret;
2172 } ];
2173
2174 for ( ; i < len; i++ ) {
2175 if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) {
2176 matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
2177 } else {
2178 matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches );
2179
2180 // Return special upon seeing a positional matcher
2181 if ( matcher[ expando ] ) {
2182
2183 // Find the next relative operator (if any) for proper handling
2184 j = ++i;
2185 for ( ; j < len; j++ ) {
2186 if ( Expr.relative[ tokens[ j ].type ] ) {
2187 break;
2188 }
2189 }
2190 return setMatcher(
2191 i > 1 && elementMatcher( matchers ),
2192 i > 1 && toSelector(
2193
2194 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
2195 tokens
2196 .slice( 0, i - 1 )
2197 .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } )
2198 ).replace( rtrim, "$1" ),
2199 matcher,
2200 i < j && matcherFromTokens( tokens.slice( i, j ) ),
2201 j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ),
2202 j < len && toSelector( tokens )
2203 );
2204 }
2205 matchers.push( matcher );
2206 }
2207 }
2208
2209 return elementMatcher( matchers );
2210}
2211
2212function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
2213 var bySet = setMatchers.length > 0,
2214 byElement = elementMatchers.length > 0,
2215 superMatcher = function( seed, context, xml, results, outermost ) {
2216 var elem, j, matcher,
2217 matchedCount = 0,
2218 i = "0",
2219 unmatched = seed && [],
2220 setMatched = [],
2221 contextBackup = outermostContext,
2222
2223 // We must always have either seed elements or outermost context
2224 elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ),
2225
2226 // Use integer dirruns iff this is the outermost matcher
2227 dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ),
2228 len = elems.length;
2229
2230 if ( outermost ) {
2231
2232 // Support: IE 11+, Edge 17 - 18+
2233 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2234 // two documents; shallow comparisons work.
2235 // eslint-disable-next-line eqeqeq
2236 outermostContext = context == document || context || outermost;
2237 }
2238
2239 // Add elements passing elementMatchers directly to results
2240 // Support: IE<9, Safari
2241 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
2242 for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) {
2243 if ( byElement && elem ) {
2244 j = 0;
2245
2246 // Support: IE 11+, Edge 17 - 18+
2247 // IE/Edge sometimes throw a "Permission denied" error when strict-comparing
2248 // two documents; shallow comparisons work.
2249 // eslint-disable-next-line eqeqeq
2250 if ( !context && elem.ownerDocument != document ) {
2251 setDocument( elem );
2252 xml = !documentIsHTML;
2253 }
2254 while ( ( matcher = elementMatchers[ j++ ] ) ) {
2255 if ( matcher( elem, context || document, xml ) ) {
2256 results.push( elem );
2257 break;
2258 }
2259 }
2260 if ( outermost ) {
2261 dirruns = dirrunsUnique;
2262 }
2263 }
2264
2265 // Track unmatched elements for set filters
2266 if ( bySet ) {
2267
2268 // They will have gone through all possible matchers
2269 if ( ( elem = !matcher && elem ) ) {
2270 matchedCount--;
2271 }
2272
2273 // Lengthen the array for every element, matched or not
2274 if ( seed ) {
2275 unmatched.push( elem );
2276 }
2277 }
2278 }
2279
2280 // `i` is now the count of elements visited above, and adding it to `matchedCount`
2281 // makes the latter nonnegative.
2282 matchedCount += i;
2283
2284 // Apply set filters to unmatched elements
2285 // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
2286 // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
2287 // no element matchers and no seed.
2288 // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
2289 // case, which will result in a "00" `matchedCount` that differs from `i` but is also
2290 // numerically zero.
2291 if ( bySet && i !== matchedCount ) {
2292 j = 0;
2293 while ( ( matcher = setMatchers[ j++ ] ) ) {
2294 matcher( unmatched, setMatched, context, xml );
2295 }
2296
2297 if ( seed ) {
2298
2299 // Reintegrate element matches to eliminate the need for sorting
2300 if ( matchedCount > 0 ) {
2301 while ( i-- ) {
2302 if ( !( unmatched[ i ] || setMatched[ i ] ) ) {
2303 setMatched[ i ] = pop.call( results );
2304 }
2305 }
2306 }
2307
2308 // Discard index placeholder values to get only actual matches
2309 setMatched = condense( setMatched );
2310 }
2311
2312 // Add matches to results
2313 push.apply( results, setMatched );
2314
2315 // Seedless set matches succeeding multiple successful matchers stipulate sorting
2316 if ( outermost && !seed && setMatched.length > 0 &&
2317 ( matchedCount + setMatchers.length ) > 1 ) {
2318
2319 Sizzle.uniqueSort( results );
2320 }
2321 }
2322
2323 // Override manipulation of globals by nested matchers
2324 if ( outermost ) {
2325 dirruns = dirrunsUnique;
2326 outermostContext = contextBackup;
2327 }
2328
2329 return unmatched;
2330 };
2331
2332 return bySet ?
2333 markFunction( superMatcher ) :
2334 superMatcher;
2335}
2336
2337compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
2338 var i,
2339 setMatchers = [],
2340 elementMatchers = [],
2341 cached = compilerCache[ selector + " " ];
2342
2343 if ( !cached ) {
2344
2345 // Generate a function of recursive functions that can be used to check each element
2346 if ( !match ) {
2347 match = tokenize( selector );
2348 }
2349 i = match.length;
2350 while ( i-- ) {
2351 cached = matcherFromTokens( match[ i ] );
2352 if ( cached[ expando ] ) {
2353 setMatchers.push( cached );
2354 } else {
2355 elementMatchers.push( cached );
2356 }
2357 }
2358
2359 // Cache the compiled function
2360 cached = compilerCache(
2361 selector,
2362 matcherFromGroupMatchers( elementMatchers, setMatchers )
2363 );
2364
2365 // Save selector and tokenization
2366 cached.selector = selector;
2367 }
2368 return cached;
2369};
2370
2371/**
2372 * A low-level selection function that works with Sizzle's compiled
2373 * selector functions
2374 * @param {String|Function} selector A selector or a pre-compiled
2375 * selector function built with Sizzle.compile
2376 * @param {Element} context
2377 * @param {Array} [results]
2378 * @param {Array} [seed] A set of elements to match against
2379 */
2380select = Sizzle.select = function( selector, context, results, seed ) {
2381 var i, tokens, token, type, find,
2382 compiled = typeof selector === "function" && selector,
2383 match = !seed && tokenize( ( selector = compiled.selector || selector ) );
2384
2385 results = results || [];
2386
2387 // Try to minimize operations if there is only one selector in the list and no seed
2388 // (the latter of which guarantees us context)
2389 if ( match.length === 1 ) {
2390
2391 // Reduce context if the leading compound selector is an ID
2392 tokens = match[ 0 ] = match[ 0 ].slice( 0 );
2393 if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" &&
2394 context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) {
2395
2396 context = ( Expr.find[ "ID" ]( token.matches[ 0 ]
2397 .replace( runescape, funescape ), context ) || [] )[ 0 ];
2398 if ( !context ) {
2399 return results;
2400
2401 // Precompiled matchers will still verify ancestry, so step up a level
2402 } else if ( compiled ) {
2403 context = context.parentNode;
2404 }
2405
2406 selector = selector.slice( tokens.shift().value.length );
2407 }
2408
2409 // Fetch a seed set for right-to-left matching
2410 i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length;
2411 while ( i-- ) {
2412 token = tokens[ i ];
2413
2414 // Abort if we hit a combinator
2415 if ( Expr.relative[ ( type = token.type ) ] ) {
2416 break;
2417 }
2418 if ( ( find = Expr.find[ type ] ) ) {
2419
2420 // Search, expanding context for leading sibling combinators
2421 if ( ( seed = find(
2422 token.matches[ 0 ].replace( runescape, funescape ),
2423 rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) ||
2424 context
2425 ) ) ) {
2426
2427 // If seed is empty or no tokens remain, we can return early
2428 tokens.splice( i, 1 );
2429 selector = seed.length && toSelector( tokens );
2430 if ( !selector ) {
2431 push.apply( results, seed );
2432 return results;
2433 }
2434
2435 break;
2436 }
2437 }
2438 }
2439 }
2440
2441 // Compile and execute a filtering function if one is not provided
2442 // Provide `match` to avoid retokenization if we modified the selector above
2443 ( compiled || compile( selector, match ) )(
2444 seed,
2445 context,
2446 !documentIsHTML,
2447 results,
2448 !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
2449 );
2450 return results;
2451};
2452
2453// One-time assignments
2454
2455// Sort stability
2456support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando;
2457
2458// Support: Chrome 14-35+
2459// Always assume duplicates if they aren't passed to the comparison function
2460support.detectDuplicates = !!hasDuplicate;
2461
2462// Initialize against the default document
2463setDocument();
2464
2465// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
2466// Detached nodes confoundingly follow *each other*
2467support.sortDetached = assert( function( el ) {
2468
2469 // Should return 1, but returns 4 (following)
2470 return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1;
2471} );
2472
2473// Support: IE<8
2474// Prevent attribute/property "interpolation"
2475// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
2476if ( !assert( function( el ) {
2477 el.innerHTML = "<a href='#'></a>";
2478 return el.firstChild.getAttribute( "href" ) === "#";
2479} ) ) {
2480 addHandle( "type|href|height|width", function( elem, name, isXML ) {
2481 if ( !isXML ) {
2482 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
2483 }
2484 } );
2485}
2486
2487// Support: IE<9
2488// Use defaultValue in place of getAttribute("value")
2489if ( !support.attributes || !assert( function( el ) {
2490 el.innerHTML = "<input/>";
2491 el.firstChild.setAttribute( "value", "" );
2492 return el.firstChild.getAttribute( "value" ) === "";
2493} ) ) {
2494 addHandle( "value", function( elem, _name, isXML ) {
2495 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2496 return elem.defaultValue;
2497 }
2498 } );
2499}
2500
2501// Support: IE<9
2502// Use getAttributeNode to fetch booleans when getAttribute lies
2503if ( !assert( function( el ) {
2504 return el.getAttribute( "disabled" ) == null;
2505} ) ) {
2506 addHandle( booleans, function( elem, name, isXML ) {
2507 var val;
2508 if ( !isXML ) {
2509 return elem[ name ] === true ? name.toLowerCase() :
2510 ( val = elem.getAttributeNode( name ) ) && val.specified ?
2511 val.value :
2512 null;
2513 }
2514 } );
2515}
2516
2517// EXPOSE
2518var _sizzle = window.Sizzle;
2519
2520Sizzle.noConflict = function() {
2521 if ( window.Sizzle === Sizzle ) {
2522 window.Sizzle = _sizzle;
2523 }
2524
2525 return Sizzle;
2526};
2527
2528if ( typeof define === "function" && define.amd ) {
2529 define( function() {
2530 return Sizzle;
2531 } );
2532
2533// Sizzle requires that there be a global window in Common-JS like environments
2534} else if ( typeof module !== "undefined" && module.exports ) {
2535 module.exports = Sizzle;
2536} else {
2537 window.Sizzle = Sizzle;
2538}
2539
2540// EXPOSE
2541
2542} )( window );