(ts)
| 2795 | * @returns {FunctionNode | undefined} the consumed function node |
| 2796 | */ |
| 2797 | const consumeAFunction = (ts) => { |
| 2798 | const { input } = ts; |
| 2799 | // Assert (spec): the next token is a <function-token>. |
| 2800 | // Consume a token from input, and let function be a new function with its name equal the returned token’s value, and a value set to an empty list. |
| 2801 | const tFn = ts.consume(); |
| 2802 | const fn = /** @type {FunctionNode} */ ( |
| 2803 | _mkContainer(T_FUNCTION, tFn.start, tFn.end) |
| 2804 | ); |
| 2805 | _setName(fn, input.slice(tFn.start, tFn.end - 1), tFn.start, tFn.end - 1); |
| 2806 | const val = _list(); |
| 2807 | _setValue(fn, val); |
| 2808 | |
| 2809 | // Process input |
| 2810 | for (;;) { |
| 2811 | const t = ts.next(); |
| 2812 | |
| 2813 | if (t.type === TT_EOF || t.type === TT_RIGHT_PARENTHESIS) { |
| 2814 | // <eof-token> |
| 2815 | // <)-token> |
| 2816 | // Discard a token from input. Return function. |
| 2817 | ts.discard(); |
| 2818 | _setEnd(fn, t.end); |
| 2819 | return fn; |
| 2820 | } |
| 2821 | |
| 2822 | // anything else |
| 2823 | // Consume a component value from input and append the result to function’s value. |
| 2824 | val.push(consumeAComponentValue(ts, t)); |
| 2825 | } |
| 2826 | }; |
| 2827 | |
| 2828 | // Identifier escape / unescape — operate on the raw text of an |
| 2829 | // `<ident-token>` (or any source slice that may carry CSS escape sequences). |
no test coverage detected