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

Function namespaceCssVariable

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

Source from the content-addressed store, hash-verified

158 * @returns The namespaced CSS variable name.
159 */
160export 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}

Callers 3

namespaceCssVariablesFunction · 0.90
parseHostStylePropertiesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected