1 | import { ElementType } from "domelementtype";
|
2 | interface SourceCodeLocation {
|
3 |
|
4 | startLine: number;
|
5 |
|
6 | startCol: number;
|
7 |
|
8 | startOffset: number;
|
9 |
|
10 | endLine: number;
|
11 |
|
12 | endCol: number;
|
13 |
|
14 | endOffset: number;
|
15 | }
|
16 | interface TagSourceCodeLocation extends SourceCodeLocation {
|
17 | startTag?: SourceCodeLocation;
|
18 | endTag?: SourceCodeLocation;
|
19 | }
|
20 | export declare type ParentNode = Document | Element | CDATA;
|
21 | export declare type ChildNode = Text | Comment | ProcessingInstruction | Element | CDATA | Document;
|
22 | export declare type AnyNode = ParentNode | ChildNode;
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | export declare abstract class Node {
|
28 |
|
29 | abstract readonly type: ElementType;
|
30 |
|
31 | parent: ParentNode | null;
|
32 |
|
33 | prev: ChildNode | null;
|
34 |
|
35 | next: ChildNode | null;
|
36 |
|
37 | startIndex: number | null;
|
38 |
|
39 | endIndex: number | null;
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 | sourceCodeLocation?: SourceCodeLocation | null;
|
46 | |
47 |
|
48 |
|
49 |
|
50 | abstract readonly nodeType: number;
|
51 | |
52 |
|
53 |
|
54 |
|
55 | get parentNode(): ParentNode | null;
|
56 | set parentNode(parent: ParentNode | null);
|
57 | |
58 |
|
59 |
|
60 |
|
61 | get previousSibling(): ChildNode | null;
|
62 | set previousSibling(prev: ChildNode | null);
|
63 | |
64 |
|
65 |
|
66 |
|
67 | get nextSibling(): ChildNode | null;
|
68 | set nextSibling(next: ChildNode | null);
|
69 | |
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | cloneNode<T extends Node>(this: T, recursive?: boolean): T;
|
76 | }
|
77 |
|
78 |
|
79 |
|
80 | export declare abstract class DataNode extends Node {
|
81 | data: string;
|
82 | |
83 |
|
84 |
|
85 | constructor(data: string);
|
86 | /**
|
87 | * Same as {@link data}.
|
88 | * [DOM spec](https:
|
89 | */
|
90 | get nodeValue(): string;
|
91 | set nodeValue(data: string);
|
92 | }
|
93 |
|
94 |
|
95 |
|
96 | export declare class Text extends DataNode {
|
97 | type: ElementType.Text;
|
98 | get nodeType(): 3;
|
99 | }
|
100 |
|
101 |
|
102 |
|
103 | export declare class Comment extends DataNode {
|
104 | type: ElementType.Comment;
|
105 | get nodeType(): 8;
|
106 | }
|
107 |
|
108 |
|
109 |
|
110 | export declare class ProcessingInstruction extends DataNode {
|
111 | name: string;
|
112 | type: ElementType.Directive;
|
113 | constructor(name: string, data: string);
|
114 | get nodeType(): 1;
|
115 | /** If this is a doctype, the document type name (parse5 only). */
|
116 | "x-name"?: string;
|
117 | /** If this is a doctype, the document type public identifier (parse5 only). */
|
118 | "x-publicId"?: string;
|
119 | /** If this is a doctype, the document type system identifier (parse5 only). */
|
120 | "x-systemId"?: string;
|
121 | }
|
122 | /**
|
123 | * A `Node` that can have children.
|
124 | */
|
125 | export declare abstract class NodeWithChildren extends Node {
|
126 | children: ChildNode[];
|
127 | |
128 |
|
129 |
|
130 | constructor(children: ChildNode[]);
|
131 | /** First child of the node. */
|
132 | get firstChild(): ChildNode | null;
|
133 | /** Last child of the node. */
|
134 | get lastChild(): ChildNode | null;
|
135 | /**
|
136 | * Same as {@link children}.
|
137 | * [DOM spec](https:
|
138 | */
|
139 | get childNodes(): ChildNode[];
|
140 | set childNodes(children: ChildNode[]);
|
141 | }
|
142 | export declare class CDATA extends NodeWithChildren {
|
143 | type: ElementType.CDATA;
|
144 | get nodeType(): 4;
|
145 | }
|
146 |
|
147 |
|
148 |
|
149 | export declare class Document extends NodeWithChildren {
|
150 | type: ElementType.Root;
|
151 | get nodeType(): 9;
|
152 |
|
153 | "x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
|
154 | }
|
155 |
|
156 |
|
157 |
|
158 | interface Attribute {
|
159 | name: string;
|
160 | value: string;
|
161 | namespace?: string;
|
162 | prefix?: string;
|
163 | }
|
164 |
|
165 |
|
166 |
|
167 | export declare class Element extends NodeWithChildren {
|
168 | name: string;
|
169 | attribs: {
|
170 | [name: string]: string;
|
171 | };
|
172 | type: ElementType.Tag | ElementType.Script | ElementType.Style;
|
173 | |
174 |
|
175 |
|
176 |
|
177 |
|
178 | constructor(name: string, attribs: {
|
179 | [name: string]: string;
|
180 | }, children?: ChildNode[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
|
181 | get nodeType(): 1;
|
182 | /**
|
183 | * `parse5` source code location info, with start & end tags.
|
184 | *
|
185 | * Available if parsing with parse5 and location info is enabled.
|
186 | */
|
187 | sourceCodeLocation?: TagSourceCodeLocation | null;
|
188 | /**
|
189 | * Same as {@link name}.
|
190 | * [DOM spec](https:
|
191 | */
|
192 | get tagName(): string;
|
193 | set tagName(name: string);
|
194 | get attributes(): Attribute[];
|
195 |
|
196 | namespace?: string;
|
197 |
|
198 | "x-attribsNamespace"?: Record<string, string>;
|
199 |
|
200 | "x-attribsPrefix"?: Record<string, string>;
|
201 | }
|
202 |
|
203 |
|
204 |
|
205 |
|
206 | export declare function isTag(node: Node): node is Element;
|
207 |
|
208 |
|
209 |
|
210 |
|
211 | export declare function isCDATA(node: Node): node is CDATA;
|
212 |
|
213 |
|
214 |
|
215 |
|
216 | export declare function isText(node: Node): node is Text;
|
217 |
|
218 |
|
219 |
|
220 |
|
221 | export declare function isComment(node: Node): node is Comment;
|
222 |
|
223 |
|
224 |
|
225 |
|
226 | export declare function isDirective(node: Node): node is ProcessingInstruction;
|
227 |
|
228 |
|
229 |
|
230 |
|
231 | export declare function isDocument(node: Node): node is Document;
|
232 |
|
233 |
|
234 |
|
235 |
|
236 | export declare function hasChildren(node: Node): node is ParentNode;
|
237 |
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 | export declare function cloneNode<T extends Node>(node: T, recursive?: boolean): T;
|
244 | export {};
|
245 |
|
\ | No newline at end of file |