123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- import type { DOCUMENT_MODE, NS } from '../common/html.js';
- import type { Attribute, ElementLocation } from '../common/token.js';
- export interface TreeAdapterTypeMap<Node = unknown, ParentNode = unknown, ChildNode = unknown, Document = unknown, DocumentFragment = unknown, Element = unknown, CommentNode = unknown, TextNode = unknown, Template = unknown, DocumentType = unknown> {
- node: Node;
- parentNode: ParentNode;
- childNode: ChildNode;
- document: Document;
- documentFragment: DocumentFragment;
- element: Element;
- commentNode: CommentNode;
- textNode: TextNode;
- template: Template;
- documentType: DocumentType;
- }
- export interface TreeAdapter<T extends TreeAdapterTypeMap = TreeAdapterTypeMap> {
-
- adoptAttributes(recipient: T['element'], attrs: Attribute[]): void;
-
- appendChild(parentNode: T['parentNode'], newNode: T['childNode']): void;
-
- createCommentNode(data: string): T['commentNode'];
-
- createTextNode(value: string): T['textNode'];
-
- createDocument(): T['document'];
-
- createDocumentFragment(): T['documentFragment'];
-
- createElement(tagName: string, namespaceURI: NS, attrs: Attribute[]): T['element'];
-
- detachNode(node: T['childNode']): void;
-
- getAttrList(element: T['element']): Attribute[];
-
- getChildNodes(node: T['parentNode']): T['childNode'][];
-
- getCommentNodeContent(commentNode: T['commentNode']): string;
-
- getDocumentMode(document: T['document']): DOCUMENT_MODE;
-
- getDocumentTypeNodeName(doctypeNode: T['documentType']): string;
-
- getDocumentTypeNodePublicId(doctypeNode: T['documentType']): string;
-
- getDocumentTypeNodeSystemId(doctypeNode: T['documentType']): string;
-
- getFirstChild(node: T['parentNode']): T['childNode'] | null;
-
- getNamespaceURI(element: T['element']): NS;
-
- getNodeSourceCodeLocation(node: T['node']): ElementLocation | undefined | null;
-
- getParentNode(node: T['node']): T['parentNode'] | null;
-
- getTagName(element: T['element']): string;
-
- getTextNodeContent(textNode: T['textNode']): string;
-
- getTemplateContent(templateElement: T['template']): T['documentFragment'];
-
- insertBefore(parentNode: T['parentNode'], newNode: T['childNode'], referenceNode: T['childNode']): void;
-
- insertText(parentNode: T['parentNode'], text: string): void;
-
- insertTextBefore(parentNode: T['parentNode'], text: string, referenceNode: T['childNode']): void;
-
- isCommentNode(node: T['node']): node is T['commentNode'];
-
- isDocumentTypeNode(node: T['node']): node is T['documentType'];
-
- isElementNode(node: T['node']): node is T['element'];
-
- isTextNode(node: T['node']): node is T['textNode'];
-
- setDocumentMode(document: T['document'], mode: DOCUMENT_MODE): void;
-
- setDocumentType(document: T['document'], name: string, publicId: string, systemId: string): void;
-
- setNodeSourceCodeLocation(node: T['node'], location: ElementLocation | null): void;
-
- updateNodeSourceCodeLocation(node: T['node'], location: Partial<ElementLocation>): void;
-
- setTemplateContent(templateElement: T['template'], contentElement: T['documentFragment']): void;
-
- onItemPush?: (item: T['element']) => void;
-
- onItemPop?: (item: T['element'], newTop: T['parentNode']) => void;
- }
|