source: imaps-frontend/node_modules/domhandler/lib/node.d.ts

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 7.6 KB
RevLine 
[79a0317]1import { ElementType } from "domelementtype";
2interface SourceCodeLocation {
3 /** One-based line index of the first character. */
4 startLine: number;
5 /** One-based column index of the first character. */
6 startCol: number;
7 /** Zero-based first character index. */
8 startOffset: number;
9 /** One-based line index of the last character. */
10 endLine: number;
11 /** One-based column index of the last character. Points directly *after* the last character. */
12 endCol: number;
13 /** Zero-based last character index. Points directly *after* the last character. */
14 endOffset: number;
15}
16interface TagSourceCodeLocation extends SourceCodeLocation {
17 startTag?: SourceCodeLocation;
18 endTag?: SourceCodeLocation;
19}
20/**
21 * This object will be used as the prototype for Nodes when creating a
22 * DOM-Level-1-compliant structure.
23 */
24export declare class Node {
25 type: ElementType;
26 /** Parent of the node */
27 parent: NodeWithChildren | null;
28 /** Previous sibling */
29 prev: Node | null;
30 /** Next sibling */
31 next: Node | null;
32 /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
33 startIndex: number | null;
34 /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
35 endIndex: number | null;
36 /**
37 * `parse5` source code location info.
38 *
39 * Available if parsing with parse5 and location info is enabled.
40 */
41 sourceCodeLocation?: SourceCodeLocation | null;
42 /**
43 *
44 * @param type The type of the node.
45 */
46 constructor(type: ElementType);
47 /**
48 * [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
49 * node {@link type}.
50 */
51 get nodeType(): number;
52 /**
53 * Same as {@link parent}.
54 * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
55 */
56 get parentNode(): NodeWithChildren | null;
57 set parentNode(parent: NodeWithChildren | null);
58 /**
59 * Same as {@link prev}.
60 * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
61 */
62 get previousSibling(): Node | null;
63 set previousSibling(prev: Node | null);
64 /**
65 * Same as {@link next}.
66 * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
67 */
68 get nextSibling(): Node | null;
69 set nextSibling(next: Node | null);
70 /**
71 * Clone this node, and optionally its children.
72 *
73 * @param recursive Clone child nodes as well.
74 * @returns A clone of the node.
75 */
76 cloneNode<T extends Node>(this: T, recursive?: boolean): T;
77}
78/**
79 * A node that contains some data.
80 */
81export declare class DataNode extends Node {
82 data: string;
83 /**
84 * @param type The type of the node
85 * @param data The content of the data node
86 */
87 constructor(type: ElementType.Comment | ElementType.Text | ElementType.Directive, data: string);
88 /**
89 * Same as {@link data}.
90 * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
91 */
92 get nodeValue(): string;
93 set nodeValue(data: string);
94}
95/**
96 * Text within the document.
97 */
98export declare class Text extends DataNode {
99 constructor(data: string);
100}
101/**
102 * Comments within the document.
103 */
104export declare class Comment extends DataNode {
105 constructor(data: string);
106}
107/**
108 * Processing instructions, including doc types.
109 */
110export declare class ProcessingInstruction extends DataNode {
111 name: string;
112 constructor(name: string, data: string);
113 /** If this is a doctype, the document type name (parse5 only). */
114 "x-name"?: string;
115 /** If this is a doctype, the document type public identifier (parse5 only). */
116 "x-publicId"?: string;
117 /** If this is a doctype, the document type system identifier (parse5 only). */
118 "x-systemId"?: string;
119}
120/**
121 * A `Node` that can have children.
122 */
123export declare class NodeWithChildren extends Node {
124 children: Node[];
125 /**
126 * @param type Type of the node.
127 * @param children Children of the node. Only certain node types can have children.
128 */
129 constructor(type: ElementType.Root | ElementType.CDATA | ElementType.Script | ElementType.Style | ElementType.Tag, children: Node[]);
130 /** First child of the node. */
131 get firstChild(): Node | null;
132 /** Last child of the node. */
133 get lastChild(): Node | null;
134 /**
135 * Same as {@link children}.
136 * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
137 */
138 get childNodes(): Node[];
139 set childNodes(children: Node[]);
140}
141/**
142 * The root node of the document.
143 */
144export declare class Document extends NodeWithChildren {
145 constructor(children: Node[]);
146 /** [Document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks) (parse5 only). */
147 "x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
148}
149/**
150 * The description of an individual attribute.
151 */
152interface Attribute {
153 name: string;
154 value: string;
155 namespace?: string;
156 prefix?: string;
157}
158/**
159 * An element within the DOM.
160 */
161export declare class Element extends NodeWithChildren {
162 name: string;
163 attribs: {
164 [name: string]: string;
165 };
166 /**
167 * @param name Name of the tag, eg. `div`, `span`.
168 * @param attribs Object mapping attribute names to attribute values.
169 * @param children Children of the node.
170 */
171 constructor(name: string, attribs: {
172 [name: string]: string;
173 }, children?: Node[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
174 /**
175 * `parse5` source code location info, with start & end tags.
176 *
177 * Available if parsing with parse5 and location info is enabled.
178 */
179 sourceCodeLocation?: TagSourceCodeLocation | null;
180 /**
181 * Same as {@link name}.
182 * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
183 */
184 get tagName(): string;
185 set tagName(name: string);
186 get attributes(): Attribute[];
187 /** Element namespace (parse5 only). */
188 namespace?: string;
189 /** Element attribute namespaces (parse5 only). */
190 "x-attribsNamespace"?: Record<string, string>;
191 /** Element attribute namespace-related prefixes (parse5 only). */
192 "x-attribsPrefix"?: Record<string, string>;
193}
194/**
195 * @param node Node to check.
196 * @returns `true` if the node is a `Element`, `false` otherwise.
197 */
198export declare function isTag(node: Node): node is Element;
199/**
200 * @param node Node to check.
201 * @returns `true` if the node has the type `CDATA`, `false` otherwise.
202 */
203export declare function isCDATA(node: Node): node is NodeWithChildren;
204/**
205 * @param node Node to check.
206 * @returns `true` if the node has the type `Text`, `false` otherwise.
207 */
208export declare function isText(node: Node): node is Text;
209/**
210 * @param node Node to check.
211 * @returns `true` if the node has the type `Comment`, `false` otherwise.
212 */
213export declare function isComment(node: Node): node is DataNode;
214/**
215 * @param node Node to check.
216 * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
217 */
218export declare function isDirective(node: Node): node is ProcessingInstruction;
219/**
220 * @param node Node to check.
221 * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
222 */
223export declare function isDocument(node: Node): node is Document;
224/**
225 * @param node Node to check.
226 * @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
227 */
228export declare function hasChildren(node: Node): node is NodeWithChildren;
229/**
230 * Clone a node, and optionally its children.
231 *
232 * @param recursive Clone child nodes as well.
233 * @returns A clone of the node.
234 */
235export declare function cloneNode<T extends Node>(node: T, recursive?: boolean): T;
236export {};
237//# sourceMappingURL=node.d.ts.map
Note: See TracBrowser for help on using the repository browser.