MCPcopy Create free account
hub / github.com/ecomfe/tempad-dev / canonicalizeVarName

Function canonicalizeVarName

packages/extension/utils/css.ts:935–954  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

933}
934
935export function canonicalizeVarName(value: string): string | null {
936 if (!value) return null
937 const cleaned = stripFallback(preprocessCssValue(value)).trim()
938
939 if (cleaned.startsWith('var(') && cleaned.endsWith(')')) {
940 // stripFallback() guarantees we have no comma at top-level.
941 let inner = cleaned.slice(4, -1).trim()
942 if (inner.startsWith('--')) {
943 inner = inner.slice(2).trim()
944 return normalizeCustomPropertyName(inner)
945 }
946 return null
947 }
948
949 if (cleaned.startsWith('--')) {
950 return normalizeCustomPropertyName(cleaned)
951 }
952
953 return null
954}
955
956export function toVarExpr(name: string): string {
957 return `var(${normalizeCustomPropertyName(name)})`

Callers 5

css.test.tsFile · 0.90
transformFunction · 0.90
normalizeTransformedNameFunction · 0.90
buildSourceNameIndexFunction · 0.90

Calls 3

stripFallbackFunction · 0.85
preprocessCssValueFunction · 0.85

Tested by

no test coverage detected