import {tBoundary} from "./type.base"; const maps: Record HTMLElement)> = { 'window': () => window as any, 'body': () => document.body, 'documentElement': () => document.documentElement, }; /** * 获取边界元素 * @author 韦胜健 * @date 2022/4/4 17:19 */ export function getBoundary(boundary: tBoundary | undefined | null): HTMLElement | null { if (boundary == null) {return null;} if (typeof boundary === "string") { const result = maps[boundary]; if (!!result) {return result();} return document.body.querySelector(boundary); } return boundary; }