MCPcopy
hub / github.com/webpack/webpack / consumeAComponentValue

Function consumeAComponentValue

lib/css/syntax.js:2728–2748  ·  view source on GitHub ↗
(ts, t = ts.next())

Source from the content-addressed store, hash-verified

2726 * @returns {SimpleBlock | FunctionNode | ComponentValue} the consumed component value
2727 */
2728const 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).

Callers 7

parseAComponentValueFunction · 0.85
consumeAnAtRuleFunction · 0.85
consumeAQualifiedRuleFunction · 0.85
consumeASimpleBlockFunction · 0.85
consumeAFunctionFunction · 0.85

Calls 5

consumeASimpleBlockFunction · 0.85
consumeAFunctionFunction · 0.85
tokenToNodeFunction · 0.85
consumeMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected