Reduce the debug.
Showing
1 changed file
with
2 additions
and
3 deletions
| ... | @@ -48,7 +48,6 @@ const compileMatcher = (ast: AST, selector: string): MatcherProducer => { | ... | @@ -48,7 +48,6 @@ const compileMatcher = (ast: AST, selector: string): MatcherProducer => { |
| 48 | neededContext[ selectorCacheCounter ] = () => new WeakMap() | 48 | neededContext[ selectorCacheCounter ] = () => new WeakMap() |
| 49 | 49 | ||
| 50 | const findChildren = (context, parent?: NodeType, selector: string, matcher: Matcher): array[NodeType] => { | 50 | const findChildren = (context, parent?: NodeType, selector: string, matcher: Matcher): array[NodeType] => { |
| 51 | if (parent === null) console.log('null parent', new Error()) | ||
| 52 | if (parent === null) return [] | 51 | if (parent === null) return [] |
| 53 | let selectorCache = context[ selectorCacheCounter ].get(parent) | 52 | let selectorCache = context[ selectorCacheCounter ].get(parent) |
| 54 | if (!selectorCache) context[ selectorCacheCounter ].set(parent, selectorCache = {}) | 53 | if (!selectorCache) context[ selectorCacheCounter ].set(parent, selectorCache = {}) |
| ... | @@ -242,7 +241,7 @@ const compileMatcher = (ast: AST, selector: string): MatcherProducer => { | ... | @@ -242,7 +241,7 @@ const compileMatcher = (ast: AST, selector: string): MatcherProducer => { |
| 242 | // case 'nth-last-of-type': | 241 | // case 'nth-last-of-type': |
| 243 | // case 'nth-last-child': | 242 | // case 'nth-last-child': |
| 244 | case 'nth-child': { | 243 | case 'nth-child': { |
| 245 | console.log('nth-child:ast', ast) | 244 | //console.log('nth-child:ast', ast) |
| 246 | const argument = ast.subtree ? ast.argument.replace(/\s*of\s+.*$/, '') : ast.argument | 245 | const argument = ast.subtree ? ast.argument.replace(/\s*of\s+.*$/, '') : ast.argument |
| 247 | const nthChildMatcher = makeNthChildPosMatcher(argument) | 246 | const nthChildMatcher = makeNthChildPosMatcher(argument) |
| 248 | let subDebug, childSelector, childMatcher | 247 | let subDebug, childSelector, childMatcher |
| ... | @@ -260,7 +259,7 @@ const compileMatcher = (ast: AST, selector: string): MatcherProducer => { | ... | @@ -260,7 +259,7 @@ const compileMatcher = (ast: AST, selector: string): MatcherProducer => { |
| 260 | const children = findChildren(context, parent, childSelector, childMatcher) | 259 | const children = findChildren(context, parent, childSelector, childMatcher) |
| 261 | const pos = children.indexOf(node) | 260 | const pos = children.indexOf(node) |
| 262 | if (parent?.name === 'body' && pos !== -1) { | 261 | if (parent?.name === 'body' && pos !== -1) { |
| 263 | console.log('nth-child:debug', {parent, childSelector, children, node, pos}) | 262 | //console.log('nth-child:debug', {parent, childSelector, children, node, pos}) |
| 264 | } | 263 | } |
| 265 | if (pos === -1) return false | 264 | if (pos === -1) return false |
| 266 | return nthChildMatcher(context, node, parent, pos + 1, debug || parent?.name === 'body') | 265 | return nthChildMatcher(context, node, parent, pos + 1, debug || parent?.name === 'body') | ... | ... |
-
Please register or sign in to post a comment