|
8 | 8 | return {}.toString.call(array) === '[object Array]'; |
9 | 9 | }; |
10 | 10 |
|
| 11 | + var LEFT_SIDE = {}; |
| 12 | + var RIGHT_SIDE = {}; |
| 13 | + |
11 | 14 | function esqueryModule() { |
12 | 15 |
|
13 | 16 | /** |
|
122 | 125 |
|
123 | 126 | case 'sibling': |
124 | 127 | return matches(node, selector.right, ancestry) && |
125 | | - sibling(node, selector.left, ancestry, 'left') || |
| 128 | + sibling(node, selector.left, ancestry, LEFT_SIDE) || |
126 | 129 | matches(node, selector.left, ancestry) && |
127 | | - sibling(node, selector.right, ancestry, 'right') && |
| 130 | + sibling(node, selector.right, ancestry, RIGHT_SIDE) && |
128 | 131 | selector.left.subject; |
129 | 132 |
|
130 | 133 | case 'adjacent': |
131 | 134 | return matches(node, selector.right, ancestry) && |
132 | | - adjacent(node, selector.left, ancestry, 'left') || |
| 135 | + adjacent(node, selector.left, ancestry, LEFT_SIDE) || |
133 | 136 | matches(node, selector.left, ancestry) && |
134 | | - adjacent(node, selector.right, ancestry, 'right') && |
| 137 | + adjacent(node, selector.right, ancestry, RIGHT_SIDE) && |
135 | 138 | selector.left.subject; |
136 | 139 |
|
137 | 140 | case 'nth-child': |
|
183 | 186 | if (isArray(listProp)) { |
184 | 187 | startIndex = listProp.indexOf(node); |
185 | 188 | if (startIndex < 0) { continue; } |
186 | | - if (side === 'left') { |
| 189 | + if (side === LEFT_SIDE) { |
187 | 190 | lowerBound = 0; |
188 | 191 | upperBound = startIndex; |
189 | 192 | } else { |
|
212 | 215 | if (isArray(listProp)) { |
213 | 216 | idx = listProp.indexOf(node); |
214 | 217 | if (idx < 0) { continue; } |
215 | | - if (side === 'left' && idx > 0 && matches(listProp[idx - 1], selector, ancestry)) { |
| 218 | + if (side === LEFT_SIDE && idx > 0 && matches(listProp[idx - 1], selector, ancestry)) { |
216 | 219 | return true; |
217 | 220 | } |
218 | | - if (side === 'right' && idx < listProp.length - 1 && matches(listProp[idx + 1], selector, ancestry)) { |
| 221 | + if (side === RIGHT_SIDE && idx < listProp.length - 1 && matches(listProp[idx + 1], selector, ancestry)) { |
219 | 222 | return true; |
220 | 223 | } |
221 | 224 | } |
|
0 commit comments