]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/ex-mode/node_modules/space-pen/node_modules/jquery/src/selector-native.js
d8163c2f9bcbe080f3f9906be7c1f4531cf3cc8c
[rbdr/dotfiles] / atom / packages / ex-mode / node_modules / space-pen / node_modules / jquery / src / selector-native.js
1 define([
2 "./core"
3 ], function( jQuery ) {
4
5 /*
6 * Optional (non-Sizzle) selector module for custom builds.
7 *
8 * Note that this DOES NOT SUPPORT many documented jQuery
9 * features in exchange for its smaller size:
10 *
11 * Attribute not equal selector
12 * Positional selectors (:first; :eq(n); :odd; etc.)
13 * Type selectors (:input; :checkbox; :button; etc.)
14 * State-based selectors (:animated; :visible; :hidden; etc.)
15 * :has(selector)
16 * :not(complex selector)
17 * custom selectors via Sizzle extensions
18 * Leading combinators (e.g., $collection.find("> *"))
19 * Reliable functionality on XML fragments
20 * Requiring all parts of a selector to match elements under context
21 * (e.g., $div.find("div > *") now matches children of $div)
22 * Matching against non-elements
23 * Reliable sorting of disconnected nodes
24 * querySelectorAll bug fixes (e.g., unreliable :focus on WebKit)
25 *
26 * If any of these are unacceptable tradeoffs, either use Sizzle or
27 * customize this stub for the project's specific needs.
28 */
29
30 var docElem = window.document.documentElement,
31 selector_hasDuplicate,
32 matches = docElem.matches ||
33 docElem.webkitMatchesSelector ||
34 docElem.mozMatchesSelector ||
35 docElem.oMatchesSelector ||
36 docElem.msMatchesSelector,
37 selector_sortOrder = function( a, b ) {
38 // Flag for duplicate removal
39 if ( a === b ) {
40 selector_hasDuplicate = true;
41 return 0;
42 }
43
44 var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b );
45
46 if ( compare ) {
47 // Disconnected nodes
48 if ( compare & 1 ) {
49
50 // Choose the first element that is related to our document
51 if ( a === document || jQuery.contains(document, a) ) {
52 return -1;
53 }
54 if ( b === document || jQuery.contains(document, b) ) {
55 return 1;
56 }
57
58 // Maintain original order
59 return 0;
60 }
61
62 return compare & 4 ? -1 : 1;
63 }
64
65 // Not directly comparable, sort on existence of method
66 return a.compareDocumentPosition ? -1 : 1;
67 };
68
69 jQuery.extend({
70 find: function( selector, context, results, seed ) {
71 var elem, nodeType,
72 i = 0;
73
74 results = results || [];
75 context = context || document;
76
77 // Same basic safeguard as Sizzle
78 if ( !selector || typeof selector !== "string" ) {
79 return results;
80 }
81
82 // Early return if context is not an element or document
83 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
84 return [];
85 }
86
87 if ( seed ) {
88 while ( (elem = seed[i++]) ) {
89 if ( jQuery.find.matchesSelector(elem, selector) ) {
90 results.push( elem );
91 }
92 }
93 } else {
94 jQuery.merge( results, context.querySelectorAll(selector) );
95 }
96
97 return results;
98 },
99 unique: function( results ) {
100 var elem,
101 duplicates = [],
102 i = 0,
103 j = 0;
104
105 selector_hasDuplicate = false;
106 results.sort( selector_sortOrder );
107
108 if ( selector_hasDuplicate ) {
109 while ( (elem = results[i++]) ) {
110 if ( elem === results[ i ] ) {
111 j = duplicates.push( i );
112 }
113 }
114 while ( j-- ) {
115 results.splice( duplicates[ j ], 1 );
116 }
117 }
118
119 return results;
120 },
121 text: function( elem ) {
122 var node,
123 ret = "",
124 i = 0,
125 nodeType = elem.nodeType;
126
127 if ( !nodeType ) {
128 // If no nodeType, this is expected to be an array
129 while ( (node = elem[i++]) ) {
130 // Do not traverse comment nodes
131 ret += jQuery.text( node );
132 }
133 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
134 // Use textContent for elements
135 return elem.textContent;
136 } else if ( nodeType === 3 || nodeType === 4 ) {
137 return elem.nodeValue;
138 }
139 // Do not include comment or processing instruction nodes
140
141 return ret;
142 },
143 contains: function( a, b ) {
144 var adown = a.nodeType === 9 ? a.documentElement : a,
145 bup = b && b.parentNode;
146 return a === bup || !!( bup && bup.nodeType === 1 && adown.contains(bup) );
147 },
148 isXMLDoc: function( elem ) {
149 return (elem.ownerDocument || elem).documentElement.nodeName !== "HTML";
150 },
151 expr: {
152 attrHandle: {},
153 match: {
154 bool: /^(?:checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$/i,
155 needsContext: /^[\x20\t\r\n\f]*[>+~]/
156 }
157 }
158 });
159
160 jQuery.extend( jQuery.find, {
161 matches: function( expr, elements ) {
162 return jQuery.find( expr, null, null, elements );
163 },
164 matchesSelector: function( elem, expr ) {
165 return matches.call( elem, expr );
166 },
167 attr: function( elem, name ) {
168 return elem.getAttribute( name );
169 }
170 });
171
172 });