* 4.3.2. Consume a numeric token * https://www.w3.org/TR/css-syntax-3/#consume-a-numeric-token
()
| 288 | * https://www.w3.org/TR/css-syntax-3/#consume-a-numeric-token |
| 289 | */ |
| 290 | private consumeANumericToken(): InputToken { |
| 291 | numberRegEx.lastIndex = this.nextInputCodePointIndex; |
| 292 | const result = numberRegEx.exec(this.text); |
| 293 | if (!result) { |
| 294 | return null; |
| 295 | } |
| 296 | this.nextInputCodePointIndex = numberRegEx.lastIndex; |
| 297 | if (this.text[this.nextInputCodePointIndex] === '%') { |
| 298 | return { type: TokenObjectType.percentage, text: result[0] }; // TODO: Push the actual number and unit here... |
| 299 | } |
| 300 | |
| 301 | const name = this.consumeAName(); |
| 302 | if (name) { |
| 303 | return { |
| 304 | type: TokenObjectType.dimension, |
| 305 | text: result[0] + name.text, |
| 306 | }; |
| 307 | } |
| 308 | |
| 309 | return { type: TokenObjectType.number, text: result[0] }; |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * 4.3.3. Consume an ident-like token |
no test coverage detected