nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / jquery / src / selector-native.js
1 define( [
2         "./core",
3         "./var/document",
4         "./var/documentElement",
5         "./var/hasOwn",
6         "./var/indexOf"
7 ], function( jQuery, document, documentElement, hasOwn, indexOf ) {
8
9 /*
10  * Optional (non-Sizzle) selector module for custom builds.
11  *
12  * Note that this DOES NOT SUPPORT many documented jQuery
13  * features in exchange for its smaller size:
14  *
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.)
19  * :has(selector)
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)
29  *
30  * If any of these are unacceptable tradeoffs, either use Sizzle or
31  * customize this stub for the project's specific needs.
32  */
33
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;
41
42 function sortOrder( a, b ) {
43
44         // Flag for duplicate removal
45         if ( a === b ) {
46                 hasDuplicate = true;
47                 return 0;
48         }
49
50         // Sort on method existence if only one input has compareDocumentPosition
51         var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
52         if ( compare ) {
53                 return compare;
54         }
55
56         // Calculate position if both inputs belong to the same document
57         compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
58                 a.compareDocumentPosition( b ) :
59
60                 // Otherwise we know they are disconnected
61                 1;
62
63         // Disconnected nodes
64         if ( compare & 1 ) {
65
66                 // Choose the first element that is related to our preferred document
67                 if ( a === document || a.ownerDocument === document &&
68                         jQuery.contains( document, a ) ) {
69                         return -1;
70                 }
71                 if ( b === document || b.ownerDocument === document &&
72                         jQuery.contains( document, b ) ) {
73                         return 1;
74                 }
75
76                 // Maintain original order
77                 return sortInput ?
78                         ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
79                         0;
80         }
81
82         return compare & 4 ? -1 : 1;
83 }
84
85 function uniqueSort( results ) {
86         var elem,
87                 duplicates = [],
88                 j = 0,
89                 i = 0;
90
91         hasDuplicate = false;
92         sortInput = !sortStable && results.slice( 0 );
93         results.sort( sortOrder );
94
95         if ( hasDuplicate ) {
96                 while ( ( elem = results[ i++ ] ) ) {
97                         if ( elem === results[ i ] ) {
98                                 j = duplicates.push( i );
99                         }
100                 }
101                 while ( j-- ) {
102                         results.splice( duplicates[ j ], 1 );
103                 }
104         }
105
106         // Clear input after sorting to release objects
107         // See https://github.com/jquery/sizzle/pull/225
108         sortInput = null;
109
110         return results;
111 }
112
113 jQuery.extend( {
114         find: function( selector, context, results, seed ) {
115                 var elem, nodeType,
116                         i = 0;
117
118                 results = results || [];
119                 context = context || document;
120
121                 // Same basic safeguard as Sizzle
122                 if ( !selector || typeof selector !== "string" ) {
123                         return results;
124                 }
125
126                 // Early return if context is not an element or document
127                 if ( ( nodeType = context.nodeType ) !== 1 && nodeType !== 9 ) {
128                         return [];
129                 }
130
131                 if ( seed ) {
132                         while ( ( elem = seed[ i++ ] ) ) {
133                                 if ( jQuery.find.matchesSelector( elem, selector ) ) {
134                                         results.push( elem );
135                                 }
136                         }
137                 } else {
138                         jQuery.merge( results, context.querySelectorAll( selector ) );
139                 }
140
141                 return results;
142         },
143         uniqueSort: uniqueSort,
144         unique: uniqueSort,
145         text: function( elem ) {
146                 var node,
147                         ret = "",
148                         i = 0,
149                         nodeType = elem.nodeType;
150
151                 if ( !nodeType ) {
152
153                         // If no nodeType, this is expected to be an array
154                         while ( ( node = elem[ i++ ] ) ) {
155
156                                 // Do not traverse comment nodes
157                                 ret += jQuery.text( node );
158                         }
159                 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
160
161                         // Use textContent for elements
162                         return elem.textContent;
163                 } else if ( nodeType === 3 || nodeType === 4 ) {
164                         return elem.nodeValue;
165                 }
166
167                 // Do not include comment or processing instruction nodes
168
169                 return ret;
170         },
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 ) );
175         },
176         isXMLDoc: function( elem ) {
177
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;
182         },
183         expr: {
184                 attrHandle: {},
185                 match: {
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]*[>+~]/
189                 }
190         }
191 } );
192
193 jQuery.extend( jQuery.find, {
194         matches: function( expr, elements ) {
195                 return jQuery.find( expr, null, null, elements );
196         },
197         matchesSelector: function( elem, expr ) {
198                 return matches.call( elem, expr );
199         },
200         attr: function( elem, name ) {
201                 var fn = jQuery.expr.attrHandle[ name.toLowerCase() ],
202
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 ) ) :
206                                 undefined;
207                 return value !== undefined ? value : elem.getAttribute( name );
208         }
209 } );
210
211 } );