MCPcopy Create free account
hub / github.com/webstudio-is/webstudio / unescapeCssIdentifier

Function unescapeCssIdentifier

packages/css-data/src/parse-css.ts:491–499  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

489// node.name = "border-\\[color\\:var\\(--border-color\\)\\]".
490// We unescape it so class names match authored HTML class attributes.
491const unescapeCssIdentifier = (value: string): string =>
492 value.replace(/\\([0-9a-fA-F]{1,6}\s?|.)/g, (_match, escaped: string) => {
493 const hexMatch = escaped.match(/^([0-9a-fA-F]{1,6})\s?$/);
494 if (hexMatch) {
495 const codePoint = Number.parseInt(hexMatch[1], 16);
496 return String.fromCodePoint(codePoint);
497 }
498 return escaped;
499 });
500
501/**
502 * Substitute var() references in a shorthand value then expand the result.

Callers 1

parseClassBasedSelectorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected