Add pseudo-element after/before handling; this is not actually used yet
during rendering anywhere.
Showing
1 changed file
with
12 additions
and
1 deletions
... | @@ -37,7 +37,8 @@ const nthChildPos = (node, parent) => filterChildElements(parent).findIndex((chi | ... | @@ -37,7 +37,8 @@ const nthChildPos = (node, parent) => filterChildElements(parent).findIndex((chi |
37 | 37 | ||
38 | const filterChildElementsMatcher = (context, child, parent, i) => child.type === ELEMENT_NODE | 38 | const filterChildElementsMatcher = (context, child, parent, i) => child.type === ELEMENT_NODE |
39 | 39 | ||
40 | type Matcher = (context, node: NodeType, parent?: NodeType, i: number, debug: number) => boolean | 40 | type NodePosition = number | 'before' | 'after' |
41 | type Matcher = (context, node: NodeType, parent?: NodeType, i: NodePosition, debug: number) => boolean | ||
41 | type MatcherProducer = () => Matcher | 42 | type MatcherProducer = () => Matcher |
42 | type AttrValueMatch = (string) => string | 43 | type AttrValueMatch = (string) => string |
43 | 44 | ||
... | @@ -295,6 +296,16 @@ const compileMatcher = (ast: AST, selector: string): MatcherProducer => { | ... | @@ -295,6 +296,16 @@ const compileMatcher = (ast: AST, selector: string): MatcherProducer => { |
295 | } | 296 | } |
296 | case 'universal': | 297 | case 'universal': |
297 | return (context, node, parent, i, debug) => true | 298 | return (context, node, parent, i, debug) => true |
299 | case 'pseudo-element': | ||
300 | switch (ast.name) { | ||
301 | case 'after': | ||
302 | return (context, node, parent, i, debug) => i === 'after' | ||
303 | case 'before': | ||
304 | return (context, node, parent, i, debug) => i === 'before' | ||
305 | default: | ||
306 | console.error('pseudo-class', nodeUtil.inspect({ selector, ast }, { depth: null, colors: true })) | ||
307 | throw new Error(`Unknown pseudo-class: ${ast.name}`) | ||
308 | } | ||
298 | default: | 309 | default: |
299 | throw new Error(`Unhandled ast: ${ast.type}`) | 310 | throw new Error(`Unhandled ast: ${ast.type}`) |
300 | } | 311 | } | ... | ... |
-
Please register or sign in to post a comment