(cssText: string)
| 1069 | * E.g. `--global--mycolor: red;` becomes `--mycolor: red;` |
| 1070 | */ |
| 1071 | export function namespaceCssVariables(cssText: string): string { |
| 1072 | return cssText.replace(_cssVariableRe, (match, prefix, varName, trailingColon) => { |
| 1073 | // Check for a leading `var(`, `@property`, or trailing `:` to approximate whether we're |
| 1074 | // operating on a real CSS variable, not another piece of syntax that resembles it. |
| 1075 | // For example, this guards against: |
| 1076 | // - `.foo--bar {}` |
| 1077 | // - `/* --foo */` |
| 1078 | // - `p { content: "--foo" }` |
| 1079 | // - `[data---bar] {}` |
| 1080 | // - `[data-status=foo--bar] {}` |
| 1081 | // etc. |
| 1082 | if (!prefix && !trailingColon) { |
| 1083 | return match; |
| 1084 | } |
| 1085 | return (prefix ?? '') + namespaceCssVariable(varName) + (trailingColon ?? ''); |
| 1086 | }); |
| 1087 | } |
| 1088 | |
| 1089 | export class CssRule { |
| 1090 | constructor( |
no test coverage detected