4 "./var/documentElement",
7 ], function( jQuery, document, documentElement, hasOwn, indexOf ) {
10 * Optional (non-Sizzle) selector module for custom builds.
12 * Note that this DOES NOT SUPPORT many documented jQuery
13 * features in exchange for its smaller size:
15 * Attribute not equal selector
16 * Positional selectors (:first; :eq(n); :odd; etc.)
17 * Type selectors (:input; :checkbox; :button; etc.)
18 * State-based selectors (:animated; :visible; :hidden; etc.)
20 * :not(complex selector)
21 * custom selectors via Sizzle extensions
22 * Leading combinators (e.g., $collection.find("> *"))
23 * Reliable functionality on XML fragments
24 * Requiring all parts of a selector to match elements under context
25 * (e.g., $div.find("div > *") now matches children of $div)
26 * Matching against non-elements
27 * Reliable sorting of disconnected nodes
28 * querySelectorAll bug fixes (e.g., unreliable :focus on WebKit)
30 * If any of these are unacceptable tradeoffs, either use Sizzle or
31 * customize this stub for the project's specific needs.
34 var hasDuplicate, sortInput,
35 sortStable = jQuery.expando.split( "" ).sort( sortOrder ).join( "" ) === jQuery.expando,
36 matches = documentElement.matches ||
37 documentElement.webkitMatchesSelector ||
38 documentElement.mozMatchesSelector ||
39 documentElement.oMatchesSelector ||
40 documentElement.msMatchesSelector;
42 function sortOrder( a, b ) {
44 // Flag for duplicate removal
50 // Sort on method existence if only one input has compareDocumentPosition
51 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
56 // Calculate position if both inputs belong to the same document
57 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
58 a.compareDocumentPosition( b ) :
60 // Otherwise we know they are disconnected
66 // Choose the first element that is related to our preferred document
67 if ( a === document || a.ownerDocument === document &&
68 jQuery.contains( document, a ) ) {
71 if ( b === document || b.ownerDocument === document &&
72 jQuery.contains( document, b ) ) {
76 // Maintain original order
78 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
82 return compare & 4 ? -1 : 1;
85 function uniqueSort( results ) {
92 sortInput = !sortStable && results.slice( 0 );
93 results.sort( sortOrder );
96 while ( ( elem = results[ i++ ] ) ) {
97 if ( elem === results[ i ] ) {
98 j = duplicates.push( i );
102 results.splice( duplicates[ j ], 1 );
106 // Clear input after sorting to release objects
107 // See https://github.com/jquery/sizzle/pull/225
114 find: function( selector, context, results, seed ) {
118 results = results || [];
119 context = context || document;
121 // Same basic safeguard as Sizzle
122 if ( !selector || typeof selector !== "string" ) {
126 // Early return if context is not an element or document
127 if ( ( nodeType = context.nodeType ) !== 1 && nodeType !== 9 ) {
132 while ( ( elem = seed[ i++ ] ) ) {
133 if ( jQuery.find.matchesSelector( elem, selector ) ) {
134 results.push( elem );
138 jQuery.merge( results, context.querySelectorAll( selector ) );
143 uniqueSort: uniqueSort,
145 text: function( elem ) {
149 nodeType = elem.nodeType;
153 // If no nodeType, this is expected to be an array
154 while ( ( node = elem[ i++ ] ) ) {
156 // Do not traverse comment nodes
157 ret += jQuery.text( node );
159 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
161 // Use textContent for elements
162 return elem.textContent;
163 } else if ( nodeType === 3 || nodeType === 4 ) {
164 return elem.nodeValue;
167 // Do not include comment or processing instruction nodes
171 contains: function( a, b ) {
172 var adown = a.nodeType === 9 ? a.documentElement : a,
173 bup = b && b.parentNode;
174 return a === bup || !!( bup && bup.nodeType === 1 && adown.contains( bup ) );
176 isXMLDoc: function( elem ) {
178 // documentElement is verified for cases where it doesn't yet exist
179 // (such as loading iframes in IE - #4833)
180 var documentElement = elem && ( elem.ownerDocument || elem ).documentElement;
181 return documentElement ? documentElement.nodeName !== "HTML" : false;
186 bool: new RegExp( "^(?:checked|selected|async|autofocus|autoplay|controls|defer" +
187 "|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$", "i" ),
188 needsContext: /^[\x20\t\r\n\f]*[>+~]/
193 jQuery.extend( jQuery.find, {
194 matches: function( expr, elements ) {
195 return jQuery.find( expr, null, null, elements );
197 matchesSelector: function( elem, expr ) {
198 return matches.call( elem, expr );
200 attr: function( elem, name ) {
201 var fn = jQuery.expr.attrHandle[ name.toLowerCase() ],
203 // Don't get fooled by Object.prototype properties (jQuery #13807)
204 value = fn && hasOwn.call( jQuery.expr.attrHandle, name.toLowerCase() ) ?
205 fn( elem, name, jQuery.isXMLDoc( elem ) ) :
207 return value !== undefined ? value : elem.getAttribute( name );