UNPKG

1.96 kBTypeScriptView Raw
1// Type definitions for dom4 v2.0
2// Project: https://github.com/WebReflection/dom4
3// Definitions by: Adi Dahiya <https://github.com/adidahiya>, Gilad Gray <https://github.com/giladgray>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6/**
7 * https://dom.spec.whatwg.org/#parentnode
8 */
9interface ParentNode {
10 /**
11 * Returns the child elements.
12 */
13 readonly children: HTMLCollection;
14
15 /**
16 * Inserts `nodes` after the last child of this node, while replacing strings with equivalent `Text` nodes.
17 */
18 append(...nodes: Array<Node | string>): void;
19
20 /**
21 * Inserts `nodes` before the first child of this node, while replacing strings with equivalent `Text` nodes.
22 */
23 prepend(...nodes: Array<Node | string>): void;
24}
25
26/**
27 * https://dom.spec.whatwg.org/#childnode
28 */
29interface ChildNode {
30 /**
31 * Inserts `nodes` just after this node, while replacing strings with equivalent `Text` nodes.
32 */
33 after(...nodes: Array<Node | string>): void;
34
35 /**
36 * Inserts `nodes` just before this node, while replacing strings with equivalent `Text` nodes.
37 */
38 before(...nodes: Array<Node | string>): void;
39
40 /**
41 * Replaces this node with `nodes`, while replacing strings in nodes with equivalent Text nodes.
42 */
43 replaceWith(...nodes: Array<Node | string>): void;
44
45 /**
46 * Removes this node.
47 */
48 remove(): void;
49}
50
51interface Element extends ParentNode {
52 /**
53 * Returns the first (starting at element) inclusive ancestor that matches selectors, and null otherwise.
54 */
55 closest(selectors: string): Element | null;
56
57 /**
58 * Returns true if matching selectors against element’s root yields element, and false otherwise.
59 */
60 matches(selectors: string): boolean;
61}
62
63interface Elements extends ParentNode, Array<Element> {
64}
65
66interface Document extends ParentNode {
67}
68
69interface DocumentFragment extends ParentNode {
70}