MCPcopy Create free account
hub / github.com/angular/angular / namespaceCssVariable

Function namespaceCssVariable

packages/compiler/src/util.ts:164–181  ·  view source on GitHub ↗
(varName: string)

Source from the content-addressed store, hash-verified

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

Callers 3

namespaceCssVariablesFunction · 0.90
parseHostStylePropertiesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected