From 76cb9c2a39d477a64824a985ade40507e3bbade1 Mon Sep 17 00:00:00 2001 From: Adam Mathes Date: Fri, 13 Feb 2026 21:34:48 -0800 Subject: feat(vanilla): add testing infrastructure and tests (NK-wjnczv) --- .../parse5/dist/tree-adapters/interface.d.ts | 255 +++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 vanilla/node_modules/parse5/dist/tree-adapters/interface.d.ts (limited to 'vanilla/node_modules/parse5/dist/tree-adapters/interface.d.ts') diff --git a/vanilla/node_modules/parse5/dist/tree-adapters/interface.d.ts b/vanilla/node_modules/parse5/dist/tree-adapters/interface.d.ts new file mode 100644 index 0000000..d14091f --- /dev/null +++ b/vanilla/node_modules/parse5/dist/tree-adapters/interface.d.ts @@ -0,0 +1,255 @@ +import type { DOCUMENT_MODE, NS } from '../common/html.js'; +import type { Attribute, ElementLocation } from '../common/token.js'; +export interface TreeAdapterTypeMap { + node: Node; + parentNode: ParentNode; + childNode: ChildNode; + document: Document; + documentFragment: DocumentFragment; + element: Element; + commentNode: CommentNode; + textNode: TextNode; + template: Template; + documentType: DocumentType; +} +/** + * Tree adapter is a set of utility functions that provides minimal required abstraction layer beetween parser and a specific AST format. + * Note that `TreeAdapter` is not designed to be a general purpose AST manipulation library. You can build such library + * on top of existing `TreeAdapter` or use one of the existing libraries from npm. + * + * @see Have a look at the default tree adapter for reference. + */ +export interface TreeAdapter { + /** + * Copies attributes to the given element. Only attributes that are not yet present in the element are copied. + * + * @param recipient - Element to copy attributes into. + * @param attrs - Attributes to copy. + */ + adoptAttributes(recipient: T['element'], attrs: Attribute[]): void; + /** + * Appends a child node to the given parent node. + * + * @param parentNode - Parent node. + * @param newNode - Child node. + */ + appendChild(parentNode: T['parentNode'], newNode: T['childNode']): void; + /** + * Creates a comment node. + * + * @param data - Comment text. + */ + createCommentNode(data: string): T['commentNode']; + /** + * Creates a text node. + * + * @param value - Text. + */ + createTextNode(value: string): T['textNode']; + /** + * Creates a document node. + */ + createDocument(): T['document']; + /** + * Creates a document fragment node. + */ + createDocumentFragment(): T['documentFragment']; + /** + * Creates an element node. + * + * @param tagName - Tag name of the element. + * @param namespaceURI - Namespace of the element. + * @param attrs - Attribute name-value pair array. Foreign attributes may contain `namespace` and `prefix` fields as well. + */ + createElement(tagName: string, namespaceURI: NS, attrs: Attribute[]): T['element']; + /** + * Removes a node from its parent. + * + * @param node - Node to remove. + */ + detachNode(node: T['childNode']): void; + /** + * Returns the given element's attributes in an array, in the form of name-value pairs. + * Foreign attributes may contain `namespace` and `prefix` fields as well. + * + * @param element - Element. + */ + getAttrList(element: T['element']): Attribute[]; + /** + * Returns the given node's children in an array. + * + * @param node - Node. + */ + getChildNodes(node: T['parentNode']): T['childNode'][]; + /** + * Returns the given comment node's content. + * + * @param commentNode - Comment node. + */ + getCommentNodeContent(commentNode: T['commentNode']): string; + /** + * Returns [document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks). + * + * @param document - Document node. + */ + getDocumentMode(document: T['document']): DOCUMENT_MODE; + /** + * Returns the given document type node's name. + * + * @param doctypeNode - Document type node. + */ + getDocumentTypeNodeName(doctypeNode: T['documentType']): string; + /** + * Returns the given document type node's public identifier. + * + * @param doctypeNode - Document type node. + */ + getDocumentTypeNodePublicId(doctypeNode: T['documentType']): string; + /** + * Returns the given document type node's system identifier. + * + * @param doctypeNode - Document type node. + */ + getDocumentTypeNodeSystemId(doctypeNode: T['documentType']): string; + /** + * Returns the first child of the given node. + * + * @param node - Node. + */ + getFirstChild(node: T['parentNode']): T['childNode'] | null; + /** + * Returns the given element's namespace. + * + * @param element - Element. + */ + getNamespaceURI(element: T['element']): NS; + /** + * Returns the given node's source code location information. + * + * @param node - Node. + */ + getNodeSourceCodeLocation(node: T['node']): ElementLocation | undefined | null; + /** + * Returns the given node's parent. + * + * @param node - Node. + */ + getParentNode(node: T['node']): T['parentNode'] | null; + /** + * Returns the given element's tag name. + * + * @param element - Element. + */ + getTagName(element: T['element']): string; + /** + * Returns the given text node's content. + * + * @param textNode - Text node. + */ + getTextNodeContent(textNode: T['textNode']): string; + /** + * Returns the `