(cssText: string)
| 1048 | * E.g. `--global--mycolor: red;` becomes `--mycolor: red;` |
| 1049 | */ |
| 1050 | export function namespaceCssVariables(cssText: string): string { |
| 1051 | return cssText.replace(_cssVariableRe, (match, leadingVar, varName, trailingColon) => { |
| 1052 | // Check for a leading `var(` or trailing `:` to approximate whether we're operating on a |
| 1053 | // real CSS variable, not another piece of syntax that resembles it. For example, this |
| 1054 | // guards against: |
| 1055 | // - `.foo--bar {}` |
| 1056 | // - `/* --foo */` |
| 1057 | // - `p { content: "--foo" }` |
| 1058 | // - `[data---bar] {}` |
| 1059 | // - `[data-status=foo--bar] {}` |
| 1060 | // etc. |
| 1061 | if (!leadingVar && !trailingColon) { |
| 1062 | return match; |
| 1063 | } |
| 1064 | return (leadingVar ?? '') + namespaceCssVariable(varName) + (trailingColon ?? ''); |
| 1065 | }); |
| 1066 | } |
| 1067 | |
| 1068 | export class CssRule { |
| 1069 | constructor( |
no test coverage detected