import { ElementSelector } from "./ElementSelector"; import type { WindowApiOption } from "./types/WindowApi"; import { WindowApi } from "./WindowApi"; declare class ElementWait extends ElementSelector { windowApi: typeof WindowApi.prototype; constructor(windowApiOption?: WindowApiOption); /** * 等待任意事件成立 * * 运行方式为根据页面元素的改变而触发回调 * @param checkFn 检测的函数 * @param timeout 超时时间,默认0 * @param parent (可选)父元素,默认document * @example * DOMUtils.wait(()=> { * let $test = document.querySelector("#test"); * return { * success: $test !== null, * data: $test * } * }) */ wait(checkFn: (...args: any[]) => { /** * 是否检测成功 */ success: boolean; /** * 返回的值 */ data: T; }, timeout?: null | undefined, parent?: Node | Element | Document | HTMLElement): Promise; wait(checkFn: (...args: any[]) => { /** * 是否检测成功 */ success: boolean; /** * 返回的值 */ data: T; }, timeout?: number, parent?: Node | Element | Document | HTMLElement): Promise; /** * 等待元素出现 * @param selectorFn 获取元素的函数 * @example * DOMUtils.waitNode(()=>document.querySelector("div")).then( $div =>{ * console.log($div); // $div => HTMLDivELement * }) */ waitNode(selectorFn: () => K | null | undefined): Promise; /** * 等待元素出现 * @param selectorFn 获取元素的函数 * @param timeout 超时时间,默认0 * @example * DOMUtils.waitNode(()=>document.querySelector("div"), 1000).then( $div =>{ * console.log($div); // $div => HTMLDivELement | null * }) */ waitNode(selectorFn: () => K | null | undefined, timeout: number): Promise; /** * 等待元素出现 * @param selectorFn 获取元素的函数 * @param parent 父元素 * @param timeout 超时时间,默认0 * @example * DOMUtils.waitNode(()=>document.querySelector("div"), document).then( $div =>{ * console.log($div); // $div => HTMLDivELement * }) * DOMUtils.waitNode(()=>document.querySelector("div"), document, 1000).then( $div =>{ * console.log($div); // $div => HTMLDivELement | null * }) */ waitNode(selectorFn: () => K | null | undefined, parent: Node | Element | Document | HTMLElement, timeout?: number): Promise; /** * 等待元素出现 * @param selector CSS选择器 * @param parent (可选)父元素,默认document * @example * DOMUtils.waitNode("div").then( $div =>{ * console.log($div); // div => HTMLDivELement * }) * DOMUtils.waitNode("div", document).then( $div =>{ * console.log($div); // div => HTMLDivELement * }) */ waitNode(selector: K, parent?: Node | Element | Document | HTMLElement): Promise; waitNode(selector: string, parent?: Node | Element | Document | HTMLElement): Promise; /** * 等待元素出现 * @param selectorList CSS选择器数组 * @param parent (可选)父元素,默认document * @example * DOMUtils.waitNode(["div"]).then( ([$div]) =>{ * console.log($div); // div => HTMLDivELement[] * }) * DOMUtils.waitNode(["div"], document).then( ([$div]) =>{ * console.log($div); // div => HTMLDivELement[] * }) */ waitNode(selectorList: K[], parent?: Node | Element | Document | HTMLElement): Promise; waitNode(selectorList: string[], parent?: Node | Element | Document | HTMLElement): Promise; /** * 等待元素出现 * @param selector CSS选择器 * @param parent 父元素,默认document * @param timeout 超时时间,默认0 * @example * DOMUtils.waitNode("div", document, 1000).then( $div =>{ * console.log($div); // $div => HTMLDivELement | null * }) */ waitNode(selector: K, parent: Node | Element | Document | HTMLElement, timeout: number): Promise; waitNode(selector: string, parent: Node | Element | Document | HTMLElement, timeout: number): Promise; /** * 等待元素出现 * @param selectorList CSS选择器数组 * @param parent 父元素,默认document * @param timeout 超时时间,默认0 * @example * DOMUtils.waitNode(["div"], document, 1000).then( ([$div]) =>{ * console.log($div); // $div => HTMLDivELement[] | null * }) */ waitNode(selectorList: K[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise; waitNode(selectorList: string[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise; /** * 等待元素出现 * @param selector CSS选择器 * @param timeout 超时时间,默认0 * @example * DOMUtils.waitNode("div", 1000).then( $div =>{ * console.log($div); // $div => HTMLDivELement | null * }) */ waitNode(selector: K, timeout: number): Promise; waitNode(selector: string, timeout: number): Promise; /** * 等待元素出现 * @param selectorList CSS选择器数组 * @param timeout 超时时间,默认0 * @example * DOMUtils.waitNode(["div"], 1000).then( [$div] =>{ * console.log($div); // $div => HTMLDivELement[] | null * }) */ waitNode(selectorList: K[], timeout: number): Promise; waitNode(selectorList: string[], timeout: number): Promise; /** * 等待任意元素出现 * @param selectorList CSS选择器数组 * @param parent (可选)监听的父元素 * @example * DOMUtils.waitAnyNode(["div","div"]).then( $div =>{ * console.log($div); // $div => HTMLDivELement 这里是第一个 * }) * DOMUtils.waitAnyNode(["a","div"], document).then( $a =>{ * console.log($a); // $a => HTMLAnchorElement 这里是第一个 * }) */ waitAnyNode(selectorList: K[], parent?: Node | Element | Document | HTMLElement): Promise; waitAnyNode(selectorList: string[], parent?: Node | Element | Document | HTMLElement): Promise; /** * 等待任意元素出现 * @param selectorList CSS选择器数组 * @param parent 父元素,默认document * @param timeout 超时时间,默认0 * @example * DOMUtils.waitAnyNode(["div","div"], document, 10000).then( $div =>{ * console.log($div); // $div => HTMLDivELement | null * }) */ waitAnyNode(selectorList: K[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise; waitAnyNode(selectorList: string[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise; /** * 等待任意元素出现 * @param selectorList CSS选择器数组 * @param timeout 超时时间,默认0 * @example * DOMUtils.waitAnyNode(["div","div"], 10000).then( $div =>{ * console.log($div); // $div => HTMLDivELement | null * }) */ waitAnyNode(selectorList: K[], timeout: number): Promise; waitAnyNode(selectorList: string[], timeout: number): Promise; /** * 等待元素数组出现 * @param selector CSS选择器 * @param parent (可选)监听的父元素 * @example * DOMUtils.waitNodeList("div").then( $result =>{ * console.log($result); // $result => NodeListOf * }) * DOMUtils.waitNodeList("div", document).then( $result =>{ * console.log($result); // $result => NodeListOf * }) */ waitNodeList(selector: T, parent?: Node | Element | Document | HTMLElement): Promise>; waitNodeList = NodeListOf>(selector: string, parent?: Node | Element | Document | HTMLElement): Promise; /** * 等待元素数组出现 * @param selectorList CSS选择器数组 * @param parent (可选)监听的父元素 * @example * DOMUtils.waitNodeList(["div"]).then( $result =>{ * console.log($result); // $result => NodeListOf[] * }) * DOMUtils.waitNodeList(["div"], document).then( $result =>{ * console.log($result); // $result => NodeListOf[] * }) */ waitNodeList(selectorList: K[], parent?: Node | Element | Document | HTMLElement): Promise[]>; waitNodeList[] = NodeListOf[]>(selectorList: string[], parent?: Node | Element | Document | HTMLElement): Promise; /** * 等待元素数组出现 * @param selector CSS选择器 * @param parent 监听的父元素 * @param timeout 超时时间,默认0 * @example * DOMUtils.waitNodeList("div", document, 10000).then( $result =>{ * console.log($result); // $result => NodeListOf | null * }) */ waitNodeList = NodeListOf>(selector: string, parent: Node | Element | Document | HTMLElement, timeout: number): Promise; waitNodeList(selector: K, parent: Node | Element | Document | HTMLElement, timeout: number): Promise | null>; /** * 等待元素数组出现 * @param selectorList CSS选择器数组 * @param parent 监听的父元素 * @param timeout 超时时间,默认0 * @example * DOMUtils.waitNodeList(["div"], document, 10000).then( $result =>{ * console.log($result); // $result => NodeListOf[] | null * }) */ waitNodeList(selectorList: K[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise[] | null>; waitNodeList[] = NodeListOf[]>(selectorList: string[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise; /** * 等待元素数组出现 * @param selector CSS选择器数组 * @param timeout 超时时间,默认0 * @example * DOMUtils.waitNodeList("div", 10000).then( $result =>{ * console.log($result); // $result => NodeListOf | null * }) */ waitNodeList(selector: K[], timeout: number): Promise | null>; waitNodeList = NodeListOf>(selector: string[], timeout: number): Promise; /** * 等待元素数组出现 * @param selectorList CSS选择器数组 * @param timeout 超时时间,默认0 * @example * DOMUtils.waitNodeList(["div"], 10000).then( $result =>{ * console.log($result); // $result => NodeListOf[] | null * }) */ waitNodeList(selectorList: K[], timeout: number): Promise[] | null>; waitNodeList = NodeListOf>(selectorList: string[], timeout: number): Promise; /** * 等待任意元素数组出现 * @param selectorList CSS选择器数组 * @param parent (可选)监听的父元素 * @example * DOMUtils.waitAnyNodeList(["div","a"]).then( $result =>{ * console.log($result); // $result => NodeListOf * }) * DOMUtils.waitAnyNodeList(["div","a"], document).then( $result =>{ * console.log($result); // $result => NodeListOf * }) */ waitAnyNodeList(selectorList: K[], parent?: Node | Element | Document | HTMLElement): Promise>; waitAnyNodeList(selectorList: string[], parent?: Node | Element | Document | HTMLElement): Promise>; /** * 等待任意元素数组出现 * @param selectorList CSS选择器数组 * @param parent 父元素,默认document * @param timeout 超时时间,默认0 * @example * DOMUtils.waitAnyNodeList(["div","a"], document, 10000).then( $result =>{ * console.log($result); // $result => NodeListOf | null * }) */ waitAnyNodeList(selectorList: K[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise | null>; waitAnyNodeList(selectorList: string[], parent: Node | Element | Document | HTMLElement, timeout: number): Promise | null>; /** * 等待任意元素出现 * @param selectorList CSS选择器数组 * @param timeout 超时时间,默认0 * @example * DOMUtils.waitAnyNodeList(["div","div"], 10000).then( $result =>{ * console.log($result); // $result => NodeListOf | null * }) */ waitAnyNodeList(selectorList: K[], timeout: number): Promise | null>; waitAnyNodeList(selectorList: string[], timeout: number): Promise | null>; } declare const elementWait: ElementWait; export { elementWait, ElementWait };