-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
The input
const selectorValuePairs = [
['foo,bar', 'A'],
['bar,baz', 'B']
];should be equivalent to
const selectorValuePairs = [
['foo', 'A'],
['bar', 'A'],
['bar', 'B'],
['baz', 'B']
];Code location:
selderee/packages/selderee/src/DecisionTree.ts
Lines 59 to 74 in f8d12f9
| function toAstTerminalPairs<V>(array: [string, V][]): AstTerminalPair<V>[] { | |
| const len = array.length; | |
| const results = new Array(len) as AstTerminalPair<V>[]; | |
| for (let i = 0; i < len; i++) { | |
| const [selectorString, val] = array[i]; | |
| const ast = preprocess(parseley.parse1(selectorString)); | |
| results[i] = { | |
| ast: ast, | |
| terminal: { | |
| type: 'terminal', | |
| valueContainer: { index: i, value: val, specificity: ast.specificity } | |
| } | |
| }; | |
| } | |
| return results; | |
| } |
Instead of expecting exactly one result from parseley.parse1 - expect 1+ results from parseley.parse. Index has to increase for each parsed result rather than for each input array item.
The goal - more compact configuration for html-to-text package by allowing to group selectors that are treated in the same way (headings, blocks).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels