(ts, t = ts.next())
| 2726 | * @returns {SimpleBlock | FunctionNode | ComponentValue} the consumed component value |
| 2727 | */ |
| 2728 | const consumeAComponentValue = (ts, t = ts.next()) => { |
| 2729 | // `t` is the next token; hot callers already peeked it and pass it in to |
| 2730 | // skip a redundant `ts.next()` per component value. |
| 2731 | // <{-token> / <[-token> / <(-token> (the three contiguous opening brackets) |
| 2732 | // Consume a simple block from input and return the result. |
| 2733 | if (t.type >= TT_LEFT_PARENTHESIS && t.type <= TT_LEFT_CURLY_BRACKET) { |
| 2734 | return /** @type {SimpleBlock} */ (consumeASimpleBlock(ts)); |
| 2735 | } |
| 2736 | // <function-token> |
| 2737 | // Consume a function from input and return the result. |
| 2738 | if (t.type === TT_FUNCTION) { |
| 2739 | return /** @type {FunctionNode} */ (consumeAFunction(ts)); |
| 2740 | } |
| 2741 | // anything else |
| 2742 | // Consume a token from input and return the result. (Asserted: not EOF.) |
| 2743 | // Inlined `consumeATokenAsNode`: `t` is already the peeked next token, so |
| 2744 | // advance past it and materialize it directly — one fewer call per leaf |
| 2745 | // component value (the bulk of the nodes on a large stylesheet). |
| 2746 | ts.consume(); |
| 2747 | return /** @type {ComponentValue} */ (tokenToNode(t)); |
| 2748 | }; |
| 2749 | |
| 2750 | /** |
| 2751 | * Consume a simple block, CSS Syntax Level 3 [§5.4.9](https://drafts.csswg.org/css-syntax/#consume-simple-block) — the next token must be `(`, `[`, or `{` (asserted); consumes component values via `consumeAComponentValue` until the mirror closing token (`)`, `]`, `}`) or EOF, returning the partial block on EOF (parse error). |
no test coverage detected