source: trip-planner-front/node_modules/domhandler/lib/node.d.ts@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.2 KB
Line 
1import { ElementType } from "domelementtype";
2/**
3 * This object will be used as the prototype for Nodes when creating a
4 * DOM-Level-1-compliant structure.
5 */
6export declare class Node {
7 type: ElementType;
8 /** Parent of the node */
9 parent: NodeWithChildren | null;
10 /** Previous sibling */
11 prev: Node | null;
12 /** Next sibling */
13 next: Node | null;
14 /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
15 startIndex: number | null;
16 /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
17 endIndex: number | null;
18 /**
19 *
20 * @param type The type of the node.
21 */
22 constructor(type: ElementType);
23 get nodeType(): number;
24 get parentNode(): NodeWithChildren | null;
25 set parentNode(parent: NodeWithChildren | null);
26 get previousSibling(): Node | null;
27 set previousSibling(prev: Node | null);
28 get nextSibling(): Node | null;
29 set nextSibling(next: Node | null);
30 /**
31 * Clone this node, and optionally its children.
32 *
33 * @param recursive Clone child nodes as well.
34 * @returns A clone of the node.
35 */
36 cloneNode<T extends Node>(this: T, recursive?: boolean): T;
37}
38/**
39 * A node that contains some data.
40 */
41export declare class DataNode extends Node {
42 data: string;
43 /**
44 * @param type The type of the node
45 * @param data The content of the data node
46 */
47 constructor(type: ElementType.Comment | ElementType.Text | ElementType.Directive, data: string);
48 get nodeValue(): string;
49 set nodeValue(data: string);
50}
51/**
52 * Text within the document.
53 */
54export declare class Text extends DataNode {
55 constructor(data: string);
56}
57/**
58 * Comments within the document.
59 */
60export declare class Comment extends DataNode {
61 constructor(data: string);
62}
63/**
64 * Processing instructions, including doc types.
65 */
66export declare class ProcessingInstruction extends DataNode {
67 name: string;
68 constructor(name: string, data: string);
69 "x-name"?: string;
70 "x-publicId"?: string;
71 "x-systemId"?: string;
72}
73/**
74 * A `Node` that can have children.
75 */
76export declare class NodeWithChildren extends Node {
77 children: Node[];
78 /**
79 * @param type Type of the node.
80 * @param children Children of the node. Only certain node types can have children.
81 */
82 constructor(type: ElementType.Root | ElementType.CDATA | ElementType.Script | ElementType.Style | ElementType.Tag, children: Node[]);
83 get firstChild(): Node | null;
84 get lastChild(): Node | null;
85 get childNodes(): Node[];
86 set childNodes(children: Node[]);
87}
88/**
89 * The root node of the document.
90 */
91export declare class Document extends NodeWithChildren {
92 constructor(children: Node[]);
93 "x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
94}
95/**
96 * The description of an individual attribute.
97 */
98interface Attribute {
99 name: string;
100 value: string;
101 namespace?: string;
102 prefix?: string;
103}
104/**
105 * An element within the DOM.
106 */
107export declare class Element extends NodeWithChildren {
108 name: string;
109 attribs: {
110 [name: string]: string;
111 };
112 /**
113 * @param name Name of the tag, eg. `div`, `span`.
114 * @param attribs Object mapping attribute names to attribute values.
115 * @param children Children of the node.
116 */
117 constructor(name: string, attribs: {
118 [name: string]: string;
119 }, children?: Node[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
120 get tagName(): string;
121 set tagName(name: string);
122 get attributes(): Attribute[];
123 "x-attribsNamespace"?: Record<string, string>;
124 "x-attribsPrefix"?: Record<string, string>;
125}
126/**
127 * @param node Node to check.
128 * @returns `true` if the node is a `Element`, `false` otherwise.
129 */
130export declare function isTag(node: Node): node is Element;
131/**
132 * @param node Node to check.
133 * @returns `true` if the node has the type `CDATA`, `false` otherwise.
134 */
135export declare function isCDATA(node: Node): node is NodeWithChildren;
136/**
137 * @param node Node to check.
138 * @returns `true` if the node has the type `Text`, `false` otherwise.
139 */
140export declare function isText(node: Node): node is Text;
141/**
142 * @param node Node to check.
143 * @returns `true` if the node has the type `Comment`, `false` otherwise.
144 */
145export declare function isComment(node: Node): node is DataNode;
146/**
147 * @param node Node to check.
148 * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
149 */
150export declare function isDirective(node: Node): node is ProcessingInstruction;
151/**
152 * @param node Node to check.
153 * @returns `true` if the node has the type `ProcessingInstruction`, `false` otherwise.
154 */
155export declare function isDocument(node: Node): node is Document;
156/**
157 * @param node Node to check.
158 * @returns `true` if the node is a `NodeWithChildren` (has children), `false` otherwise.
159 */
160export declare function hasChildren(node: Node): node is NodeWithChildren;
161/**
162 * Clone a node, and optionally its children.
163 *
164 * @param recursive Clone child nodes as well.
165 * @returns A clone of the node.
166 */
167export declare function cloneNode<T extends Node>(node: T, recursive?: boolean): T;
168export {};
169//# sourceMappingURL=node.d.ts.map
Note: See TracBrowser for help on using the repository browser.