4 "./var/documentElement",
7 ], function( jQuery, document, documentElement, hasOwn, indexOf ) {
12 * Optional (non-Sizzle) selector module for custom builds.
14 * Note that this DOES NOT SUPPORT many documented jQuery
15 * features in exchange for its smaller size:
17 * Attribute not equal selector
18 * Positional selectors (:first; :eq(n); :odd; etc.)
19 * Type selectors (:input; :checkbox; :button; etc.)
20 * State-based selectors (:animated; :visible; :hidden; etc.)
22 * :not(complex selector)
23 * custom selectors via Sizzle extensions
24 * Leading combinators (e.g., $collection.find("> *"))
25 * Reliable functionality on XML fragments
26 * Requiring all parts of a selector to match elements under context
27 * (e.g., $div.find("div > *") now matches children of $div)
28 * Matching against non-elements
29 * Reliable sorting of disconnected nodes
30 * querySelectorAll bug fixes (e.g., unreliable :focus on WebKit)
32 * If any of these are unacceptable tradeoffs, either use Sizzle or
33 * customize this stub for the project's specific needs.
36 var hasDuplicate, sortInput,
37 sortStable = jQuery.expando.split( "" ).sort( sortOrder ).join( "" ) === jQuery.expando,
38 matches = documentElement.matches ||
39 documentElement.webkitMatchesSelector ||
40 documentElement.mozMatchesSelector ||
41 documentElement.oMatchesSelector ||
42 documentElement.msMatchesSelector,
44 // CSS string/identifier serialization
45 // https://drafts.csswg.org/cssom/#common-serializing-idioms
46 rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g,
47 fcssescape = function( ch, asCodePoint ) {
50 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
55 // Control characters and (dependent upon position) numbers get escaped as code points
56 return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
59 // Other potentially-special ASCII characters get backslash-escaped
63 function sortOrder( a, b ) {
65 // Flag for duplicate removal
71 // Sort on method existence if only one input has compareDocumentPosition
72 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
77 // Calculate position if both inputs belong to the same document
78 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
79 a.compareDocumentPosition( b ) :
81 // Otherwise we know they are disconnected
87 // Choose the first element that is related to our preferred document
88 if ( a === document || a.ownerDocument === document &&
89 jQuery.contains( document, a ) ) {
92 if ( b === document || b.ownerDocument === document &&
93 jQuery.contains( document, b ) ) {
97 // Maintain original order
99 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
103 return compare & 4 ? -1 : 1;
106 function uniqueSort( results ) {
112 hasDuplicate = false;
113 sortInput = !sortStable && results.slice( 0 );
114 results.sort( sortOrder );
116 if ( hasDuplicate ) {
117 while ( ( elem = results[ i++ ] ) ) {
118 if ( elem === results[ i ] ) {
119 j = duplicates.push( i );
123 results.splice( duplicates[ j ], 1 );
127 // Clear input after sorting to release objects
128 // See https://github.com/jquery/sizzle/pull/225
134 function escape( sel ) {
135 return ( sel + "" ).replace( rcssescape, fcssescape );
139 uniqueSort: uniqueSort,
141 escapeSelector: escape,
142 find: function( selector, context, results, seed ) {
146 results = results || [];
147 context = context || document;
149 // Same basic safeguard as Sizzle
150 if ( !selector || typeof selector !== "string" ) {
154 // Early return if context is not an element or document
155 if ( ( nodeType = context.nodeType ) !== 1 && nodeType !== 9 ) {
160 while ( ( elem = seed[ i++ ] ) ) {
161 if ( jQuery.find.matchesSelector( elem, selector ) ) {
162 results.push( elem );
166 jQuery.merge( results, context.querySelectorAll( selector ) );
171 text: function( elem ) {
175 nodeType = elem.nodeType;
179 // If no nodeType, this is expected to be an array
180 while ( ( node = elem[ i++ ] ) ) {
182 // Do not traverse comment nodes
183 ret += jQuery.text( node );
185 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
187 // Use textContent for elements
188 return elem.textContent;
189 } else if ( nodeType === 3 || nodeType === 4 ) {
190 return elem.nodeValue;
193 // Do not include comment or processing instruction nodes
197 contains: function( a, b ) {
198 var adown = a.nodeType === 9 ? a.documentElement : a,
199 bup = b && b.parentNode;
200 return a === bup || !!( bup && bup.nodeType === 1 && adown.contains( bup ) );
202 isXMLDoc: function( elem ) {
204 // documentElement is verified for cases where it doesn't yet exist
205 // (such as loading iframes in IE - #4833)
206 var documentElement = elem && ( elem.ownerDocument || elem ).documentElement;
207 return documentElement ? documentElement.nodeName !== "HTML" : false;
212 bool: new RegExp( "^(?:checked|selected|async|autofocus|autoplay|controls|defer" +
213 "|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$", "i" ),
214 needsContext: /^[\x20\t\r\n\f]*[>+~]/
219 jQuery.extend( jQuery.find, {
220 matches: function( expr, elements ) {
221 return jQuery.find( expr, null, null, elements );
223 matchesSelector: function( elem, expr ) {
224 return matches.call( elem, expr );
226 attr: function( elem, name ) {
227 var fn = jQuery.expr.attrHandle[ name.toLowerCase() ],
229 // Don't get fooled by Object.prototype properties (jQuery #13807)
230 value = fn && hasOwn.call( jQuery.expr.attrHandle, name.toLowerCase() ) ?
231 fn( elem, name, jQuery.isXMLDoc( elem ) ) :
233 return value !== undefined ? value : elem.getAttribute( name );