Skip to content

pantoken-root / formats/scope/src / resolveScope

函式: resolveScope() ​

resolveScope(start): ResolvedScope

Beta(測試)

透過向上遍歷其祖先來解析對 start 生效的範圍。

參數 ​

start ​

Element | null

要解析的元素。其自身的屬性也會參與解析。

回傳 ​

ResolvedScope

ResolvedScope;未被任何祖先宣告的欄位將保留為 undefined。

範例 ​

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

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