(input, pos, options = {})
| 2164 | * @returns {ComponentValue | undefined} the parsed component value, or `undefined` on empty / trailing-garbage input |
| 2165 | */ |
| 2166 | const parseAComponentValue = (input, pos, options = {}) => { |
| 2167 | // 1. Normalize input, and set input to the result. |
| 2168 | const ts = normalizeIntoTokenStream(input, pos, options.comment); |
| 2169 | useObjectBackend(ts.locConverter); |
| 2170 | // 2. Discard whitespace from input. |
| 2171 | while (ts.next().type === TT_WHITESPACE) ts.discard(); |
| 2172 | // 3. If input is empty, return a syntax error. |
| 2173 | if (ts.next().type === TT_EOF) return undefined; |
| 2174 | // 4. Consume a component value from input and let value be the return value. |
| 2175 | const result = consumeAComponentValue(ts); |
| 2176 | // 5. Discard whitespace from input. |
| 2177 | while (ts.next().type === TT_WHITESPACE) ts.discard(); |
| 2178 | // 6. If input is empty, return value. Otherwise, return a syntax error. |
| 2179 | if (ts.next().type === TT_EOF) return result; |
| 2180 | return undefined; |
| 2181 | }; |
| 2182 | |
| 2183 | /** |
| 2184 | * Parse a list of component values, CSS Syntax Level 3 |
no test coverage detected