123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- import { ElementType } from "domelementtype";
- interface SourceCodeLocation {
-
- startLine: number;
-
- startCol: number;
-
- startOffset: number;
-
- endLine: number;
-
- endCol: number;
-
- endOffset: number;
- }
- interface TagSourceCodeLocation extends SourceCodeLocation {
- startTag?: SourceCodeLocation;
- endTag?: SourceCodeLocation;
- }
- export declare type ParentNode = Document | Element | CDATA;
- export declare type ChildNode = Text | Comment | ProcessingInstruction | Element | CDATA | Document;
- export declare type AnyNode = ParentNode | ChildNode;
- export declare abstract class Node {
-
- abstract readonly type: ElementType;
-
- parent: ParentNode | null;
-
- prev: ChildNode | null;
-
- next: ChildNode | null;
-
- startIndex: number | null;
-
- endIndex: number | null;
-
- sourceCodeLocation?: SourceCodeLocation | null;
-
- abstract readonly nodeType: number;
-
- get parentNode(): ParentNode | null;
- set parentNode(parent: ParentNode | null);
-
- get previousSibling(): ChildNode | null;
- set previousSibling(prev: ChildNode | null);
-
- get nextSibling(): ChildNode | null;
- set nextSibling(next: ChildNode | null);
-
- cloneNode<T extends Node>(this: T, recursive?: boolean): T;
- }
- export declare abstract class DataNode extends Node {
- data: string;
-
- constructor(data: string);
-
- get nodeValue(): string;
- set nodeValue(data: string);
- }
- export declare class Text extends DataNode {
- type: ElementType.Text;
- get nodeType(): 3;
- }
- export declare class Comment extends DataNode {
- type: ElementType.Comment;
- get nodeType(): 8;
- }
- export declare class ProcessingInstruction extends DataNode {
- name: string;
- type: ElementType.Directive;
- constructor(name: string, data: string);
- get nodeType(): 1;
-
- "x-name"?: string;
-
- "x-publicId"?: string;
-
- "x-systemId"?: string;
- }
- export declare abstract class NodeWithChildren extends Node {
- children: ChildNode[];
-
- constructor(children: ChildNode[]);
-
- get firstChild(): ChildNode | null;
-
- get lastChild(): ChildNode | null;
-
- get childNodes(): ChildNode[];
- set childNodes(children: ChildNode[]);
- }
- export declare class CDATA extends NodeWithChildren {
- type: ElementType.CDATA;
- get nodeType(): 4;
- }
- export declare class Document extends NodeWithChildren {
- type: ElementType.Root;
- get nodeType(): 9;
-
- "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;
- };
- type: ElementType.Tag | ElementType.Script | ElementType.Style;
-
- constructor(name: string, attribs: {
- [name: string]: string;
- }, children?: ChildNode[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
- get nodeType(): 1;
-
- sourceCodeLocation?: TagSourceCodeLocation | null;
-
- get tagName(): string;
- set tagName(name: string);
- get attributes(): Attribute[];
-
- namespace?: string;
-
- "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 CDATA;
- export declare function isText(node: Node): node is Text;
- export declare function isComment(node: Node): node is Comment;
- 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 ParentNode;
- export declare function cloneNode<T extends Node>(node: T, recursive?: boolean): T;
- export {};
|