( css: string )
| 678 | * to be resolved together as if they apply to the same element. |
| 679 | */ |
| 680 | export const extractCssCustomProperties = ( |
| 681 | css: string |
| 682 | ): Map<string, string> => { |
| 683 | const map = new Map<string, string>(); |
| 684 | const ast = cssTreeTryParse(css); |
| 685 | if (ast === undefined) { |
| 686 | return map; |
| 687 | } |
| 688 | csstree.walk(ast, { |
| 689 | visit: "Declaration", |
| 690 | enter(node) { |
| 691 | const decl = node as csstree.Declaration; |
| 692 | const prop = normalizeProperty(decl.property); |
| 693 | if (prop.startsWith("--")) { |
| 694 | const value = getRawDeclarationValue(css, decl); |
| 695 | if (value !== undefined && isValidCustomPropertyValue(value)) { |
| 696 | map.set(prop, normalizeCustomPropertyValue(value)); |
| 697 | } |
| 698 | } |
| 699 | }, |
| 700 | }); |
| 701 | return map; |
| 702 | }; |
| 703 | |
| 704 | export const parseCss = ( |
| 705 | css: string, |
no test coverage detected