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