Skip to content

Commit 4e4c95a

Browse files
committed
refactor: remove non-standard APIs and add DomParser class
1 parent d922305 commit 4e4c95a

File tree

9 files changed

+761
-141
lines changed

9 files changed

+761
-141
lines changed

crates/domparser_napi/index.d.ts

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/* auto-generated by NAPI-RS */
2+
/* eslint-disable */
3+
export declare class NodeRepr {
4+
/**
5+
* Append a child node to this node, after existing children.
6+
*
7+
* The child node will be remove from its previous position.
8+
*/
9+
append(newChild: NodeRepr): void
10+
appendChild(newChild: NodeRepr): NodeRepr
11+
removeChild(child: NodeRepr): NodeRepr
12+
/**
13+
* Prepend a child node to this node, before existing children.
14+
*
15+
* The child node will be remove from its previous position.
16+
*/
17+
prepend(newChild: NodeRepr): void
18+
/**
19+
* Insert a new sibling after this node.
20+
*
21+
* The sibling node will be remove from its previous position.
22+
*/
23+
after(newSibling: NodeRepr): void
24+
/**
25+
* Insert a new sibling before this node.
26+
*
27+
* The sibling node will be remove from its previous position.
28+
*/
29+
before(newSibling: NodeRepr): void
30+
insertBefore(newNode: NodeRepr, refNode?: NodeRepr | undefined | null): NodeRepr
31+
/** Remove a node from its parent and siblings. Children are not affected. */
32+
remove(): void
33+
/** Assign an attribute K-V to this node */
34+
setAttribute(name: string, value: string): void
35+
/** Remove an attribute of this node by name. */
36+
removeAttribute(name: string): void
37+
toggleAttribute(name: string, force?: boolean | undefined | null): boolean
38+
setAttributeNS(namespace: string | undefined | null, name: string, value: string): void
39+
removeAttributeNS(namespace: string | undefined | null, localName: string): void
40+
createElement(tagName: string): NodeRepr
41+
createTextNode(data: string): NodeRepr
42+
createComment(data: string): NodeRepr
43+
createDocumentFragment(): NodeRepr
44+
createProcessingInstruction(target: string, data: string): NodeRepr
45+
importNode(externalNode: NodeRepr, deep?: boolean | undefined | null): NodeRepr
46+
adoptNode(externalNode: NodeRepr): NodeRepr
47+
replaceChild(newChild: NodeRepr, oldChild: NodeRepr): NodeRepr
48+
replaceWith(newNode: NodeRepr): void
49+
insertAdjacentElement(position: string, element: NodeRepr): NodeRepr | null
50+
insertAdjacentText(position: string, data: string): void
51+
insertAdjacentHTML(position: string, html: string): void
52+
normalize(): void
53+
splitText(offset: number): NodeRepr
54+
substringData(offset: number, count: number): string
55+
appendData(data: string): void
56+
insertData(offset: number, data: string): void
57+
deleteData(offset: number, count: number): void
58+
replaceData(offset: number, count: number, data: string): void
59+
get nodeType(): number
60+
get nodeName(): string
61+
get tagName(): string | null
62+
get namespaceURI(): string | null
63+
get prefix(): string | null
64+
get localName(): string | null
65+
get id(): string
66+
set id(id: string)
67+
get className(): string
68+
set className(className: string)
69+
get parentNode(): NodeRepr | null
70+
get firstChild(): NodeRepr | null
71+
get lastChild(): NodeRepr | null
72+
get previousSibling(): NodeRepr | null
73+
get nextSibling(): NodeRepr | null
74+
get parentElement(): NodeRepr | null
75+
get firstElementChild(): NodeRepr | null
76+
get lastElementChild(): NodeRepr | null
77+
get previousElementSibling(): NodeRepr | null
78+
get nextElementSibling(): NodeRepr | null
79+
get children(): Array<NodeRepr>
80+
get childElementCount(): number
81+
getRootNode(): NodeRepr
82+
get nodeValue(): string | null
83+
set nodeValue(value?: string | undefined | null)
84+
get data(): string | null
85+
set data(value: string)
86+
get textContent(): string
87+
set textContent(text: string)
88+
isSameNode(otherNode: NodeRepr): boolean
89+
get innerHTML(): string
90+
set innerHTML(html: string)
91+
get outerHTML(): string
92+
set outerHTML(html: string)
93+
get ownerDocument(): NodeRepr | null
94+
get childNodes(): Array<NodeRepr>
95+
get isConnected(): boolean
96+
get doctype(): NodeRepr | null
97+
get publicId(): string
98+
get systemId(): string
99+
get name(): string
100+
get target(): string
101+
_classListAdd(className: string): void
102+
_classListRemove(className: string): void
103+
_classListToggle(className: string, force?: boolean | undefined | null): boolean
104+
_classListContains(className: string): boolean
105+
_datasetGet(): Record<string, string>
106+
_datasetSet(key: string, value: string): void
107+
_datasetRemove(key: string): void
108+
/** Get attribute value of this node by given name. */
109+
getAttribute(name: string): string | null
110+
getAttributeNames(): Array<string>
111+
hasAttributes(): boolean
112+
hasChildNodes(): boolean
113+
compareDocumentPosition(other: NodeRepr): number
114+
querySelector(selectors: string): NodeRepr | null
115+
querySelectorAll(selectors: string): Array<NodeRepr>
116+
hasAttribute(name: string): boolean
117+
getAttributeNS(namespace: string | undefined | null, localName: string): string | null
118+
hasAttributeNS(namespace: string | undefined | null, localName: string): boolean
119+
lookupPrefix(namespace?: string | undefined | null): string | null
120+
lookupNamespaceURI(prefix?: string | undefined | null): string | null
121+
isDefaultNamespace(namespace?: string | undefined | null): boolean
122+
getElementById(id: string): NodeRepr | null
123+
getElementsByClassName(classNames: string): Array<NodeRepr>
124+
getElementsByTagName(tagName: string): Array<NodeRepr>
125+
contains(otherNode: NodeRepr): boolean
126+
isEqualNode(otherNode: NodeRepr): boolean
127+
get head(): NodeRepr | null
128+
get body(): NodeRepr | null
129+
get title(): string
130+
get documentElement(): NodeRepr | null
131+
matches(selectors: string): boolean
132+
closest(selectors: string): NodeRepr | null
133+
/** The node object, cann't be instantiated in javascript. So call the constructor will throw an error. */
134+
constructor(): void
135+
cloneNode(deep?: boolean | undefined | null): NodeRepr
136+
}
137+
138+
/** Parse string input to a html tree, return the root node. */
139+
export declare function parse(html: string): NodeRepr

0 commit comments

Comments
 (0)