UNPKG

2.18 kBTypeScriptView Raw
1import { Node, Element } from "domhandler";
2import { ElementType } from "domelementtype";
3interface TestElementOpts {
4 tag_name?: string | ((name: string) => boolean);
5 tag_type?: string | ((name: string) => boolean);
6 tag_contains?: string | ((data?: string) => boolean);
7 [attributeName: string]: undefined | string | ((attributeValue: string) => boolean);
8}
9/**
10 * @param options An object describing nodes to look for.
11 * @param node The element to test.
12 * @returns Whether the element matches the description in `options`.
13 */
14export declare function testElement(options: TestElementOpts, node: Node): boolean;
15/**
16 * @param options An object describing nodes to look for.
17 * @param nodes Nodes to search through.
18 * @param recurse Also consider child nodes.
19 * @param limit Maximum number of nodes to return.
20 * @returns All nodes that match `options`.
21 */
22export declare function getElements(options: TestElementOpts, nodes: Node | Node[], recurse: boolean, limit?: number): Node[];
23/**
24 * @param id The unique ID attribute value to look for.
25 * @param nodes Nodes to search through.
26 * @param recurse Also consider child nodes.
27 * @returns The node with the supplied ID.
28 */
29export declare function getElementById(id: string | ((id: string) => boolean), nodes: Node | Node[], recurse?: boolean): Element | null;
30/**
31 * @param tagName Tag name to search for.
32 * @param nodes Nodes to search through.
33 * @param recurse Also consider child nodes.
34 * @param limit Maximum number of nodes to return.
35 * @returns All nodes with the supplied `tagName`.
36 */
37export declare function getElementsByTagName(tagName: string | ((name: string) => boolean), nodes: Node | Node[], recurse?: boolean, limit?: number): Element[];
38/**
39 * @param type Element type to look for.
40 * @param nodes Nodes to search through.
41 * @param recurse Also consider child nodes.
42 * @param limit Maximum number of nodes to return.
43 * @returns All nodes with the supplied `type`.
44 */
45export declare function getElementsByTagType(type: ElementType | ((type: ElementType) => boolean), nodes: Node | Node[], recurse?: boolean, limit?: number): Node[];
46export {};
47//# sourceMappingURL=legacy.d.ts.map
\No newline at end of file