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

Function namespaceCssVariables

packages/compiler/src/shadow_css.ts:1071–1087  ·  view source on GitHub ↗
(cssText: string)

Source from the content-addressed store, hash-verified

1069 * E.g. `--global--mycolor: red;` becomes `--mycolor: red;`
1070 */
1071export function namespaceCssVariables(cssText: string): string {
1072 return cssText.replace(_cssVariableRe, (match, prefix, varName, trailingColon) => {
1073 // Check for a leading `var(`, `@property`, or trailing `:` to approximate whether we're
1074 // operating on a real CSS variable, not another piece of syntax that resembles it.
1075 // For example, this guards against:
1076 // - `.foo--bar {}`
1077 // - `/* --foo */`
1078 // - `p { content: "--foo" }`
1079 // - `[data---bar] {}`
1080 // - `[data-status=foo--bar] {}`
1081 // etc.
1082 if (!prefix && !trailingColon) {
1083 return match;
1084 }
1085 return (prefix ?? '') + namespaceCssVariable(varName) + (trailingColon ?? '');
1086 });
1087}
1088
1089export class CssRule {
1090 constructor(

Callers 2

shadow_css_spec.tsFile · 0.90

Calls 2

namespaceCssVariableFunction · 0.90
replaceMethod · 0.45

Tested by

no test coverage detected