Skip to content

pantoken-root / formats/scope/src / resolveScope

函数: resolveScope() ​

resolveScope(start): ResolvedScope

Beta

通过向上遍历其祖先来解析对 start 生效的作用域。

参数 ​

start ​

Element | null

要为其解析的元素。其自身的属性也会参与解析。

返回值 ​

ResolvedScope

The ResolvedScope;未被任何祖先声明的字段保持为 undefined。

示例 ​

ts
import { resolveScope } from "@pantoken/scope";

// <div data-pantoken-theme="canvas"><span id="x"></span></div>
resolveScope(document.querySelector("#x")!).theme; // "canvas"