scratch – Diff between revs 58 and 125
?pathlinks?
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 || |
|
42 | documentElement.msMatchesSelector, |
- | ||
43 | |
- | ||
44 | // CSS string/identifier serialization |
- | ||
45 | // https://drafts.csswg.org/cssom/#common-serializing-idioms |
- | ||
46 | rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g, |
- | ||
47 | fcssescape = function( ch, asCodePoint ) { |
- | ||
48 | if ( asCodePoint ) { |
- | ||
49 | |
- | ||
50 | // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER |
- | ||
51 | if ( ch === "\0" ) { |
- | ||
52 | return "\uFFFD"; |
- | ||
53 | } |
- | ||
54 | |
- | ||
55 | // Control characters and (dependent upon position) numbers get escaped as code points |
- | ||
56 | return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; |
- | ||
57 | } |
- | ||
58 | |
- | ||
59 | // Other potentially-special ASCII characters get backslash-escaped |
- | ||
60 | return "\\" + ch; |
- | ||
61 | }; |
- | ||
62 | |
36 | docElem.msMatchesSelector, |
|
63 | function sortOrder( a, b ) { |
- | ||
64 | |
37 | selector_sortOrder = function( a, b ) { |
|
65 | // Flag for duplicate removal |
38 | // Flag for duplicate removal |
|
66 | if ( a === b ) { |
39 | if ( a === b ) { |
|
67 | hasDuplicate = true; |
40 | selector_hasDuplicate = true; |
|
68 | return 0; |
41 | return 0; |
|
Line 69... | Line -... | |||
69 | } |
- | ||
70 | |
42 | } |
|
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 | |
- | ||
Line -... | Line 43... | |||
- | 43 | |
||
81 | // Otherwise we know they are disconnected |
44 | var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b ); |
|
82 | 1; |
45 | |
|
Line 83... | Line 46... | |||
83 | |
46 | if ( compare ) { |
|
84 | // Disconnected nodes |
47 | // Disconnected nodes |
|
85 | if ( compare & 1 ) { |
- | ||
86 | |
48 | if ( compare & 1 ) { |
|
87 | // Choose the first element that is related to our preferred document |
49 | |
|
88 | if ( a === document || a.ownerDocument === document && |
50 | // Choose the first element that is related to our document |
|
89 | jQuery.contains( document, a ) ) { |
- | ||
90 | return -1; |
51 | if ( a === document || jQuery.contains(document, a) ) { |
|
91 | } |
52 | return -1; |
|
Line 92... | Line 53... | |||
92 | if ( b === document || b.ownerDocument === document && |
53 | } |
|
93 | jQuery.contains( document, b ) ) { |
54 | if ( b === document || jQuery.contains(document, b) ) { |
|
94 | return 1; |
- | ||
95 | } |
- | ||
96 | |
55 | return 1; |
|
Line 97... | Line 56... | |||
97 | // Maintain original order |
56 | } |
|
98 | return sortInput ? |
57 | |
|
Line 99... | Line -... | |||
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 ) { |
58 | // Maintain original order |
|
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 ) { |
59 | return 0; |
|
117 | while ( ( elem = results[ i++ ] ) ) { |
- | ||
118 | if ( elem === results[ i ] ) { |
60 | } |
|
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; |
- | ||
Line 130... | Line 61... | |||
130 | |
61 | |
|
131 | return results; |
- | ||
132 | } |
- | ||
133 | |
- | ||
134 | function escape( sel ) { |
62 | return compare & 4 ? -1 : 1; |
|
135 | return ( sel + "" ).replace( rcssescape, fcssescape ); |
63 | } |
|
136 | } |
64 | |
|
Line 137... | Line 65... | |||
137 | |
65 | // Not directly comparable, sort on existence of method |
|
Line 166... | Line 94... | |||
166 | jQuery.merge( results, context.querySelectorAll( selector ) ); |
94 | jQuery.merge( results, context.querySelectorAll(selector) ); |
|
167 | } |
95 | } |
|
Line 168... | Line 96... | |||
168 | |
96 | |
|
169 | return results; |
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; |
||
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, |
|
Line 175... | Line 125... | |||
175 | nodeType = elem.nodeType; |
125 | nodeType = elem.nodeType; |
|
176 | |
- | ||
177 | if ( !nodeType ) { |
126 | |
|
178 | |
127 | if ( !nodeType ) { |
|
179 | // If no nodeType, this is expected to be an array |
- | ||
180 | while ( ( node = elem[ i++ ] ) ) { |
128 | // If no nodeType, this is expected to be an array |
|
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 | } |
- | ||
185 | } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { |
132 | } |
|
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; |
- | ||
191 | } |
137 | return elem.nodeValue; |
|
Line 192... | Line 138... | |||
192 | |
138 | } |
|
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 ) ); |
- | ||
201 | }, |
- | ||
202 | isXMLDoc: function( elem ) { |
- | ||
203 | |
- | ||
204 | // documentElement is verified for cases where it doesn't yet exist |
146 | return a === bup || !!( bup && bup.nodeType === 1 && adown.contains(bup) ); |
|
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: { |
- | ||
210 | attrHandle: {}, |
151 | expr: { |
|
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]*[>+~]/ |
|
Line 222... | Line 163... | |||
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 | }); |
|
Line 236... | Line 171... | |||
236 | |
171 | |