xonecas.io
286
Sf

simple-flask-coffee-sass-boilerplate / files

simple-flask-coffee-sass-boilerplate / bower_components / jquery / src / sizzle / dist / sizzle.js

57.2 KB
1/*!
2 * Sizzle CSS Selector Engine v1.10.19
3 * http://sizzlejs.com/
4 *
5 * Copyright 2013 jQuery Foundation, Inc. and other contributors
6 * Released under the MIT license
7 * http://jquery.org/license
8 *
9 * Date: 2014-04-18
10 */
11(function( window ) {
12
13var i,
14	support,
15	Expr,
16	getText,
17	isXML,
18	tokenize,
19	compile,
20	select,
21	outermostContext,
22	sortInput,
23	hasDuplicate,
24
25	// Local document vars
26	setDocument,
27	document,
28	docElem,
29	documentIsHTML,
30	rbuggyQSA,
31	rbuggyMatches,
32	matches,
33	contains,
34
35	// Instance-specific data
36	expando = "sizzle" + -(new Date()),
37	preferredDoc = window.document,
38	dirruns = 0,
39	done = 0,
40	classCache = createCache(),
41	tokenCache = createCache(),
42	compilerCache = createCache(),
43	sortOrder = function( a, b ) {
44		if ( a === b ) {
45			hasDuplicate = true;
46		}
47		return 0;
48	},
49
50	// General-purpose constants
51	strundefined = typeof undefined,
52	MAX_NEGATIVE = 1 << 31,
53
54	// Instance methods
55	hasOwn = ({}).hasOwnProperty,
56	arr = [],
57	pop = arr.pop,
58	push_native = arr.push,
59	push = arr.push,
60	slice = arr.slice,
61	// Use a stripped-down indexOf if we can't use a native one
62	indexOf = arr.indexOf || function( elem ) {
63		var i = 0,
64			len = this.length;
65		for ( ; i < len; i++ ) {
66			if ( this[i] === elem ) {
67				return i;
68			}
69		}
70		return -1;
71	},
72
73	booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
74
75	// Regular expressions
76
77	// Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
78	whitespace = "[\\x20\\t\\r\\n\\f]",
79	// http://www.w3.org/TR/css3-syntax/#characters
80	characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
81
82	// Loosely modeled on CSS identifier characters
83	// An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
84	// Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
85	identifier = characterEncoding.replace( "w", "w#" ),
86
87	// Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
88	attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
89		// Operator (capture 2)
90		"*([*^$|!~]?=)" + whitespace +
91		// "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
92		"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
93		"*\\]",
94
95	pseudos = ":(" + characterEncoding + ")(?:\\((" +
96		// To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
97		// 1. quoted (capture 3; capture 4 or capture 5)
98		"('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
99		// 2. simple (capture 6)
100		"((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
101		// 3. anything else (capture 2)
102		".*" +
103		")\\)|)",
104
105	// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
106	rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
107
108	rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
109	rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
110
111	rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
112
113	rpseudo = new RegExp( pseudos ),
114	ridentifier = new RegExp( "^" + identifier + "$" ),
115
116	matchExpr = {
117		"ID": new RegExp( "^#(" + characterEncoding + ")" ),
118		"CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
119		"TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
120		"ATTR": new RegExp( "^" + attributes ),
121		"PSEUDO": new RegExp( "^" + pseudos ),
122		"CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
123			"*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
124			"*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
125		"bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
126		// For use in libraries implementing .is()
127		// We use this for POS matching in `select`
128		"needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
129			whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
130	},
131
132	rinputs = /^(?:input|select|textarea|button)$/i,
133	rheader = /^h\d$/i,
134
135	rnative = /^[^{]+\{\s*\[native \w/,
136
137	// Easily-parseable/retrievable ID or TAG or CLASS selectors
138	rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
139
140	rsibling = /[+~]/,
141	rescape = /'|\\/g,
142
143	// CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
144	runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
145	funescape = function( _, escaped, escapedWhitespace ) {
146		var high = "0x" + escaped - 0x10000;
147		// NaN means non-codepoint
148		// Support: Firefox<24
149		// Workaround erroneous numeric interpretation of +"0x"
150		return high !== high || escapedWhitespace ?
151			escaped :
152			high < 0 ?
153				// BMP codepoint
154				String.fromCharCode( high + 0x10000 ) :
155				// Supplemental Plane codepoint (surrogate pair)
156				String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
157	};
158
159// Optimize for push.apply( _, NodeList )
160try {
161	push.apply(
162		(arr = slice.call( preferredDoc.childNodes )),
163		preferredDoc.childNodes
164	);
165	// Support: Android<4.0
166	// Detect silently failing push.apply
167	arr[ preferredDoc.childNodes.length ].nodeType;
168} catch ( e ) {
169	push = { apply: arr.length ?
170
171		// Leverage slice if possible
172		function( target, els ) {
173			push_native.apply( target, slice.call(els) );
174		} :
175
176		// Support: IE<9
177		// Otherwise append directly
178		function( target, els ) {
179			var j = target.length,
180				i = 0;
181			// Can't trust NodeList.length
182			while ( (target[j++] = els[i++]) ) {}
183			target.length = j - 1;
184		}
185	};
186}
187
188function Sizzle( selector, context, results, seed ) {
189	var match, elem, m, nodeType,
190		// QSA vars
191		i, groups, old, nid, newContext, newSelector;
192
193	if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
194		setDocument( context );
195	}
196
197	context = context || document;
198	results = results || [];
199
200	if ( !selector || typeof selector !== "string" ) {
201		return results;
202	}
203
204	if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
205		return [];
206	}
207
208	if ( documentIsHTML && !seed ) {
209
210		// Shortcuts
211		if ( (match = rquickExpr.exec( selector )) ) {
212			// Speed-up: Sizzle("#ID")
213			if ( (m = match[1]) ) {
214				if ( nodeType === 9 ) {
215					elem = context.getElementById( m );
216					// Check parentNode to catch when Blackberry 4.6 returns
217					// nodes that are no longer in the document (jQuery #6963)
218					if ( elem && elem.parentNode ) {
219						// Handle the case where IE, Opera, and Webkit return items
220						// by name instead of ID
221						if ( elem.id === m ) {
222							results.push( elem );
223							return results;
224						}
225					} else {
226						return results;
227					}
228				} else {
229					// Context is not a document
230					if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
231						contains( context, elem ) && elem.id === m ) {
232						results.push( elem );
233						return results;
234					}
235				}
236
237			// Speed-up: Sizzle("TAG")
238			} else if ( match[2] ) {
239				push.apply( results, context.getElementsByTagName( selector ) );
240				return results;
241
242			// Speed-up: Sizzle(".CLASS")
243			} else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
244				push.apply( results, context.getElementsByClassName( m ) );
245				return results;
246			}
247		}
248
249		// QSA path
250		if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
251			nid = old = expando;
252			newContext = context;
253			newSelector = nodeType === 9 && selector;
254
255			// qSA works strangely on Element-rooted queries
256			// We can work around this by specifying an extra ID on the root
257			// and working up from there (Thanks to Andrew Dupont for the technique)
258			// IE 8 doesn't work on object elements
259			if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
260				groups = tokenize( selector );
261
262				if ( (old = context.getAttribute("id")) ) {
263					nid = old.replace( rescape, "\\$&" );
264				} else {
265					context.setAttribute( "id", nid );
266				}
267				nid = "[id='" + nid + "'] ";
268
269				i = groups.length;
270				while ( i-- ) {
271					groups[i] = nid + toSelector( groups[i] );
272				}
273				newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
274				newSelector = groups.join(",");
275			}
276
277			if ( newSelector ) {
278				try {
279					push.apply( results,
280						newContext.querySelectorAll( newSelector )
281					);
282					return results;
283				} catch(qsaError) {
284				} finally {
285					if ( !old ) {
286						context.removeAttribute("id");
287					}
288				}
289			}
290		}
291	}
292
293	// All others
294	return select( selector.replace( rtrim, "$1" ), context, results, seed );
295}
296
297/**
298 * Create key-value caches of limited size
299 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
300 *	property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
301 *	deleting the oldest entry
302 */
303function createCache() {
304	var keys = [];
305
306	function cache( key, value ) {
307		// Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
308		if ( keys.push( key + " " ) > Expr.cacheLength ) {
309			// Only keep the most recent entries
310			delete cache[ keys.shift() ];
311		}
312		return (cache[ key + " " ] = value);
313	}
314	return cache;
315}
316
317/**
318 * Mark a function for special use by Sizzle
319 * @param {Function} fn The function to mark
320 */
321function markFunction( fn ) {
322	fn[ expando ] = true;
323	return fn;
324}
325
326/**
327 * Support testing using an element
328 * @param {Function} fn Passed the created div and expects a boolean result
329 */
330function assert( fn ) {
331	var div = document.createElement("div");
332
333	try {
334		return !!fn( div );
335	} catch (e) {
336		return false;
337	} finally {
338		// Remove from its parent by default
339		if ( div.parentNode ) {
340			div.parentNode.removeChild( div );
341		}
342		// release memory in IE
343		div = null;
344	}
345}
346
347/**
348 * Adds the same handler for all of the specified attrs
349 * @param {String} attrs Pipe-separated list of attributes
350 * @param {Function} handler The method that will be applied
351 */
352function addHandle( attrs, handler ) {
353	var arr = attrs.split("|"),
354		i = attrs.length;
355
356	while ( i-- ) {
357		Expr.attrHandle[ arr[i] ] = handler;
358	}
359}
360
361/**
362 * Checks document order of two siblings
363 * @param {Element} a
364 * @param {Element} b
365 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
366 */
367function siblingCheck( a, b ) {
368	var cur = b && a,
369		diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
370			( ~b.sourceIndex || MAX_NEGATIVE ) -
371			( ~a.sourceIndex || MAX_NEGATIVE );
372
373	// Use IE sourceIndex if available on both nodes
374	if ( diff ) {
375		return diff;
376	}
377
378	// Check if b follows a
379	if ( cur ) {
380		while ( (cur = cur.nextSibling) ) {
381			if ( cur === b ) {
382				return -1;
383			}
384		}
385	}
386
387	return a ? 1 : -1;
388}
389
390/**
391 * Returns a function to use in pseudos for input types
392 * @param {String} type
393 */
394function createInputPseudo( type ) {
395	return function( elem ) {
396		var name = elem.nodeName.toLowerCase();
397		return name === "input" && elem.type === type;
398	};
399}
400
401/**
402 * Returns a function to use in pseudos for buttons
403 * @param {String} type
404 */
405function createButtonPseudo( type ) {
406	return function( elem ) {
407		var name = elem.nodeName.toLowerCase();
408		return (name === "input" || name === "button") && elem.type === type;
409	};
410}
411
412/**
413 * Returns a function to use in pseudos for positionals
414 * @param {Function} fn
415 */
416function createPositionalPseudo( fn ) {
417	return markFunction(function( argument ) {
418		argument = +argument;
419		return markFunction(function( seed, matches ) {
420			var j,
421				matchIndexes = fn( [], seed.length, argument ),
422				i = matchIndexes.length;
423
424			// Match elements found at the specified indexes
425			while ( i-- ) {
426				if ( seed[ (j = matchIndexes[i]) ] ) {
427					seed[j] = !(matches[j] = seed[j]);
428				}
429			}
430		});
431	});
432}
433
434/**
435 * Checks a node for validity as a Sizzle context
436 * @param {Element|Object=} context
437 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
438 */
439function testContext( context ) {
440	return context && typeof context.getElementsByTagName !== strundefined && context;
441}
442
443// Expose support vars for convenience
444support = Sizzle.support = {};
445
446/**
447 * Detects XML nodes
448 * @param {Element|Object} elem An element or a document
449 * @returns {Boolean} True iff elem is a non-HTML XML node
450 */
451isXML = Sizzle.isXML = function( elem ) {
452	// documentElement is verified for cases where it doesn't yet exist
453	// (such as loading iframes in IE - #4833)
454	var documentElement = elem && (elem.ownerDocument || elem).documentElement;
455	return documentElement ? documentElement.nodeName !== "HTML" : false;
456};
457
458/**
459 * Sets document-related variables once based on the current document
460 * @param {Element|Object} [doc] An element or document object to use to set the document
461 * @returns {Object} Returns the current document
462 */
463setDocument = Sizzle.setDocument = function( node ) {
464	var hasCompare,
465		doc = node ? node.ownerDocument || node : preferredDoc,
466		parent = doc.defaultView;
467
468	// If no document and documentElement is available, return
469	if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
470		return document;
471	}
472
473	// Set our document
474	document = doc;
475	docElem = doc.documentElement;
476
477	// Support tests
478	documentIsHTML = !isXML( doc );
479
480	// Support: IE>8
481	// If iframe document is assigned to "document" variable and if iframe has been reloaded,
482	// IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
483	// IE6-8 do not support the defaultView property so parent will be undefined
484	if ( parent && parent !== parent.top ) {
485		// IE11 does not have attachEvent, so all must suffer
486		if ( parent.addEventListener ) {
487			parent.addEventListener( "unload", function() {
488				setDocument();
489			}, false );
490		} else if ( parent.attachEvent ) {
491			parent.attachEvent( "onunload", function() {
492				setDocument();
493			});
494		}
495	}
496
497	/* Attributes
498	---------------------------------------------------------------------- */
499
500	// Support: IE<8
501	// Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
502	support.attributes = assert(function( div ) {
503		div.className = "i";
504		return !div.getAttribute("className");
505	});
506
507	/* getElement(s)By*
508	---------------------------------------------------------------------- */
509
510	// Check if getElementsByTagName("*") returns only elements
511	support.getElementsByTagName = assert(function( div ) {
512		div.appendChild( doc.createComment("") );
513		return !div.getElementsByTagName("*").length;
514	});
515
516	// Check if getElementsByClassName can be trusted
517	support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
518		div.innerHTML = "<div class='a'></div><div class='a i'></div>";
519
520		// Support: Safari<4
521		// Catch class over-caching
522		div.firstChild.className = "i";
523		// Support: Opera<10
524		// Catch gEBCN failure to find non-leading classes
525		return div.getElementsByClassName("i").length === 2;
526	});
527
528	// Support: IE<10
529	// Check if getElementById returns elements by name
530	// The broken getElementById methods don't pick up programatically-set names,
531	// so use a roundabout getElementsByName test
532	support.getById = assert(function( div ) {
533		docElem.appendChild( div ).id = expando;
534		return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
535	});
536
537	// ID find and filter
538	if ( support.getById ) {
539		Expr.find["ID"] = function( id, context ) {
540			if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
541				var m = context.getElementById( id );
542				// Check parentNode to catch when Blackberry 4.6 returns
543				// nodes that are no longer in the document #6963
544				return m && m.parentNode ? [ m ] : [];
545			}
546		};
547		Expr.filter["ID"] = function( id ) {
548			var attrId = id.replace( runescape, funescape );
549			return function( elem ) {
550				return elem.getAttribute("id") === attrId;
551			};
552		};
553	} else {
554		// Support: IE6/7
555		// getElementById is not reliable as a find shortcut
556		delete Expr.find["ID"];
557
558		Expr.filter["ID"] =  function( id ) {
559			var attrId = id.replace( runescape, funescape );
560			return function( elem ) {
561				var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
562				return node && node.value === attrId;
563			};
564		};
565	}
566
567	// Tag
568	Expr.find["TAG"] = support.getElementsByTagName ?
569		function( tag, context ) {
570			if ( typeof context.getElementsByTagName !== strundefined ) {
571				return context.getElementsByTagName( tag );
572			}
573		} :
574		function( tag, context ) {
575			var elem,
576				tmp = [],
577				i = 0,
578				results = context.getElementsByTagName( tag );
579
580			// Filter out possible comments
581			if ( tag === "*" ) {
582				while ( (elem = results[i++]) ) {
583					if ( elem.nodeType === 1 ) {
584						tmp.push( elem );
585					}
586				}
587
588				return tmp;
589			}
590			return results;
591		};
592
593	// Class
594	Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
595		if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
596			return context.getElementsByClassName( className );
597		}
598	};
599
600	/* QSA/matchesSelector
601	---------------------------------------------------------------------- */
602
603	// QSA and matchesSelector support
604
605	// matchesSelector(:active) reports false when true (IE9/Opera 11.5)
606	rbuggyMatches = [];
607
608	// qSa(:focus) reports false when true (Chrome 21)
609	// We allow this because of a bug in IE8/9 that throws an error
610	// whenever `document.activeElement` is accessed on an iframe
611	// So, we allow :focus to pass through QSA all the time to avoid the IE error
612	// See http://bugs.jquery.com/ticket/13378
613	rbuggyQSA = [];
614
615	if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
616		// Build QSA regex
617		// Regex strategy adopted from Diego Perini
618		assert(function( div ) {
619			// Select is set to empty string on purpose
620			// This is to test IE's treatment of not explicitly
621			// setting a boolean content attribute,
622			// since its presence should be enough
623			// http://bugs.jquery.com/ticket/12359
624			div.innerHTML = "<select msallowclip=''><option selected=''></option></select>";
625
626			// Support: IE8, Opera 11-12.16
627			// Nothing should be selected when empty strings follow ^= or $= or *=
628			// The test attribute must be unknown in Opera but "safe" for WinRT
629			// http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
630			if ( div.querySelectorAll("[msallowclip^='']").length ) {
631				rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
632			}
633
634			// Support: IE8
635			// Boolean attributes and "value" are not treated correctly
636			if ( !div.querySelectorAll("[selected]").length ) {
637				rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
638			}
639
640			// Webkit/Opera - :checked should return selected option elements
641			// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
642			// IE8 throws error here and will not see later tests
643			if ( !div.querySelectorAll(":checked").length ) {
644				rbuggyQSA.push(":checked");
645			}
646		});
647
648		assert(function( div ) {
649			// Support: Windows 8 Native Apps
650			// The type and name attributes are restricted during .innerHTML assignment
651			var input = doc.createElement("input");
652			input.setAttribute( "type", "hidden" );
653			div.appendChild( input ).setAttribute( "name", "D" );
654
655			// Support: IE8
656			// Enforce case-sensitivity of name attribute
657			if ( div.querySelectorAll("[name=d]").length ) {
658				rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
659			}
660
661			// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
662			// IE8 throws error here and will not see later tests
663			if ( !div.querySelectorAll(":enabled").length ) {
664				rbuggyQSA.push( ":enabled", ":disabled" );
665			}
666
667			// Opera 10-11 does not throw on post-comma invalid pseudos
668			div.querySelectorAll("*,:x");
669			rbuggyQSA.push(",.*:");
670		});
671	}
672
673	if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
674		docElem.webkitMatchesSelector ||
675		docElem.mozMatchesSelector ||
676		docElem.oMatchesSelector ||
677		docElem.msMatchesSelector) )) ) {
678
679		assert(function( div ) {
680			// Check to see if it's possible to do matchesSelector
681			// on a disconnected node (IE 9)
682			support.disconnectedMatch = matches.call( div, "div" );
683
684			// This should fail with an exception
685			// Gecko does not error, returns false instead
686			matches.call( div, "[s!='']:x" );
687			rbuggyMatches.push( "!=", pseudos );
688		});
689	}
690
691	rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
692	rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
693
694	/* Contains
695	---------------------------------------------------------------------- */
696	hasCompare = rnative.test( docElem.compareDocumentPosition );
697
698	// Element contains another
699	// Purposefully does not implement inclusive descendent
700	// As in, an element does not contain itself
701	contains = hasCompare || rnative.test( docElem.contains ) ?
702		function( a, b ) {
703			var adown = a.nodeType === 9 ? a.documentElement : a,
704				bup = b && b.parentNode;
705			return a === bup || !!( bup && bup.nodeType === 1 && (
706				adown.contains ?
707					adown.contains( bup ) :
708					a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
709			));
710		} :
711		function( a, b ) {
712			if ( b ) {
713				while ( (b = b.parentNode) ) {
714					if ( b === a ) {
715						return true;
716					}
717				}
718			}
719			return false;
720		};
721
722	/* Sorting
723	---------------------------------------------------------------------- */
724
725	// Document order sorting
726	sortOrder = hasCompare ?
727	function( a, b ) {
728
729		// Flag for duplicate removal
730		if ( a === b ) {
731			hasDuplicate = true;
732			return 0;
733		}
734
735		// Sort on method existence if only one input has compareDocumentPosition
736		var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
737		if ( compare ) {
738			return compare;
739		}
740
741		// Calculate position if both inputs belong to the same document
742		compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
743			a.compareDocumentPosition( b ) :
744
745			// Otherwise we know they are disconnected
746			1;
747
748		// Disconnected nodes
749		if ( compare & 1 ||
750			(!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
751
752			// Choose the first element that is related to our preferred document
753			if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
754				return -1;
755			}
756			if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
757				return 1;
758			}
759
760			// Maintain original order
761			return sortInput ?
762				( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
763				0;
764		}
765
766		return compare & 4 ? -1 : 1;
767	} :
768	function( a, b ) {
769		// Exit early if the nodes are identical
770		if ( a === b ) {
771			hasDuplicate = true;
772			return 0;
773		}
774
775		var cur,
776			i = 0,
777			aup = a.parentNode,
778			bup = b.parentNode,
779			ap = [ a ],
780			bp = [ b ];
781
782		// Parentless nodes are either documents or disconnected
783		if ( !aup || !bup ) {
784			return a === doc ? -1 :
785				b === doc ? 1 :
786				aup ? -1 :
787				bup ? 1 :
788				sortInput ?
789				( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
790				0;
791
792		// If the nodes are siblings, we can do a quick check
793		} else if ( aup === bup ) {
794			return siblingCheck( a, b );
795		}
796
797		// Otherwise we need full lists of their ancestors for comparison
798		cur = a;
799		while ( (cur = cur.parentNode) ) {
800			ap.unshift( cur );
801		}
802		cur = b;
803		while ( (cur = cur.parentNode) ) {
804			bp.unshift( cur );
805		}
806
807		// Walk down the tree looking for a discrepancy
808		while ( ap[i] === bp[i] ) {
809			i++;
810		}
811
812		return i ?
813			// Do a sibling check if the nodes have a common ancestor
814			siblingCheck( ap[i], bp[i] ) :
815
816			// Otherwise nodes in our document sort first
817			ap[i] === preferredDoc ? -1 :
818			bp[i] === preferredDoc ? 1 :
819			0;
820	};
821
822	return doc;
823};
824
825Sizzle.matches = function( expr, elements ) {
826	return Sizzle( expr, null, null, elements );
827};
828
829Sizzle.matchesSelector = function( elem, expr ) {
830	// Set document vars if needed
831	if ( ( elem.ownerDocument || elem ) !== document ) {
832		setDocument( elem );
833	}
834
835	// Make sure that attribute selectors are quoted
836	expr = expr.replace( rattributeQuotes, "='$1']" );
837
838	if ( support.matchesSelector && documentIsHTML &&
839		( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
840		( !rbuggyQSA     || !rbuggyQSA.test( expr ) ) ) {
841
842		try {
843			var ret = matches.call( elem, expr );
844
845			// IE 9's matchesSelector returns false on disconnected nodes
846			if ( ret || support.disconnectedMatch ||
847					// As well, disconnected nodes are said to be in a document
848					// fragment in IE 9
849					elem.document && elem.document.nodeType !== 11 ) {
850				return ret;
851			}
852		} catch(e) {}
853	}
854
855	return Sizzle( expr, document, null, [ elem ] ).length > 0;
856};
857
858Sizzle.contains = function( context, elem ) {
859	// Set document vars if needed
860	if ( ( context.ownerDocument || context ) !== document ) {
861		setDocument( context );
862	}
863	return contains( context, elem );
864};
865
866Sizzle.attr = function( elem, name ) {
867	// Set document vars if needed
868	if ( ( elem.ownerDocument || elem ) !== document ) {
869		setDocument( elem );
870	}
871
872	var fn = Expr.attrHandle[ name.toLowerCase() ],
873		// Don't get fooled by Object.prototype properties (jQuery #13807)
874		val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
875			fn( elem, name, !documentIsHTML ) :
876			undefined;
877
878	return val !== undefined ?
879		val :
880		support.attributes || !documentIsHTML ?
881			elem.getAttribute( name ) :
882			(val = elem.getAttributeNode(name)) && val.specified ?
883				val.value :
884				null;
885};
886
887Sizzle.error = function( msg ) {
888	throw new Error( "Syntax error, unrecognized expression: " + msg );
889};
890
891/**
892 * Document sorting and removing duplicates
893 * @param {ArrayLike} results
894 */
895Sizzle.uniqueSort = function( results ) {
896	var elem,
897		duplicates = [],
898		j = 0,
899		i = 0;
900
901	// Unless we *know* we can detect duplicates, assume their presence
902	hasDuplicate = !support.detectDuplicates;
903	sortInput = !support.sortStable && results.slice( 0 );
904	results.sort( sortOrder );
905
906	if ( hasDuplicate ) {
907		while ( (elem = results[i++]) ) {
908			if ( elem === results[ i ] ) {
909				j = duplicates.push( i );
910			}
911		}
912		while ( j-- ) {
913			results.splice( duplicates[ j ], 1 );
914		}
915	}
916
917	// Clear input after sorting to release objects
918	// See https://github.com/jquery/sizzle/pull/225
919	sortInput = null;
920
921	return results;
922};
923
924/**
925 * Utility function for retrieving the text value of an array of DOM nodes
926 * @param {Array|Element} elem
927 */
928getText = Sizzle.getText = function( elem ) {
929	var node,
930		ret = "",
931		i = 0,
932		nodeType = elem.nodeType;
933
934	if ( !nodeType ) {
935		// If no nodeType, this is expected to be an array
936		while ( (node = elem[i++]) ) {
937			// Do not traverse comment nodes
938			ret += getText( node );
939		}
940	} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
941		// Use textContent for elements
942		// innerText usage removed for consistency of new lines (jQuery #11153)
943		if ( typeof elem.textContent === "string" ) {
944			return elem.textContent;
945		} else {
946			// Traverse its children
947			for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
948				ret += getText( elem );
949			}
950		}
951	} else if ( nodeType === 3 || nodeType === 4 ) {
952		return elem.nodeValue;
953	}
954	// Do not include comment or processing instruction nodes
955
956	return ret;
957};
958
959Expr = Sizzle.selectors = {
960
961	// Can be adjusted by the user
962	cacheLength: 50,
963
964	createPseudo: markFunction,
965
966	match: matchExpr,
967
968	attrHandle: {},
969
970	find: {},
971
972	relative: {
973		">": { dir: "parentNode", first: true },
974		" ": { dir: "parentNode" },
975		"+": { dir: "previousSibling", first: true },
976		"~": { dir: "previousSibling" }
977	},
978
979	preFilter: {
980		"ATTR": function( match ) {
981			match[1] = match[1].replace( runescape, funescape );
982
983			// Move the given value to match[3] whether quoted or unquoted
984			match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
985
986			if ( match[2] === "~=" ) {
987				match[3] = " " + match[3] + " ";
988			}
989
990			return match.slice( 0, 4 );
991		},
992
993		"CHILD": function( match ) {
994			/* matches from matchExpr["CHILD"]
995				1 type (only|nth|...)
996				2 what (child|of-type)
997				3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
998				4 xn-component of xn+y argument ([+-]?\d*n|)
999				5 sign of xn-component
1000				6 x of xn-component
1001				7 sign of y-component
1002				8 y of y-component
1003			*/
1004			match[1] = match[1].toLowerCase();
1005
1006			if ( match[1].slice( 0, 3 ) === "nth" ) {
1007				// nth-* requires argument
1008				if ( !match[3] ) {
1009					Sizzle.error( match[0] );
1010				}
1011
1012				// numeric x and y parameters for Expr.filter.CHILD
1013				// remember that false/true cast respectively to 0/1
1014				match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
1015				match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
1016
1017			// other types prohibit arguments
1018			} else if ( match[3] ) {
1019				Sizzle.error( match[0] );
1020			}
1021
1022			return match;
1023		},
1024
1025		"PSEUDO": function( match ) {
1026			var excess,
1027				unquoted = !match[6] && match[2];
1028
1029			if ( matchExpr["CHILD"].test( match[0] ) ) {
1030				return null;
1031			}
1032
1033			// Accept quoted arguments as-is
1034			if ( match[3] ) {
1035				match[2] = match[4] || match[5] || "";
1036
1037			// Strip excess characters from unquoted arguments
1038			} else if ( unquoted && rpseudo.test( unquoted ) &&
1039				// Get excess from tokenize (recursively)
1040				(excess = tokenize( unquoted, true )) &&
1041				// advance to the next closing parenthesis
1042				(excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
1043
1044				// excess is a negative index
1045				match[0] = match[0].slice( 0, excess );
1046				match[2] = unquoted.slice( 0, excess );
1047			}
1048
1049			// Return only captures needed by the pseudo filter method (type and argument)
1050			return match.slice( 0, 3 );
1051		}
1052	},
1053
1054	filter: {
1055
1056		"TAG": function( nodeNameSelector ) {
1057			var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
1058			return nodeNameSelector === "*" ?
1059				function() { return true; } :
1060				function( elem ) {
1061					return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
1062				};
1063		},
1064
1065		"CLASS": function( className ) {
1066			var pattern = classCache[ className + " " ];
1067
1068			return pattern ||
1069				(pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
1070				classCache( className, function( elem ) {
1071					return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
1072				});
1073		},
1074
1075		"ATTR": function( name, operator, check ) {
1076			return function( elem ) {
1077				var result = Sizzle.attr( elem, name );
1078
1079				if ( result == null ) {
1080					return operator === "!=";
1081				}
1082				if ( !operator ) {
1083					return true;
1084				}
1085
1086				result += "";
1087
1088				return operator === "=" ? result === check :
1089					operator === "!=" ? result !== check :
1090					operator === "^=" ? check && result.indexOf( check ) === 0 :
1091					operator === "*=" ? check && result.indexOf( check ) > -1 :
1092					operator === "$=" ? check && result.slice( -check.length ) === check :
1093					operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
1094					operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
1095					false;
1096			};
1097		},
1098
1099		"CHILD": function( type, what, argument, first, last ) {
1100			var simple = type.slice( 0, 3 ) !== "nth",
1101				forward = type.slice( -4 ) !== "last",
1102				ofType = what === "of-type";
1103
1104			return first === 1 && last === 0 ?
1105
1106				// Shortcut for :nth-*(n)
1107				function( elem ) {
1108					return !!elem.parentNode;
1109				} :
1110
1111				function( elem, context, xml ) {
1112					var cache, outerCache, node, diff, nodeIndex, start,
1113						dir = simple !== forward ? "nextSibling" : "previousSibling",
1114						parent = elem.parentNode,
1115						name = ofType && elem.nodeName.toLowerCase(),
1116						useCache = !xml && !ofType;
1117
1118					if ( parent ) {
1119
1120						// :(first|last|only)-(child|of-type)
1121						if ( simple ) {
1122							while ( dir ) {
1123								node = elem;
1124								while ( (node = node[ dir ]) ) {
1125									if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
1126										return false;
1127									}
1128								}
1129								// Reverse direction for :only-* (if we haven't yet done so)
1130								start = dir = type === "only" && !start && "nextSibling";
1131							}
1132							return true;
1133						}
1134
1135						start = [ forward ? parent.firstChild : parent.lastChild ];
1136
1137						// non-xml :nth-child(...) stores cache data on `parent`
1138						if ( forward && useCache ) {
1139							// Seek `elem` from a previously-cached index
1140							outerCache = parent[ expando ] || (parent[ expando ] = {});
1141							cache = outerCache[ type ] || [];
1142							nodeIndex = cache[0] === dirruns && cache[1];
1143							diff = cache[0] === dirruns && cache[2];
1144							node = nodeIndex && parent.childNodes[ nodeIndex ];
1145
1146							while ( (node = ++nodeIndex && node && node[ dir ] ||
1147
1148								// Fallback to seeking `elem` from the start
1149								(diff = nodeIndex = 0) || start.pop()) ) {
1150
1151								// When found, cache indexes on `parent` and break
1152								if ( node.nodeType === 1 && ++diff && node === elem ) {
1153									outerCache[ type ] = [ dirruns, nodeIndex, diff ];
1154									break;
1155								}
1156							}
1157
1158						// Use previously-cached element index if available
1159						} else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
1160							diff = cache[1];
1161
1162						// xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
1163						} else {
1164							// Use the same loop as above to seek `elem` from the start
1165							while ( (node = ++nodeIndex && node && node[ dir ] ||
1166								(diff = nodeIndex = 0) || start.pop()) ) {
1167
1168								if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
1169									// Cache the index of each encountered element
1170									if ( useCache ) {
1171										(node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
1172									}
1173
1174									if ( node === elem ) {
1175										break;
1176									}
1177								}
1178							}
1179						}
1180
1181						// Incorporate the offset, then check against cycle size
1182						diff -= last;
1183						return diff === first || ( diff % first === 0 && diff / first >= 0 );
1184					}
1185				};
1186		},
1187
1188		"PSEUDO": function( pseudo, argument ) {
1189			// pseudo-class names are case-insensitive
1190			// http://www.w3.org/TR/selectors/#pseudo-classes
1191			// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
1192			// Remember that setFilters inherits from pseudos
1193			var args,
1194				fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
1195					Sizzle.error( "unsupported pseudo: " + pseudo );
1196
1197			// The user may use createPseudo to indicate that
1198			// arguments are needed to create the filter function
1199			// just as Sizzle does
1200			if ( fn[ expando ] ) {
1201				return fn( argument );
1202			}
1203
1204			// But maintain support for old signatures
1205			if ( fn.length > 1 ) {
1206				args = [ pseudo, pseudo, "", argument ];
1207				return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
1208					markFunction(function( seed, matches ) {
1209						var idx,
1210							matched = fn( seed, argument ),
1211							i = matched.length;
1212						while ( i-- ) {
1213							idx = indexOf.call( seed, matched[i] );
1214							seed[ idx ] = !( matches[ idx ] = matched[i] );
1215						}
1216					}) :
1217					function( elem ) {
1218						return fn( elem, 0, args );
1219					};
1220			}
1221
1222			return fn;
1223		}
1224	},
1225
1226	pseudos: {
1227		// Potentially complex pseudos
1228		"not": markFunction(function( selector ) {
1229			// Trim the selector passed to compile
1230			// to avoid treating leading and trailing
1231			// spaces as combinators
1232			var input = [],
1233				results = [],
1234				matcher = compile( selector.replace( rtrim, "$1" ) );
1235
1236			return matcher[ expando ] ?
1237				markFunction(function( seed, matches, context, xml ) {
1238					var elem,
1239						unmatched = matcher( seed, null, xml, [] ),
1240						i = seed.length;
1241
1242					// Match elements unmatched by `matcher`
1243					while ( i-- ) {
1244						if ( (elem = unmatched[i]) ) {
1245							seed[i] = !(matches[i] = elem);
1246						}
1247					}
1248				}) :
1249				function( elem, context, xml ) {
1250					input[0] = elem;
1251					matcher( input, null, xml, results );
1252					return !results.pop();
1253				};
1254		}),
1255
1256		"has": markFunction(function( selector ) {
1257			return function( elem ) {
1258				return Sizzle( selector, elem ).length > 0;
1259			};
1260		}),
1261
1262		"contains": markFunction(function( text ) {
1263			return function( elem ) {
1264				return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
1265			};
1266		}),
1267
1268		// "Whether an element is represented by a :lang() selector
1269		// is based solely on the element's language value
1270		// being equal to the identifier C,
1271		// or beginning with the identifier C immediately followed by "-".
1272		// The matching of C against the element's language value is performed case-insensitively.
1273		// The identifier C does not have to be a valid language name."
1274		// http://www.w3.org/TR/selectors/#lang-pseudo
1275		"lang": markFunction( function( lang ) {
1276			// lang value must be a valid identifier
1277			if ( !ridentifier.test(lang || "") ) {
1278				Sizzle.error( "unsupported lang: " + lang );
1279			}
1280			lang = lang.replace( runescape, funescape ).toLowerCase();
1281			return function( elem ) {
1282				var elemLang;
1283				do {
1284					if ( (elemLang = documentIsHTML ?
1285						elem.lang :
1286						elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
1287
1288						elemLang = elemLang.toLowerCase();
1289						return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
1290					}
1291				} while ( (elem = elem.parentNode) && elem.nodeType === 1 );
1292				return false;
1293			};
1294		}),
1295
1296		// Miscellaneous
1297		"target": function( elem ) {
1298			var hash = window.location && window.location.hash;
1299			return hash && hash.slice( 1 ) === elem.id;
1300		},
1301
1302		"root": function( elem ) {
1303			return elem === docElem;
1304		},
1305
1306		"focus": function( elem ) {
1307			return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
1308		},
1309
1310		// Boolean properties
1311		"enabled": function( elem ) {
1312			return elem.disabled === false;
1313		},
1314
1315		"disabled": function( elem ) {
1316			return elem.disabled === true;
1317		},
1318
1319		"checked": function( elem ) {
1320			// In CSS3, :checked should return both checked and selected elements
1321			// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
1322			var nodeName = elem.nodeName.toLowerCase();
1323			return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
1324		},
1325
1326		"selected": function( elem ) {
1327			// Accessing this property makes selected-by-default
1328			// options in Safari work properly
1329			if ( elem.parentNode ) {
1330				elem.parentNode.selectedIndex;
1331			}
1332
1333			return elem.selected === true;
1334		},
1335
1336		// Contents
1337		"empty": function( elem ) {
1338			// http://www.w3.org/TR/selectors/#empty-pseudo
1339			// :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
1340			//   but not by others (comment: 8; processing instruction: 7; etc.)
1341			// nodeType < 6 works because attributes (2) do not appear as children
1342			for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
1343				if ( elem.nodeType < 6 ) {
1344					return false;
1345				}
1346			}
1347			return true;
1348		},
1349
1350		"parent": function( elem ) {
1351			return !Expr.pseudos["empty"]( elem );
1352		},
1353
1354		// Element/input types
1355		"header": function( elem ) {
1356			return rheader.test( elem.nodeName );
1357		},
1358
1359		"input": function( elem ) {
1360			return rinputs.test( elem.nodeName );
1361		},
1362
1363		"button": function( elem ) {
1364			var name = elem.nodeName.toLowerCase();
1365			return name === "input" && elem.type === "button" || name === "button";
1366		},
1367
1368		"text": function( elem ) {
1369			var attr;
1370			return elem.nodeName.toLowerCase() === "input" &&
1371				elem.type === "text" &&
1372
1373				// Support: IE<8
1374				// New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
1375				( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
1376		},
1377
1378		// Position-in-collection
1379		"first": createPositionalPseudo(function() {
1380			return [ 0 ];
1381		}),
1382
1383		"last": createPositionalPseudo(function( matchIndexes, length ) {
1384			return [ length - 1 ];
1385		}),
1386
1387		"eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
1388			return [ argument < 0 ? argument + length : argument ];
1389		}),
1390
1391		"even": createPositionalPseudo(function( matchIndexes, length ) {
1392			var i = 0;
1393			for ( ; i < length; i += 2 ) {
1394				matchIndexes.push( i );
1395			}
1396			return matchIndexes;
1397		}),
1398
1399		"odd": createPositionalPseudo(function( matchIndexes, length ) {
1400			var i = 1;
1401			for ( ; i < length; i += 2 ) {
1402				matchIndexes.push( i );
1403			}
1404			return matchIndexes;
1405		}),
1406
1407		"lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
1408			var i = argument < 0 ? argument + length : argument;
1409			for ( ; --i >= 0; ) {
1410				matchIndexes.push( i );
1411			}
1412			return matchIndexes;
1413		}),
1414
1415		"gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
1416			var i = argument < 0 ? argument + length : argument;
1417			for ( ; ++i < length; ) {
1418				matchIndexes.push( i );
1419			}
1420			return matchIndexes;
1421		})
1422	}
1423};
1424
1425Expr.pseudos["nth"] = Expr.pseudos["eq"];
1426
1427// Add button/input type pseudos
1428for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
1429	Expr.pseudos[ i ] = createInputPseudo( i );
1430}
1431for ( i in { submit: true, reset: true } ) {
1432	Expr.pseudos[ i ] = createButtonPseudo( i );
1433}
1434
1435// Easy API for creating new setFilters
1436function setFilters() {}
1437setFilters.prototype = Expr.filters = Expr.pseudos;
1438Expr.setFilters = new setFilters();
1439
1440tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
1441	var matched, match, tokens, type,
1442		soFar, groups, preFilters,
1443		cached = tokenCache[ selector + " " ];
1444
1445	if ( cached ) {
1446		return parseOnly ? 0 : cached.slice( 0 );
1447	}
1448
1449	soFar = selector;
1450	groups = [];
1451	preFilters = Expr.preFilter;
1452
1453	while ( soFar ) {
1454
1455		// Comma and first run
1456		if ( !matched || (match = rcomma.exec( soFar )) ) {
1457			if ( match ) {
1458				// Don't consume trailing commas as valid
1459				soFar = soFar.slice( match[0].length ) || soFar;
1460			}
1461			groups.push( (tokens = []) );
1462		}
1463
1464		matched = false;
1465
1466		// Combinators
1467		if ( (match = rcombinators.exec( soFar )) ) {
1468			matched = match.shift();
1469			tokens.push({
1470				value: matched,
1471				// Cast descendant combinators to space
1472				type: match[0].replace( rtrim, " " )
1473			});
1474			soFar = soFar.slice( matched.length );
1475		}
1476
1477		// Filters
1478		for ( type in Expr.filter ) {
1479			if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
1480				(match = preFilters[ type ]( match ))) ) {
1481				matched = match.shift();
1482				tokens.push({
1483					value: matched,
1484					type: type,
1485					matches: match
1486				});
1487				soFar = soFar.slice( matched.length );
1488			}
1489		}
1490
1491		if ( !matched ) {
1492			break;
1493		}
1494	}
1495
1496	// Return the length of the invalid excess
1497	// if we're just parsing
1498	// Otherwise, throw an error or return tokens
1499	return parseOnly ?
1500		soFar.length :
1501		soFar ?
1502			Sizzle.error( selector ) :
1503			// Cache the tokens
1504			tokenCache( selector, groups ).slice( 0 );
1505};
1506
1507function toSelector( tokens ) {
1508	var i = 0,
1509		len = tokens.length,
1510		selector = "";
1511	for ( ; i < len; i++ ) {
1512		selector += tokens[i].value;
1513	}
1514	return selector;
1515}
1516
1517function addCombinator( matcher, combinator, base ) {
1518	var dir = combinator.dir,
1519		checkNonElements = base && dir === "parentNode",
1520		doneName = done++;
1521
1522	return combinator.first ?
1523		// Check against closest ancestor/preceding element
1524		function( elem, context, xml ) {
1525			while ( (elem = elem[ dir ]) ) {
1526				if ( elem.nodeType === 1 || checkNonElements ) {
1527					return matcher( elem, context, xml );
1528				}
1529			}
1530		} :
1531
1532		// Check against all ancestor/preceding elements
1533		function( elem, context, xml ) {
1534			var oldCache, outerCache,
1535				newCache = [ dirruns, doneName ];
1536
1537			// We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
1538			if ( xml ) {
1539				while ( (elem = elem[ dir ]) ) {
1540					if ( elem.nodeType === 1 || checkNonElements ) {
1541						if ( matcher( elem, context, xml ) ) {
1542							return true;
1543						}
1544					}
1545				}
1546			} else {
1547				while ( (elem = elem[ dir ]) ) {
1548					if ( elem.nodeType === 1 || checkNonElements ) {
1549						outerCache = elem[ expando ] || (elem[ expando ] = {});
1550						if ( (oldCache = outerCache[ dir ]) &&
1551							oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
1552
1553							// Assign to newCache so results back-propagate to previous elements
1554							return (newCache[ 2 ] = oldCache[ 2 ]);
1555						} else {
1556							// Reuse newcache so results back-propagate to previous elements
1557							outerCache[ dir ] = newCache;
1558
1559							// A match means we're done; a fail means we have to keep checking
1560							if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
1561								return true;
1562							}
1563						}
1564					}
1565				}
1566			}
1567		};
1568}
1569
1570function elementMatcher( matchers ) {
1571	return matchers.length > 1 ?
1572		function( elem, context, xml ) {
1573			var i = matchers.length;
1574			while ( i-- ) {
1575				if ( !matchers[i]( elem, context, xml ) ) {
1576					return false;
1577				}
1578			}
1579			return true;
1580		} :
1581		matchers[0];
1582}
1583
1584function multipleContexts( selector, contexts, results ) {
1585	var i = 0,
1586		len = contexts.length;
1587	for ( ; i < len; i++ ) {
1588		Sizzle( selector, contexts[i], results );
1589	}
1590	return results;
1591}
1592
1593function condense( unmatched, map, filter, context, xml ) {
1594	var elem,
1595		newUnmatched = [],
1596		i = 0,
1597		len = unmatched.length,
1598		mapped = map != null;
1599
1600	for ( ; i < len; i++ ) {
1601		if ( (elem = unmatched[i]) ) {
1602			if ( !filter || filter( elem, context, xml ) ) {
1603				newUnmatched.push( elem );
1604				if ( mapped ) {
1605					map.push( i );
1606				}
1607			}
1608		}
1609	}
1610
1611	return newUnmatched;
1612}
1613
1614function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
1615	if ( postFilter && !postFilter[ expando ] ) {
1616		postFilter = setMatcher( postFilter );
1617	}
1618	if ( postFinder && !postFinder[ expando ] ) {
1619		postFinder = setMatcher( postFinder, postSelector );
1620	}
1621	return markFunction(function( seed, results, context, xml ) {
1622		var temp, i, elem,
1623			preMap = [],
1624			postMap = [],
1625			preexisting = results.length,
1626
1627			// Get initial elements from seed or context
1628			elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
1629
1630			// Prefilter to get matcher input, preserving a map for seed-results synchronization
1631			matcherIn = preFilter && ( seed || !selector ) ?
1632				condense( elems, preMap, preFilter, context, xml ) :
1633				elems,
1634
1635			matcherOut = matcher ?
1636				// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
1637				postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
1638
1639					// ...intermediate processing is necessary
1640					[] :
1641
1642					// ...otherwise use results directly
1643					results :
1644				matcherIn;
1645
1646		// Find primary matches
1647		if ( matcher ) {
1648			matcher( matcherIn, matcherOut, context, xml );
1649		}
1650
1651		// Apply postFilter
1652		if ( postFilter ) {
1653			temp = condense( matcherOut, postMap );
1654			postFilter( temp, [], context, xml );
1655
1656			// Un-match failing elements by moving them back to matcherIn
1657			i = temp.length;
1658			while ( i-- ) {
1659				if ( (elem = temp[i]) ) {
1660					matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
1661				}
1662			}
1663		}
1664
1665		if ( seed ) {
1666			if ( postFinder || preFilter ) {
1667				if ( postFinder ) {
1668					// Get the final matcherOut by condensing this intermediate into postFinder contexts
1669					temp = [];
1670					i = matcherOut.length;
1671					while ( i-- ) {
1672						if ( (elem = matcherOut[i]) ) {
1673							// Restore matcherIn since elem is not yet a final match
1674							temp.push( (matcherIn[i] = elem) );
1675						}
1676					}
1677					postFinder( null, (matcherOut = []), temp, xml );
1678				}
1679
1680				// Move matched elements from seed to results to keep them synchronized
1681				i = matcherOut.length;
1682				while ( i-- ) {
1683					if ( (elem = matcherOut[i]) &&
1684						(temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
1685
1686						seed[temp] = !(results[temp] = elem);
1687					}
1688				}
1689			}
1690
1691		// Add elements to results, through postFinder if defined
1692		} else {
1693			matcherOut = condense(
1694				matcherOut === results ?
1695					matcherOut.splice( preexisting, matcherOut.length ) :
1696					matcherOut
1697			);
1698			if ( postFinder ) {
1699				postFinder( null, results, matcherOut, xml );
1700			} else {
1701				push.apply( results, matcherOut );
1702			}
1703		}
1704	});
1705}
1706
1707function matcherFromTokens( tokens ) {
1708	var checkContext, matcher, j,
1709		len = tokens.length,
1710		leadingRelative = Expr.relative[ tokens[0].type ],
1711		implicitRelative = leadingRelative || Expr.relative[" "],
1712		i = leadingRelative ? 1 : 0,
1713
1714		// The foundational matcher ensures that elements are reachable from top-level context(s)
1715		matchContext = addCombinator( function( elem ) {
1716			return elem === checkContext;
1717		}, implicitRelative, true ),
1718		matchAnyContext = addCombinator( function( elem ) {
1719			return indexOf.call( checkContext, elem ) > -1;
1720		}, implicitRelative, true ),
1721		matchers = [ function( elem, context, xml ) {
1722			return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
1723				(checkContext = context).nodeType ?
1724					matchContext( elem, context, xml ) :
1725					matchAnyContext( elem, context, xml ) );
1726		} ];
1727
1728	for ( ; i < len; i++ ) {
1729		if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
1730			matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
1731		} else {
1732			matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
1733
1734			// Return special upon seeing a positional matcher
1735			if ( matcher[ expando ] ) {
1736				// Find the next relative operator (if any) for proper handling
1737				j = ++i;
1738				for ( ; j < len; j++ ) {
1739					if ( Expr.relative[ tokens[j].type ] ) {
1740						break;
1741					}
1742				}
1743				return setMatcher(
1744					i > 1 && elementMatcher( matchers ),
1745					i > 1 && toSelector(
1746						// If the preceding token was a descendant combinator, insert an implicit any-element `*`
1747						tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
1748					).replace( rtrim, "$1" ),
1749					matcher,
1750					i < j && matcherFromTokens( tokens.slice( i, j ) ),
1751					j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
1752					j < len && toSelector( tokens )
1753				);
1754			}
1755			matchers.push( matcher );
1756		}
1757	}
1758
1759	return elementMatcher( matchers );
1760}
1761
1762function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
1763	var bySet = setMatchers.length > 0,
1764		byElement = elementMatchers.length > 0,
1765		superMatcher = function( seed, context, xml, results, outermost ) {
1766			var elem, j, matcher,
1767				matchedCount = 0,
1768				i = "0",
1769				unmatched = seed && [],
1770				setMatched = [],
1771				contextBackup = outermostContext,
1772				// We must always have either seed elements or outermost context
1773				elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
1774				// Use integer dirruns iff this is the outermost matcher
1775				dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
1776				len = elems.length;
1777
1778			if ( outermost ) {
1779				outermostContext = context !== document && context;
1780			}
1781
1782			// Add elements passing elementMatchers directly to results
1783			// Keep `i` a string if there are no elements so `matchedCount` will be "00" below
1784			// Support: IE<9, Safari
1785			// Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
1786			for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
1787				if ( byElement && elem ) {
1788					j = 0;
1789					while ( (matcher = elementMatchers[j++]) ) {
1790						if ( matcher( elem, context, xml ) ) {
1791							results.push( elem );
1792							break;
1793						}
1794					}
1795					if ( outermost ) {
1796						dirruns = dirrunsUnique;
1797					}
1798				}
1799
1800				// Track unmatched elements for set filters
1801				if ( bySet ) {
1802					// They will have gone through all possible matchers
1803					if ( (elem = !matcher && elem) ) {
1804						matchedCount--;
1805					}
1806
1807					// Lengthen the array for every element, matched or not
1808					if ( seed ) {
1809						unmatched.push( elem );
1810					}
1811				}
1812			}
1813
1814			// Apply set filters to unmatched elements
1815			matchedCount += i;
1816			if ( bySet && i !== matchedCount ) {
1817				j = 0;
1818				while ( (matcher = setMatchers[j++]) ) {
1819					matcher( unmatched, setMatched, context, xml );
1820				}
1821
1822				if ( seed ) {
1823					// Reintegrate element matches to eliminate the need for sorting
1824					if ( matchedCount > 0 ) {
1825						while ( i-- ) {
1826							if ( !(unmatched[i] || setMatched[i]) ) {
1827								setMatched[i] = pop.call( results );
1828							}
1829						}
1830					}
1831
1832					// Discard index placeholder values to get only actual matches
1833					setMatched = condense( setMatched );
1834				}
1835
1836				// Add matches to results
1837				push.apply( results, setMatched );
1838
1839				// Seedless set matches succeeding multiple successful matchers stipulate sorting
1840				if ( outermost && !seed && setMatched.length > 0 &&
1841					( matchedCount + setMatchers.length ) > 1 ) {
1842
1843					Sizzle.uniqueSort( results );
1844				}
1845			}
1846
1847			// Override manipulation of globals by nested matchers
1848			if ( outermost ) {
1849				dirruns = dirrunsUnique;
1850				outermostContext = contextBackup;
1851			}
1852
1853			return unmatched;
1854		};
1855
1856	return bySet ?
1857		markFunction( superMatcher ) :
1858		superMatcher;
1859}
1860
1861compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
1862	var i,
1863		setMatchers = [],
1864		elementMatchers = [],
1865		cached = compilerCache[ selector + " " ];
1866
1867	if ( !cached ) {
1868		// Generate a function of recursive functions that can be used to check each element
1869		if ( !match ) {
1870			match = tokenize( selector );
1871		}
1872		i = match.length;
1873		while ( i-- ) {
1874			cached = matcherFromTokens( match[i] );
1875			if ( cached[ expando ] ) {
1876				setMatchers.push( cached );
1877			} else {
1878				elementMatchers.push( cached );
1879			}
1880		}
1881
1882		// Cache the compiled function
1883		cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
1884
1885		// Save selector and tokenization
1886		cached.selector = selector;
1887	}
1888	return cached;
1889};
1890
1891/**
1892 * A low-level selection function that works with Sizzle's compiled
1893 *  selector functions
1894 * @param {String|Function} selector A selector or a pre-compiled
1895 *  selector function built with Sizzle.compile
1896 * @param {Element} context
1897 * @param {Array} [results]
1898 * @param {Array} [seed] A set of elements to match against
1899 */
1900select = Sizzle.select = function( selector, context, results, seed ) {
1901	var i, tokens, token, type, find,
1902		compiled = typeof selector === "function" && selector,
1903		match = !seed && tokenize( (selector = compiled.selector || selector) );
1904
1905	results = results || [];
1906
1907	// Try to minimize operations if there is no seed and only one group
1908	if ( match.length === 1 ) {
1909
1910		// Take a shortcut and set the context if the root selector is an ID
1911		tokens = match[0] = match[0].slice( 0 );
1912		if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
1913				support.getById && context.nodeType === 9 && documentIsHTML &&
1914				Expr.relative[ tokens[1].type ] ) {
1915
1916			context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
1917			if ( !context ) {
1918				return results;
1919
1920			// Precompiled matchers will still verify ancestry, so step up a level
1921			} else if ( compiled ) {
1922				context = context.parentNode;
1923			}
1924
1925			selector = selector.slice( tokens.shift().value.length );
1926		}
1927
1928		// Fetch a seed set for right-to-left matching
1929		i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
1930		while ( i-- ) {
1931			token = tokens[i];
1932
1933			// Abort if we hit a combinator
1934			if ( Expr.relative[ (type = token.type) ] ) {
1935				break;
1936			}
1937			if ( (find = Expr.find[ type ]) ) {
1938				// Search, expanding context for leading sibling combinators
1939				if ( (seed = find(
1940					token.matches[0].replace( runescape, funescape ),
1941					rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
1942				)) ) {
1943
1944					// If seed is empty or no tokens remain, we can return early
1945					tokens.splice( i, 1 );
1946					selector = seed.length && toSelector( tokens );
1947					if ( !selector ) {
1948						push.apply( results, seed );
1949						return results;
1950					}
1951
1952					break;
1953				}
1954			}
1955		}
1956	}
1957
1958	// Compile and execute a filtering function if one is not provided
1959	// Provide `match` to avoid retokenization if we modified the selector above
1960	( compiled || compile( selector, match ) )(
1961		seed,
1962		context,
1963		!documentIsHTML,
1964		results,
1965		rsibling.test( selector ) && testContext( context.parentNode ) || context
1966	);
1967	return results;
1968};
1969
1970// One-time assignments
1971
1972// Sort stability
1973support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
1974
1975// Support: Chrome<14
1976// Always assume duplicates if they aren't passed to the comparison function
1977support.detectDuplicates = !!hasDuplicate;
1978
1979// Initialize against the default document
1980setDocument();
1981
1982// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
1983// Detached nodes confoundingly follow *each other*
1984support.sortDetached = assert(function( div1 ) {
1985	// Should return 1, but returns 4 (following)
1986	return div1.compareDocumentPosition( document.createElement("div") ) & 1;
1987});
1988
1989// Support: IE<8
1990// Prevent attribute/property "interpolation"
1991// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
1992if ( !assert(function( div ) {
1993	div.innerHTML = "<a href='#'></a>";
1994	return div.firstChild.getAttribute("href") === "#" ;
1995}) ) {
1996	addHandle( "type|href|height|width", function( elem, name, isXML ) {
1997		if ( !isXML ) {
1998			return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
1999		}
2000	});
2001}
2002
2003// Support: IE<9
2004// Use defaultValue in place of getAttribute("value")
2005if ( !support.attributes || !assert(function( div ) {
2006	div.innerHTML = "<input/>";
2007	div.firstChild.setAttribute( "value", "" );
2008	return div.firstChild.getAttribute( "value" ) === "";
2009}) ) {
2010	addHandle( "value", function( elem, name, isXML ) {
2011		if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
2012			return elem.defaultValue;
2013		}
2014	});
2015}
2016
2017// Support: IE<9
2018// Use getAttributeNode to fetch booleans when getAttribute lies
2019if ( !assert(function( div ) {
2020	return div.getAttribute("disabled") == null;
2021}) ) {
2022	addHandle( booleans, function( elem, name, isXML ) {
2023		var val;
2024		if ( !isXML ) {
2025			return elem[ name ] === true ? name.toLowerCase() :
2026					(val = elem.getAttributeNode( name )) && val.specified ?
2027					val.value :
2028				null;
2029		}
2030	});
2031}
2032
2033// EXPOSE
2034if ( typeof define === "function" && define.amd ) {
2035	define(function() { return Sizzle; });
2036// Sizzle requires that there be a global window in Common-JS like environments
2037} else if ( typeof module !== "undefined" && module.exports ) {
2038	module.exports = Sizzle;
2039} else {
2040	window.Sizzle = Sizzle;
2041}
2042// EXPOSE
2043
2044})( window );