UNPKG

3.14 kBTypeScriptView Raw
1import { DOCUMENT_MODE, type NS } from '../common/html.js';
2import type { Attribute, Location, ElementLocation } from '../common/token.js';
3import type { TreeAdapter, TreeAdapterTypeMap } from './interface.js';
4export interface Document {
5 /** The name of the node. */
6 nodeName: '#document';
7 /**
8 * Document mode.
9 *
10 * @see {@link DOCUMENT_MODE} */
11 mode: DOCUMENT_MODE;
12 /** The node's children. */
13 childNodes: ChildNode[];
14 /** Comment source code location info. Available if location info is enabled. */
15 sourceCodeLocation?: Location | null;
16}
17export interface DocumentFragment {
18 /** The name of the node. */
19 nodeName: '#document-fragment';
20 /** The node's children. */
21 childNodes: ChildNode[];
22 /** Comment source code location info. Available if location info is enabled. */
23 sourceCodeLocation?: Location | null;
24}
25export interface Element {
26 /** Element tag name. Same as {@link tagName}. */
27 nodeName: string;
28 /** Element tag name. Same as {@link nodeName}. */
29 tagName: string;
30 /** List of element attributes. */
31 attrs: Attribute[];
32 /** Element namespace. */
33 namespaceURI: NS;
34 /** Element source code location info, with attributes. Available if location info is enabled. */
35 sourceCodeLocation?: ElementLocation | null;
36 /** Parent node. */
37 parentNode: ParentNode | null;
38 /** The node's children. */
39 childNodes: ChildNode[];
40}
41export interface CommentNode {
42 /** The name of the node. */
43 nodeName: '#comment';
44 /** Parent node. */
45 parentNode: ParentNode | null;
46 /** Comment text. */
47 data: string;
48 /** Comment source code location info. Available if location info is enabled. */
49 sourceCodeLocation?: Location | null;
50}
51export interface TextNode {
52 nodeName: '#text';
53 /** Parent node. */
54 parentNode: ParentNode | null;
55 /** Text content. */
56 value: string;
57 /** Comment source code location info. Available if location info is enabled. */
58 sourceCodeLocation?: Location | null;
59}
60export interface Template extends Element {
61 nodeName: 'template';
62 tagName: 'template';
63 /** The content of a `template` tag. */
64 content: DocumentFragment;
65}
66export interface DocumentType {
67 /** The name of the node. */
68 nodeName: '#documentType';
69 /** Parent node. */
70 parentNode: ParentNode | null;
71 /** Document type name. */
72 name: string;
73 /** Document type public identifier. */
74 publicId: string;
75 /** Document type system identifier. */
76 systemId: string;
77 /** Comment source code location info. Available if location info is enabled. */
78 sourceCodeLocation?: Location | null;
79}
80export type ParentNode = Document | DocumentFragment | Element | Template;
81export type ChildNode = Element | Template | CommentNode | TextNode | DocumentType;
82export type Node = ParentNode | ChildNode;
83export type DefaultTreeAdapterMap = TreeAdapterTypeMap<Node, ParentNode, ChildNode, Document, DocumentFragment, Element, CommentNode, TextNode, Template, DocumentType>;
84export declare const defaultTreeAdapter: TreeAdapter<DefaultTreeAdapterMap>;