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