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

Function namespaceCssVariable

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

Source from the content-addressed store, hash-verified

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

Callers 3

namespaceCssVariablesFunction · 0.90
parseHostStylePropertiesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected