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