* 5.4.7. Consume a simple block * https://www.w3.org/TR/css-syntax-3/#consume-a-simple-block
(associatedToken: InputToken)
| 626 | * https://www.w3.org/TR/css-syntax-3/#consume-a-simple-block |
| 627 | */ |
| 628 | private consumeASimpleBlock(associatedToken: InputToken): SimpleBlock { |
| 629 | const endianToken: ']' | '}' | ')' = { |
| 630 | '[': ']', |
| 631 | '{': '}', |
| 632 | '(': ')', |
| 633 | }[<any>associatedToken]; |
| 634 | const start = this.nextInputCodePointIndex - 1; |
| 635 | const block: SimpleBlock = { |
| 636 | type: TokenObjectType.simpleBlock, |
| 637 | text: undefined, |
| 638 | associatedToken, |
| 639 | values: [], |
| 640 | }; |
| 641 | let nextInputToken; |
| 642 | while ((nextInputToken = this.text[this.nextInputCodePointIndex])) { |
| 643 | if (nextInputToken === endianToken) { |
| 644 | this.nextInputCodePointIndex++; |
| 645 | const end = this.nextInputCodePointIndex; |
| 646 | block.text = this.text.substring(start, end); |
| 647 | |
| 648 | return block; |
| 649 | } |
| 650 | const value = this.consumeAComponentValue(); |
| 651 | if (value) { |
| 652 | block.values.push(value); |
| 653 | } |
| 654 | } |
| 655 | block.text = this.text.substring(start); |
| 656 | |
| 657 | return block; |
| 658 | } |
| 659 | |
| 660 | /** |
| 661 | * 5.4.8. Consume a function |
no test coverage detected