12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- import { Node, Element, DataNode, NodeWithChildren, Document } from "./node";
- export * from "./node";
- export interface DomHandlerOptions {
-
- withStartIndices?: boolean;
-
- withEndIndices?: boolean;
-
- normalizeWhitespace?: boolean;
-
- xmlMode?: boolean;
- }
- interface ParserInterface {
- startIndex: number | null;
- endIndex: number | null;
- }
- declare type Callback = (error: Error | null, dom: Node[]) => void;
- declare type ElementCallback = (element: Element) => void;
- export declare class DomHandler {
-
- dom: Node[];
-
- root: Document;
-
- private readonly callback;
-
- private readonly options;
-
- private readonly elementCB;
-
- private done;
-
- protected tagStack: NodeWithChildren[];
-
- protected lastNode: DataNode | null;
-
- private parser;
-
- constructor(callback?: Callback | null, options?: DomHandlerOptions | null, elementCB?: ElementCallback);
- onparserinit(parser: ParserInterface): void;
- onreset(): void;
- onend(): void;
- onerror(error: Error): void;
- onclosetag(): void;
- onopentag(name: string, attribs: {
- [key: string]: string;
- }): void;
- ontext(data: string): void;
- oncomment(data: string): void;
- oncommentend(): void;
- oncdatastart(): void;
- oncdataend(): void;
- onprocessinginstruction(name: string, data: string): void;
- protected handleCallback(error: Error | null): void;
- protected addNode(node: Node): void;
- }
- export default DomHandler;
|