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