Skip to content

pantoken / packages/utils/src / danglingReferences

函式: danglingReferences()

danglingReferences(css): string[]

Beta(測試)

自包含性檢查:--instui-* 名稱透過 var() 在樣式表中被參考,但該樣式表從未 將其定義(作為 @property 註冊或 --x: 宣告)。已排序;空值表示每個 參考都在相同輸出中解析。用於自包含的樣式表(css、pendo)。

參數

css

string

產生的樣式表。

回傳

string[]

懸而未決的參考名稱。

範例

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"]