Skip to content

pantoken / packages/utils/src / danglingReferences

Funkcja: danglingReferences()

danglingReferences(css): string[]

Beta

Kontrola samowystarczalności: --instui-* nazwy odwoływane przez var() w arkuszu stylów, które nigdy nie definiuje (jako rejestracja @property lub deklaracja --x:). Posortowane; pusta wartość oznacza, że każde odwołanie rozwiązuje się w tym samym wyjściu. Używane dla samodzielnych arkuszy stylów (css, pendo).

Parametry

css

string

Wygenerowany arkusz stylów.

Zwraca

string[]

Nazwy niepowiązanych odwołań.

Przykład

ts
import { danglingReferences } from "@pantoken/utils";

// Self-contained: the referenced property is also defined here.
danglingReferences("@property --instui-a {} .b { color: var(--instui-a); }"); // → []

// Dangling: `--instui-b` is referenced but never defined.
danglingReferences(
  ":root { --instui-a: red; } .b { color: var(--instui-a); background: var(--instui-b); }",
); // → ["--instui-b"]