123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- import { ElementType } from "domelementtype";
- export declare class Node {
- type: ElementType;
-
- parent: NodeWithChildren | null;
-
- prev: Node | null;
-
- next: Node | null;
-
- startIndex: number | null;
-
- endIndex: number | null;
-
- constructor(type: ElementType);
- get nodeType(): number;
- get parentNode(): NodeWithChildren | null;
- set parentNode(parent: NodeWithChildren | null);
- get previousSibling(): Node | null;
- set previousSibling(prev: Node | null);
- get nextSibling(): Node | null;
- set nextSibling(next: Node | null);
- /**
- * Clone this node, and optionally its children.
- *
- * @param recursive Clone child nodes as well.
- * @returns A clone of the node.
- */
- cloneNode<T extends Node>(this: T, recursive?: boolean): T;
- }
- export declare class DataNode extends Node {
- data: string;
-
- constructor(type: ElementType.Comment | ElementType.Text | ElementType.Directive, data: string);
- get nodeValue(): string;
- set nodeValue(data: string);
- }
- export declare class Text extends DataNode {
- constructor(data: string);
- }
- export declare class Comment extends DataNode {
- constructor(data: string);
- }
- export declare class ProcessingInstruction extends DataNode {
- name: string;
- constructor(name: string, data: string);
- "x-name"?: string;
- "x-publicId"?: string;
- "x-systemId"?: string;
- }
- /**
- * A `Node` that can have children.
- */
- export declare class NodeWithChildren extends Node {
- children: Node[];
-
- constructor(type: ElementType.Root | ElementType.CDATA | ElementType.Script | ElementType.Style | ElementType.Tag, children: Node[]);
- get firstChild(): Node | null;
- get lastChild(): Node | null;
- get childNodes(): Node[];
- set childNodes(children: Node[]);
- }
- export declare class Document extends NodeWithChildren {
- constructor(children: Node[]);
- "x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
- }
- interface Attribute {
- name: string;
- value: string;
- namespace?: string;
- prefix?: string;
- }
- export declare class Element extends NodeWithChildren {
- name: string;
- attribs: {
- [name: string]: string;
- };
-
- constructor(name: string, attribs: {
- [name: string]: string;
- }, children?: Node[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
- get tagName(): string;
- set tagName(name: string);
- get attributes(): Attribute[];
- "x-attribsNamespace"?: Record<string, string>;
- "x-attribsPrefix"?: Record<string, string>;
- }
- export declare function isTag(node: Node): node is Element;
- export declare function isCDATA(node: Node): node is NodeWithChildren;
- export declare function isText(node: Node): node is DataNode;
- export declare function isComment(node: Node): node is DataNode;
- export declare function isDirective(node: Node): node is ProcessingInstruction;
- export declare function isDocument(node: Node): node is Document;
- export declare function hasChildren(node: Node): node is NodeWithChildren;
- export declare function cloneNode<T extends Node>(node: T, recursive?: boolean): T;
- export {};
|