(varName: string)
| 158 | * @returns The namespaced CSS variable name. |
| 159 | */ |
| 160 | export function namespaceCssVariable(varName: string): string { |
| 161 | // TODO: Enforce this in v23. This is a breaking change. |
| 162 | // Enable tests under platform-browser and compiler matching "has a single hyphen". |
| 163 | // g3-only-start |
| 164 | // if (varName.startsWith('--global-') && !varName.startsWith('--global--')) { |
| 165 | // throw new Error( |
| 166 | // `CSS variable "${varName}" has a single hyphen after "--global". ` + |
| 167 | // `Use two hyphens ("--global--${varName.substring('--global-'.length)}") to opt-out of namespacing.`, |
| 168 | // ); |
| 169 | // } |
| 170 | // g3-only-end |
| 171 | |
| 172 | if (varName.startsWith('--global--')) { |
| 173 | return '--' + varName.substring('--global--'.length); |
| 174 | } else { |
| 175 | return '--%NS%' + varName.substring('--'.length); |
| 176 | } |
| 177 | } |
no outgoing calls
no test coverage detected