scratch – Diff between revs 58 and 125

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 58 Rev 125
Line 1... Line 1...
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"; -  
Line 10... Line 4...
10   4  
11 /* 5 /*
12 * Optional (non-Sizzle) selector module for custom builds. 6 * Optional (non-Sizzle) selector module for custom builds.
13 * 7 *
Line 31... Line 25...
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 */
Line 35... Line 29...
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;
Line 53... Line -...
53 } -  
54   60 }
55 // Control characters and (dependent upon position) numbers get escaped as code points 61  
Line 56... Line 62...
56 return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; 62 return compare & 4 ? -1 : 1;
57 } 63 }
58   64  
Line 59... Line -...
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  
Line 141... Line 69...
141 escapeSelector: escape, 69 jQuery.extend({
Line 150... Line 78...
150 if ( !selector || typeof selector !== "string" ) { 78 if ( !selector || typeof selector !== "string" ) {
151 return results; 79 return results;
152 } 80 }
Line 153... Line 81...
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 [];
Line 157... Line 85...
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 }
-   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-- ) {
165 } else { 115 results.splice( duplicates[ j ], 1 );
Line 166... Line 116...
166 jQuery.merge( results, context.querySelectorAll( selector ) ); 116 }
167 } 117 }
168   118  
Line 173... Line 123...
173 ret = "", 123 ret = "",
174 i = 0, 124 i = 0,
175 nodeType = elem.nodeType; 125 nodeType = elem.nodeType;
Line 176... Line 126...
176   126  
177 if ( !nodeType ) { -  
178   127 if ( !nodeType ) {
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++ ] ) ) { -  
181   129 while ( (node = elem[i++]) ) {
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 ) { -  
186   133 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
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 } -  
192   138 }
Line 193... Line 139...
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 }, -  
202 isXMLDoc: function( elem ) { -  
203   -  
204 // documentElement is verified for cases where it doesn't yet exist -  
205 // (such as loading iframes in IE - #4833) 147 },
206 var documentElement = elem && ( elem.ownerDocument || elem ).documentElement; 148 isXMLDoc: function( elem ) {
207 return documentElement ? documentElement.nodeName !== "HTML" : false; 149 return (elem.ownerDocument || elem).documentElement.nodeName !== "HTML";
208 }, 150 },
209 expr: { 151 expr: {
210 attrHandle: {}, -  
211 match: { 152 attrHandle: {},
212 bool: new RegExp( "^(?:checked|selected|async|autofocus|autoplay|controls|defer" + 153 match: {
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 }
Line 216... Line 157...
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 ); -  
225 }, -  
226 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() ) ? 165 return matches.call( elem, expr );
231 fn( elem, name, jQuery.isXMLDoc( elem ) ) : 166 },
232 undefined; 167 attr: function( elem, name ) {
Line 233... Line 168...
233 return value !== undefined ? value : elem.getAttribute( name ); 168 return elem.getAttribute( name );