forked from capricorn86/happy-dom
/
IDocument.ts
202 lines (181 loc) · 4.6 KB
/
IDocument.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import IElement from '../element/IElement';
import IHTMLElement from '../html-element/IHTMLElement';
import IWindow from '../../window/IWindow';
import TreeWalker from '../../tree-walker/TreeWalker';
import Event from '../../event/Event';
import DOMImplementation from '../../dom-implementation/DOMImplementation';
import INodeFilter from '../../tree-walker/INodeFilter';
import Attr from '../../attribute/Attr';
import IDocumentType from '../document-type/IDocumentType';
import IParentNode from '../parent-node/IParentNode';
import INode from '../node/INode';
import ICharacterData from '../character-data/ICharacterData';
import IDocumentFragment from '../document-fragment/IDocumentFragment';
import Selection from '../../selection/Selection';
import IHTMLCollection from '../element/IHTMLCollection';
import IHTMLScriptElement from '../html-script-element/IHTMLScriptElement';
import CSSStyleSheet from '../../css/CSSStyleSheet';
import Location from '../../location/Location';
import DocumentReadyStateEnum from './DocumentReadyStateEnum';
import INodeList from '../node/INodeList';
import Range from '../../range/Range';
/**
* Document.
*/
export default interface IDocument extends IParentNode {
onreadystatechange: (event: Event) => void;
readonly defaultView: IWindow;
readonly implementation: DOMImplementation;
readonly documentElement: IHTMLElement;
readonly doctype: IDocumentType;
readonly body: IHTMLElement;
readonly head: IHTMLElement;
readonly scripts: IHTMLCollection<IHTMLScriptElement>;
readonly activeElement: IHTMLElement;
readonly styleSheets: CSSStyleSheet[];
readonly scrollingElement: IHTMLElement;
readonly location: Location;
readonly readyState: DocumentReadyStateEnum;
readonly charset: string;
readonly characterSet: string;
readonly URL: string;
readonly documentURI: string;
cookie: string;
/**
* Replaces the document HTML with new HTML.
*
* @param html HTML.
*/
write(html: string): void;
/**
* Opens the document.
*
* @returns Document.
*/
open(): IDocument;
/**
* Closes the document.
*/
close(): void;
/**
* Creates an element.
*
* @param tagName Tag name.
* @param [options] Options.
* @returns Element.
*/
createElement(tagName: string, options?: { is: string }): IElement;
/**
* Creates an element with the specified namespace URI and qualified name.
*
* @param tagName Tag name.
* @param [options] Options.
* @returns Element.
*/
createElementNS(namespaceURI: string, qualifiedName: string, options?: { is: string }): IElement;
/**
* Creates a text node.
*
* @param data Text data.
* @returns Text node.
*/
createTextNode(data?: string): ICharacterData;
/**
* Creates a comment node.
*
* @param data Text data.
* @returns Text node.
*/
createComment(data?: string): ICharacterData;
/**
* Creates a document fragment.
*
* @returns Document fragment.
*/
createDocumentFragment(): IDocumentFragment;
/**
* Creates a Tree Walker.
*
* @param root Root.
* @param [whatToShow] What to show.
* @param [filter] Filter.
*/
createTreeWalker(root: INode, whatToShow: number, filter: INodeFilter): TreeWalker;
/**
* Creates an event.
*
* @deprecated
* @param _type Type.
* @returns Event.
*/
createEvent(_type: string): Event;
/**
* Creates an Attr node.
*
* @param name Name.
* @returns Attribute.
*/
createAttribute(name: string): Attr;
/**
* Creates a namespaced Attr node.
*
* @param namespaceURI Namespace URI.
* @param qualifiedName Qualified name.
* @returns Element.
*/
createAttributeNS(namespaceURI: string, qualifiedName: string): Attr;
/**
* Imports a node.
*
* @param node Node to import.
* @param Imported Node.
*/
importNode(node: INode): INode;
/**
* Creates a range.
*
* @returns Range.
*/
createRange(): Range;
/**
* Returns an element by ID.
*
* @param id ID.
* @returns Matching element.
*/
getElementById(id: string): IElement;
/**
* Returns an elements by name.
*
* @param name Name.
* @returns Matching element.
*/
getElementsByName(name: string): INodeList<IElement>;
/**
* Clones a node.
*
* @override
* @param [deep=false] "true" to clone deep.
* @returns Cloned node.
*/
cloneNode(deep: boolean): IDocument;
/**
* Adopts a node.
*
* @param node Node to adopt.
* @returns Adopted node.
*/
adoptNode(node: INode): INode;
/**
* Returns selection.
*
* @returns Selection.
*/
getSelection(): Selection;
/**
* Returns a boolean value indicating whether the document or any element inside the document has focus.
*
* @returns "true" if the document has focus.
*/
hasFocus(): boolean;
}