|
import { ChildNode, Element, DataNode, Document, ParentNode } from "./node.js"; |
|
export * from "./node.js"; |
|
export interface DomHandlerOptions { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
withStartIndices?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
withEndIndices?: boolean; |
|
|
|
|
|
|
|
|
|
|
|
xmlMode?: boolean; |
|
} |
|
interface ParserInterface { |
|
startIndex: number | null; |
|
endIndex: number | null; |
|
} |
|
declare type Callback = (error: Error | null, dom: ChildNode[]) => void; |
|
declare type ElementCallback = (element: Element) => void; |
|
export declare class DomHandler { |
|
|
|
dom: ChildNode[]; |
|
|
|
root: Document; |
|
|
|
private readonly callback; |
|
|
|
private readonly options; |
|
|
|
private readonly elementCB; |
|
|
|
private done; |
|
|
|
protected tagStack: ParentNode[]; |
|
|
|
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: ChildNode): void; |
|
} |
|
export default DomHandler; |
|
|