scratch – Blame information for rev 125
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
125 | office | 1 | define([ |
2 | "./core" |
||
3 | ], function( jQuery ) { |
||
58 | office | 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 | |||
125 | office | 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; |
||
58 | office | 42 | } |
43 | |||
125 | office | 44 | var compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b ); |
58 | office | 45 | |
125 | office | 46 | if ( compare ) { |
47 | // Disconnected nodes |
||
48 | if ( compare & 1 ) { |
||
58 | office | 49 | |
125 | office | 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 | } |
||
58 | office | 57 | |
125 | office | 58 | // Maintain original order |
59 | return 0; |
||
60 | } |
||
58 | office | 61 | |
125 | office | 62 | return compare & 4 ? -1 : 1; |
58 | office | 63 | } |
64 | |||
125 | office | 65 | // Not directly comparable, sort on existence of method |
66 | return a.compareDocumentPosition ? -1 : 1; |
||
67 | }; |
||
58 | office | 68 | |
125 | office | 69 | jQuery.extend({ |
58 | office | 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 |
||
125 | office | 83 | if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { |
58 | office | 84 | return []; |
85 | } |
||
86 | |||
87 | if ( seed ) { |
||
125 | office | 88 | while ( (elem = seed[i++]) ) { |
89 | if ( jQuery.find.matchesSelector(elem, selector) ) { |
||
58 | office | 90 | results.push( elem ); |
91 | } |
||
92 | } |
||
93 | } else { |
||
125 | office | 94 | jQuery.merge( results, context.querySelectorAll(selector) ); |
58 | office | 95 | } |
96 | |||
97 | return results; |
||
98 | }, |
||
125 | office | 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 | }, |
||
58 | office | 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 |
||
125 | office | 129 | while ( (node = elem[i++]) ) { |
58 | office | 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; |
||
125 | office | 146 | return a === bup || !!( bup && bup.nodeType === 1 && adown.contains(bup) ); |
58 | office | 147 | }, |
148 | isXMLDoc: function( elem ) { |
||
125 | office | 149 | return (elem.ownerDocument || elem).documentElement.nodeName !== "HTML"; |
58 | office | 150 | }, |
151 | expr: { |
||
152 | attrHandle: {}, |
||
153 | match: { |
||
125 | office | 154 | bool: /^(?:checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$/i, |
58 | office | 155 | needsContext: /^[\x20\t\r\n\f]*[>+~]/ |
156 | } |
||
157 | } |
||
125 | office | 158 | }); |
58 | office | 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 ) { |
||
125 | office | 168 | return elem.getAttribute( name ); |
58 | office | 169 | } |
125 | office | 170 | }); |
58 | office | 171 | |
125 | office | 172 | }); |