scratch – Diff between revs 58 and 125

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 58 Rev 125
1 define( [ 1 define([
2 "./core", 2 "./core"
3 "./var/document", -  
4 "./var/documentElement", 3 ], function( jQuery ) {
5 "./var/hasOwn", -  
6 "./var/indexOf" -  
7 ], function( jQuery, document, documentElement, hasOwn, indexOf ) { -  
8   -  
9 "use strict"; -  
10   4  
11 /* 5 /*
12 * Optional (non-Sizzle) selector module for custom builds. 6 * Optional (non-Sizzle) selector module for custom builds.
13 * 7 *
14 * Note that this DOES NOT SUPPORT many documented jQuery 8 * Note that this DOES NOT SUPPORT many documented jQuery
15 * features in exchange for its smaller size: 9 * features in exchange for its smaller size:
16 * 10 *
17 * Attribute not equal selector 11 * Attribute not equal selector
18 * Positional selectors (:first; :eq(n); :odd; etc.) 12 * Positional selectors (:first; :eq(n); :odd; etc.)
19 * Type selectors (:input; :checkbox; :button; etc.) 13 * Type selectors (:input; :checkbox; :button; etc.)
20 * State-based selectors (:animated; :visible; :hidden; etc.) 14 * State-based selectors (:animated; :visible; :hidden; etc.)
21 * :has(selector) 15 * :has(selector)
22 * :not(complex selector) 16 * :not(complex selector)
23 * custom selectors via Sizzle extensions 17 * custom selectors via Sizzle extensions
24 * Leading combinators (e.g., $collection.find("> *")) 18 * Leading combinators (e.g., $collection.find("> *"))
25 * Reliable functionality on XML fragments 19 * Reliable functionality on XML fragments
26 * Requiring all parts of a selector to match elements under context 20 * Requiring all parts of a selector to match elements under context
27 * (e.g., $div.find("div > *") now matches children of $div) 21 * (e.g., $div.find("div > *") now matches children of $div)
28 * Matching against non-elements 22 * Matching against non-elements
29 * Reliable sorting of disconnected nodes 23 * Reliable sorting of disconnected nodes
30 * querySelectorAll bug fixes (e.g., unreliable :focus on WebKit) 24 * querySelectorAll bug fixes (e.g., unreliable :focus on WebKit)
31 * 25 *
32 * If any of these are unacceptable tradeoffs, either use Sizzle or 26 * If any of these are unacceptable tradeoffs, either use Sizzle or
33 * customize this stub for the project's specific needs. 27 * customize this stub for the project's specific needs.
34 */ 28 */
35   29  
36 var hasDuplicate, sortInput, 30 var docElem = window.document.documentElement,
37 sortStable = jQuery.expando.split( "" ).sort( sortOrder ).join( "" ) === jQuery.expando, 31 selector_hasDuplicate,
38 matches = documentElement.matches || 32 matches = docElem.matches ||
39 documentElement.webkitMatchesSelector || 33 docElem.webkitMatchesSelector ||
40 documentElement.mozMatchesSelector || 34 docElem.mozMatchesSelector ||
41 documentElement.oMatchesSelector || 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  
42 documentElement.msMatchesSelector, 44 var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b );
-   45  
43   46 if ( compare ) {
-   47 // Disconnected nodes
-   48 if ( compare & 1 ) {
44 // CSS string/identifier serialization 49  
45 // https://drafts.csswg.org/cssom/#common-serializing-idioms 50 // Choose the first element that is related to our document
-   51 if ( a === document || jQuery.contains(document, a) ) {
-   52 return -1;
46 rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g, 53 }
47 fcssescape = function( ch, asCodePoint ) { 54 if ( b === document || jQuery.contains(document, b) ) {
-   55 return 1;
48 if ( asCodePoint ) { 56 }
49   -  
50 // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER 57  
51 if ( ch === "\0" ) { 58 // Maintain original order
52 return "\uFFFD"; 59 return 0;
53 } -  
54   60 }
55 // Control characters and (dependent upon position) numbers get escaped as code points 61  
56 return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; 62 return compare & 4 ? -1 : 1;
57 } 63 }
58   64  
59 // Other potentially-special ASCII characters get backslash-escaped -  
60 return "\\" + ch; -  
61 }; -  
62   -  
63 function sortOrder( a, b ) { -  
64   -  
65 // Flag for duplicate removal -  
66 if ( a === b ) { -  
67 hasDuplicate = true; -  
68 return 0; -  
69 } -  
70   -  
71 // Sort on method existence if only one input has compareDocumentPosition -  
72 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; -  
73 if ( compare ) { -  
74 return compare; -  
75 } -  
76   -  
77 // Calculate position if both inputs belong to the same document -  
78 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? -  
79 a.compareDocumentPosition( b ) : -  
80   -  
81 // Otherwise we know they are disconnected -  
82 1; -  
83   -  
84 // Disconnected nodes -  
85 if ( compare & 1 ) { -  
86   -  
87 // Choose the first element that is related to our preferred document -  
88 if ( a === document || a.ownerDocument === document && -  
89 jQuery.contains( document, a ) ) { -  
90 return -1; -  
91 } -  
92 if ( b === document || b.ownerDocument === document && -  
93 jQuery.contains( document, b ) ) { -  
94 return 1; -  
95 } -  
96   -  
97 // Maintain original order -  
98 return sortInput ? -  
99 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : -  
100 0; -  
101 } -  
102   -  
103 return compare & 4 ? -1 : 1; -  
104 } -  
105   -  
106 function uniqueSort( results ) { -  
107 var elem, -  
108 duplicates = [], -  
109 j = 0, -  
110 i = 0; -  
111   -  
112 hasDuplicate = false; -  
113 sortInput = !sortStable && results.slice( 0 ); -  
114 results.sort( sortOrder ); -  
115   -  
116 if ( hasDuplicate ) { -  
117 while ( ( elem = results[ i++ ] ) ) { -  
118 if ( elem === results[ i ] ) { -  
119 j = duplicates.push( i ); -  
120 } -  
121 } -  
122 while ( j-- ) { -  
123 results.splice( duplicates[ j ], 1 ); -  
124 } -  
125 } -  
126   -  
127 // Clear input after sorting to release objects -  
128 // See https://github.com/jquery/sizzle/pull/225 -  
129 sortInput = null; -  
130   -  
131 return results; -  
132 } -  
133   -  
134 function escape( sel ) { 65 // Not directly comparable, sort on existence of method
135 return ( sel + "" ).replace( rcssescape, fcssescape ); -  
136 } -  
137   -  
138 jQuery.extend( { 66 return a.compareDocumentPosition ? -1 : 1;
139 uniqueSort: uniqueSort, 67 };
140 unique: uniqueSort, 68  
141 escapeSelector: escape, 69 jQuery.extend({
142 find: function( selector, context, results, seed ) { 70 find: function( selector, context, results, seed ) {
143 var elem, nodeType, 71 var elem, nodeType,
144 i = 0; 72 i = 0;
145   73  
146 results = results || []; 74 results = results || [];
147 context = context || document; 75 context = context || document;
148   76  
149 // Same basic safeguard as Sizzle 77 // Same basic safeguard as Sizzle
150 if ( !selector || typeof selector !== "string" ) { 78 if ( !selector || typeof selector !== "string" ) {
151 return results; 79 return results;
152 } 80 }
153   81  
154 // Early return if context is not an element or document 82 // Early return if context is not an element or document
155 if ( ( nodeType = context.nodeType ) !== 1 && nodeType !== 9 ) { 83 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
156 return []; 84 return [];
157 } 85 }
158   86  
159 if ( seed ) { 87 if ( seed ) {
160 while ( ( elem = seed[ i++ ] ) ) { 88 while ( (elem = seed[i++]) ) {
161 if ( jQuery.find.matchesSelector( elem, selector ) ) { 89 if ( jQuery.find.matchesSelector(elem, selector) ) {
162 results.push( elem ); 90 results.push( elem );
163 } 91 }
164 } 92 }
165 } else { 93 } else {
166 jQuery.merge( results, context.querySelectorAll( selector ) ); 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 }
167 } 117 }
168   118  
169 return results; 119 return results;
170 }, 120 },
171 text: function( elem ) { 121 text: function( elem ) {
172 var node, 122 var node,
173 ret = "", 123 ret = "",
174 i = 0, 124 i = 0,
175 nodeType = elem.nodeType; 125 nodeType = elem.nodeType;
176   126  
177 if ( !nodeType ) { 127 if ( !nodeType ) {
178   -  
179 // If no nodeType, this is expected to be an array 128 // If no nodeType, this is expected to be an array
180 while ( ( node = elem[ i++ ] ) ) { 129 while ( (node = elem[i++]) ) {
181   -  
182 // Do not traverse comment nodes 130 // Do not traverse comment nodes
183 ret += jQuery.text( node ); 131 ret += jQuery.text( node );
184 } 132 }
185 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { 133 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
186   -  
187 // Use textContent for elements 134 // Use textContent for elements
188 return elem.textContent; 135 return elem.textContent;
189 } else if ( nodeType === 3 || nodeType === 4 ) { 136 } else if ( nodeType === 3 || nodeType === 4 ) {
190 return elem.nodeValue; 137 return elem.nodeValue;
191 } 138 }
192   -  
193 // Do not include comment or processing instruction nodes 139 // Do not include comment or processing instruction nodes
194   140  
195 return ret; 141 return ret;
196 }, 142 },
197 contains: function( a, b ) { 143 contains: function( a, b ) {
198 var adown = a.nodeType === 9 ? a.documentElement : a, 144 var adown = a.nodeType === 9 ? a.documentElement : a,
199 bup = b && b.parentNode; 145 bup = b && b.parentNode;
200 return a === bup || !!( bup && bup.nodeType === 1 && adown.contains( bup ) ); 146 return a === bup || !!( bup && bup.nodeType === 1 && adown.contains(bup) );
201 }, 147 },
202 isXMLDoc: function( elem ) { 148 isXMLDoc: function( elem ) {
203   -  
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; 149 return (elem.ownerDocument || elem).documentElement.nodeName !== "HTML";
208 }, 150 },
209 expr: { 151 expr: {
210 attrHandle: {}, 152 attrHandle: {},
211 match: { 153 match: {
212 bool: new RegExp( "^(?:checked|selected|async|autofocus|autoplay|controls|defer" + -  
213 "|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$", "i" ), 154 bool: /^(?:checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$/i,
214 needsContext: /^[\x20\t\r\n\f]*[>+~]/ 155 needsContext: /^[\x20\t\r\n\f]*[>+~]/
215 } 156 }
216 } 157 }
217 } ); 158 });
218   159  
219 jQuery.extend( jQuery.find, { 160 jQuery.extend( jQuery.find, {
220 matches: function( expr, elements ) { 161 matches: function( expr, elements ) {
221 return jQuery.find( expr, null, null, elements ); 162 return jQuery.find( expr, null, null, elements );
222 }, 163 },
223 matchesSelector: function( elem, expr ) { 164 matchesSelector: function( elem, expr ) {
224 return matches.call( elem, expr ); 165 return matches.call( elem, expr );
225 }, 166 },
226 attr: function( elem, name ) { 167 attr: function( elem, name ) {
227 var fn = jQuery.expr.attrHandle[ name.toLowerCase() ], -  
228   -  
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 ) ) : -  
232 undefined; -  
233 return value !== undefined ? value : elem.getAttribute( name ); 168 return elem.getAttribute( name );
234 } 169 }
235 } ); 170 });
236   171  
237 } ); 172 });
238   173