@xmldom/xmldom 0.9.0-beta.9 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -0
- package/index.d.ts +1242 -121
- package/lib/.eslintrc.yml +1 -1
- package/lib/conventions.js +108 -77
- package/lib/dom-parser.js +98 -87
- package/lib/dom.js +1055 -397
- package/lib/entities.js +14 -9
- package/lib/errors.js +202 -0
- package/lib/grammar.js +21 -3
- package/lib/index.js +23 -3
- package/lib/sax.js +157 -115
- package/package.json +73 -70
- package/readme.md +11 -3
package/index.d.ts
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
|
-
/// <reference lib="dom" />
|
|
2
|
-
|
|
3
1
|
declare module '@xmldom/xmldom' {
|
|
4
2
|
// START ./lib/conventions.js
|
|
5
3
|
/**
|
|
6
4
|
* Since xmldom can not rely on `Object.assign`,
|
|
7
5
|
* it uses/provides a simplified version that is sufficient for its needs.
|
|
8
6
|
*
|
|
9
|
-
* @throws TypeError
|
|
10
|
-
*
|
|
7
|
+
* @throws {TypeError}
|
|
8
|
+
* If target is not an object.
|
|
11
9
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
12
10
|
* @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign
|
|
13
11
|
*/
|
|
14
|
-
function assign<T, S>(target:T, source:S): T & S;
|
|
12
|
+
function assign<T, S>(target: T, source: S): T & S;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* For both the `text/html` and the `application/xhtml+xml` namespace the spec defines that
|
|
16
|
+
* the HTML namespace is provided as the default.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} mimeType
|
|
19
|
+
* @returns {boolean}
|
|
20
|
+
* @see https://dom.spec.whatwg.org/#dom-document-createelement
|
|
21
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument
|
|
22
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
|
23
|
+
*/
|
|
24
|
+
function hasDefaultHTMLNamespace(
|
|
25
|
+
mimeType: string
|
|
26
|
+
): mimeType is typeof MIME_TYPE.HTML | typeof MIME_TYPE.XML_XHTML_APPLICATION;
|
|
27
|
+
|
|
15
28
|
/**
|
|
16
29
|
* Only returns true if `value` matches MIME_TYPE.HTML, which indicates an HTML document.
|
|
17
30
|
*
|
|
@@ -20,7 +33,8 @@ declare module '@xmldom/xmldom' {
|
|
|
20
33
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
|
|
21
34
|
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
|
|
22
35
|
*/
|
|
23
|
-
function
|
|
36
|
+
function isHTMLMimeType(mimeType: string): mimeType is typeof MIME_TYPE.HTML;
|
|
37
|
+
|
|
24
38
|
/**
|
|
25
39
|
* Only returns true if `mimeType` is one of the allowed values for `DOMParser.parseFromString`.
|
|
26
40
|
*/
|
|
@@ -29,28 +43,42 @@ declare module '@xmldom/xmldom' {
|
|
|
29
43
|
/**
|
|
30
44
|
* All mime types that are allowed as input to `DOMParser.parseFromString`
|
|
31
45
|
*
|
|
32
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02
|
|
33
|
-
*
|
|
34
|
-
* @see
|
|
46
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02
|
|
47
|
+
* MDN
|
|
48
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype
|
|
49
|
+
* WHATWG HTML Spec
|
|
50
|
+
* @see {@link DOMParser.prototype.parseFromString}
|
|
51
|
+
*/
|
|
52
|
+
type MIME_TYPE = (typeof MIME_TYPE)[keyof typeof MIME_TYPE];
|
|
53
|
+
/**
|
|
54
|
+
* All mime types that are allowed as input to `DOMParser.parseFromString`
|
|
55
|
+
*
|
|
56
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02
|
|
57
|
+
* MDN
|
|
58
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype
|
|
59
|
+
* WHATWG HTML Spec
|
|
60
|
+
* @see {@link DOMParser.prototype.parseFromString}
|
|
35
61
|
*/
|
|
36
|
-
|
|
62
|
+
var MIME_TYPE: {
|
|
37
63
|
/**
|
|
38
64
|
* `text/html`, the only mime type that triggers treating an XML document as HTML.
|
|
39
65
|
*
|
|
40
66
|
* @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
|
|
41
67
|
* @see https://en.wikipedia.org/wiki/HTML Wikipedia
|
|
42
68
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
|
|
43
|
-
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
|
|
69
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
|
|
70
|
+
* WHATWG HTML Spec
|
|
44
71
|
*/
|
|
45
|
-
HTML
|
|
72
|
+
readonly HTML: 'text/html';
|
|
46
73
|
/**
|
|
47
74
|
* `application/xml`, the standard mime type for XML documents.
|
|
48
75
|
*
|
|
49
|
-
* @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType
|
|
76
|
+
* @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType
|
|
77
|
+
* registration
|
|
50
78
|
* @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
|
|
51
79
|
* @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
|
|
52
80
|
*/
|
|
53
|
-
XML_APPLICATION
|
|
81
|
+
readonly XML_APPLICATION: 'application/xml';
|
|
54
82
|
/**
|
|
55
83
|
* `text/html`, an alias for `application/xml`.
|
|
56
84
|
*
|
|
@@ -58,16 +86,17 @@ declare module '@xmldom/xmldom' {
|
|
|
58
86
|
* @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
|
|
59
87
|
* @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
|
|
60
88
|
*/
|
|
61
|
-
XML_TEXT
|
|
89
|
+
readonly XML_TEXT: 'text/xml';
|
|
62
90
|
/**
|
|
63
91
|
* `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
|
|
64
92
|
* but is parsed as an XML document.
|
|
65
93
|
*
|
|
66
|
-
* @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType
|
|
94
|
+
* @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType
|
|
95
|
+
* registration
|
|
67
96
|
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
|
|
68
97
|
* @see https://en.wikipedia.org/wiki/XHTML Wikipedia
|
|
69
98
|
*/
|
|
70
|
-
XML_XHTML_APPLICATION
|
|
99
|
+
readonly XML_XHTML_APPLICATION: 'application/xhtml+xml';
|
|
71
100
|
/**
|
|
72
101
|
* `image/svg+xml`,
|
|
73
102
|
*
|
|
@@ -75,78 +104,1170 @@ declare module '@xmldom/xmldom' {
|
|
|
75
104
|
* @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
|
|
76
105
|
* @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
|
|
77
106
|
*/
|
|
78
|
-
XML_SVG_IMAGE
|
|
79
|
-
}
|
|
107
|
+
readonly XML_SVG_IMAGE: 'image/svg+xml';
|
|
108
|
+
};
|
|
80
109
|
/**
|
|
81
110
|
* Namespaces that are used in xmldom.
|
|
82
111
|
*
|
|
83
112
|
* @see http://www.w3.org/TR/REC-xml-names
|
|
84
113
|
*/
|
|
85
|
-
|
|
114
|
+
type NAMESPACE = (typeof NAMESPACE)[keyof typeof NAMESPACE];
|
|
115
|
+
/**
|
|
116
|
+
* Namespaces that are used in xmldom.
|
|
117
|
+
*
|
|
118
|
+
* @see http://www.w3.org/TR/REC-xml-names
|
|
119
|
+
*/
|
|
120
|
+
var NAMESPACE: {
|
|
86
121
|
/**
|
|
87
122
|
* The XHTML namespace.
|
|
88
123
|
*
|
|
89
124
|
* @see http://www.w3.org/1999/xhtml
|
|
90
125
|
*/
|
|
91
|
-
HTML
|
|
126
|
+
readonly HTML: 'http://www.w3.org/1999/xhtml';
|
|
92
127
|
/**
|
|
93
128
|
* The SVG namespace.
|
|
94
129
|
*
|
|
95
130
|
* @see http://www.w3.org/2000/svg
|
|
96
131
|
*/
|
|
97
|
-
SVG
|
|
132
|
+
readonly SVG: 'http://www.w3.org/2000/svg';
|
|
98
133
|
/**
|
|
99
134
|
* The `xml:` namespace.
|
|
100
135
|
*
|
|
101
136
|
* @see http://www.w3.org/XML/1998/namespace
|
|
102
137
|
*/
|
|
103
|
-
XML
|
|
138
|
+
readonly XML: 'http://www.w3.org/XML/1998/namespace';
|
|
104
139
|
|
|
105
140
|
/**
|
|
106
|
-
* The `xmlns:` namespace
|
|
141
|
+
* The `xmlns:` namespace.
|
|
107
142
|
*
|
|
108
143
|
* @see https://www.w3.org/2000/xmlns/
|
|
109
144
|
*/
|
|
110
|
-
XMLNS
|
|
145
|
+
readonly XMLNS: 'http://www.w3.org/2000/xmlns/';
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// END ./lib/conventions.js
|
|
149
|
+
|
|
150
|
+
// START ./lib/errors.js
|
|
151
|
+
type DOMExceptionName =
|
|
152
|
+
(typeof DOMExceptionName)[keyof typeof DOMExceptionName];
|
|
153
|
+
var DOMExceptionName: {
|
|
154
|
+
/**
|
|
155
|
+
* the default value as defined by the spec
|
|
156
|
+
*/
|
|
157
|
+
readonly Error: 'Error';
|
|
158
|
+
/**
|
|
159
|
+
* @deprecated
|
|
160
|
+
* Use RangeError instead.
|
|
161
|
+
*/
|
|
162
|
+
readonly IndexSizeError: 'IndexSizeError';
|
|
163
|
+
/**
|
|
164
|
+
* @deprecated
|
|
165
|
+
* Just to match the related static code, not part of the spec.
|
|
166
|
+
*/
|
|
167
|
+
readonly DomstringSizeError: 'DomstringSizeError';
|
|
168
|
+
readonly HierarchyRequestError: 'HierarchyRequestError';
|
|
169
|
+
readonly WrongDocumentError: 'WrongDocumentError';
|
|
170
|
+
readonly InvalidCharacterError: 'InvalidCharacterError';
|
|
171
|
+
/**
|
|
172
|
+
* @deprecated
|
|
173
|
+
* Just to match the related static code, not part of the spec.
|
|
174
|
+
*/
|
|
175
|
+
readonly NoDataAllowedError: 'NoDataAllowedError';
|
|
176
|
+
readonly NoModificationAllowedError: 'NoModificationAllowedError';
|
|
177
|
+
readonly NotFoundError: 'NotFoundError';
|
|
178
|
+
readonly NotSupportedError: 'NotSupportedError';
|
|
179
|
+
readonly InUseAttributeError: 'InUseAttributeError';
|
|
180
|
+
readonly InvalidStateError: 'InvalidStateError';
|
|
181
|
+
readonly SyntaxError: 'SyntaxError';
|
|
182
|
+
readonly InvalidModificationError: 'InvalidModificationError';
|
|
183
|
+
readonly NamespaceError: 'NamespaceError';
|
|
184
|
+
/**
|
|
185
|
+
* @deprecated
|
|
186
|
+
* Use TypeError for invalid arguments,
|
|
187
|
+
* "NotSupportedError" DOMException for unsupported operations,
|
|
188
|
+
* and "NotAllowedError" DOMException for denied requests instead.
|
|
189
|
+
*/
|
|
190
|
+
readonly InvalidAccessError: 'InvalidAccessError';
|
|
191
|
+
/**
|
|
192
|
+
* @deprecated
|
|
193
|
+
* Just to match the related static code, not part of the spec.
|
|
194
|
+
*/
|
|
195
|
+
readonly ValidationError: 'ValidationError';
|
|
196
|
+
/**
|
|
197
|
+
* @deprecated
|
|
198
|
+
* Use TypeError instead.
|
|
199
|
+
*/
|
|
200
|
+
readonly TypeMismatchError: 'TypeMismatchError';
|
|
201
|
+
readonly SecurityError: 'SecurityError';
|
|
202
|
+
readonly NetworkError: 'NetworkError';
|
|
203
|
+
readonly AbortError: 'AbortError';
|
|
204
|
+
/**
|
|
205
|
+
* @deprecated
|
|
206
|
+
* Just to match the related static code, not part of the spec.
|
|
207
|
+
*/
|
|
208
|
+
readonly URLMismatchError: 'URLMismatchError';
|
|
209
|
+
readonly QuotaExceededError: 'QuotaExceededError';
|
|
210
|
+
readonly TimeoutError: 'TimeoutError';
|
|
211
|
+
readonly InvalidNodeTypeError: 'InvalidNodeTypeError';
|
|
212
|
+
readonly DataCloneError: 'DataCloneError';
|
|
213
|
+
readonly EncodingError: 'EncodingError';
|
|
214
|
+
readonly NotReadableError: 'NotReadableError';
|
|
215
|
+
readonly UnknownError: 'UnknownError';
|
|
216
|
+
readonly ConstraintError: 'ConstraintError';
|
|
217
|
+
readonly DataError: 'DataError';
|
|
218
|
+
readonly TransactionInactiveError: 'TransactionInactiveError';
|
|
219
|
+
readonly ReadOnlyError: 'ReadOnlyError';
|
|
220
|
+
readonly VersionError: 'VersionError';
|
|
221
|
+
readonly OperationError: 'OperationError';
|
|
222
|
+
readonly NotAllowedError: 'NotAllowedError';
|
|
223
|
+
readonly OptOutError: 'OptOutError';
|
|
224
|
+
};
|
|
225
|
+
type ExceptionCode = (typeof ExceptionCode)[keyof typeof ExceptionCode];
|
|
226
|
+
|
|
227
|
+
var ExceptionCode: {
|
|
228
|
+
readonly INDEX_SIZE_ERR: 1;
|
|
229
|
+
readonly DOMSTRING_SIZE_ERR: 2;
|
|
230
|
+
readonly HIERARCHY_REQUEST_ERR: 3;
|
|
231
|
+
readonly WRONG_DOCUMENT_ERR: 4;
|
|
232
|
+
readonly INVALID_CHARACTER_ERR: 5;
|
|
233
|
+
readonly NO_DATA_ALLOWED_ERR: 6;
|
|
234
|
+
readonly NO_MODIFICATION_ALLOWED_ERR: 7;
|
|
235
|
+
readonly NOT_FOUND_ERR: 8;
|
|
236
|
+
readonly NOT_SUPPORTED_ERR: 9;
|
|
237
|
+
readonly INUSE_ATTRIBUTE_ERR: 10;
|
|
238
|
+
readonly INVALID_STATE_ERR: 11;
|
|
239
|
+
readonly SYNTAX_ERR: 12;
|
|
240
|
+
readonly INVALID_MODIFICATION_ERR: 13;
|
|
241
|
+
readonly NAMESPACE_ERR: 14;
|
|
242
|
+
readonly INVALID_ACCESS_ERR: 15;
|
|
243
|
+
readonly VALIDATION_ERR: 16;
|
|
244
|
+
readonly TYPE_MISMATCH_ERR: 17;
|
|
245
|
+
readonly SECURITY_ERR: 18;
|
|
246
|
+
readonly NETWORK_ERR: 19;
|
|
247
|
+
readonly ABORT_ERR: 20;
|
|
248
|
+
readonly URL_MISMATCH_ERR: 21;
|
|
249
|
+
readonly QUOTA_EXCEEDED_ERR: 22;
|
|
250
|
+
readonly TIMEOUT_ERR: 23;
|
|
251
|
+
readonly INVALID_NODE_TYPE_ERR: 24;
|
|
252
|
+
readonly DATA_CLONE_ERR: 25;
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an
|
|
257
|
+
* operation is impossible to perform (either for logical reasons, because data is lost, or
|
|
258
|
+
* because the implementation has become unstable). In general, DOM methods return specific
|
|
259
|
+
* error values in ordinary processing situations, such as out-of-bound errors when using
|
|
260
|
+
* NodeList.
|
|
261
|
+
*
|
|
262
|
+
* Implementations should raise other exceptions under other circumstances. For example,
|
|
263
|
+
* implementations should raise an implementation-dependent exception if a null argument is
|
|
264
|
+
* passed when null was not expected.
|
|
265
|
+
*
|
|
266
|
+
* This implementation supports the following usages:
|
|
267
|
+
* 1. according to the living standard (both arguments are optional):
|
|
268
|
+
* ```
|
|
269
|
+
* new DOMException("message (can be empty)", DOMExceptionNames.HierarchyRequestError)
|
|
270
|
+
* ```
|
|
271
|
+
* 2. according to previous xmldom implementation (only the first argument is required):
|
|
272
|
+
* ```
|
|
273
|
+
* new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "optional message")
|
|
274
|
+
* ```
|
|
275
|
+
* both result in the proper name being set.
|
|
276
|
+
*
|
|
277
|
+
* @see https://webidl.spec.whatwg.org/#idl-DOMException
|
|
278
|
+
* @see https://webidl.spec.whatwg.org/#dfn-error-names-table
|
|
279
|
+
* @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-17189187
|
|
280
|
+
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
|
|
281
|
+
* @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
|
|
282
|
+
*/
|
|
283
|
+
class DOMException extends Error {
|
|
284
|
+
constructor(message?: string, name?: DOMExceptionName | string);
|
|
285
|
+
constructor(code?: ExceptionCode, message?: string);
|
|
286
|
+
|
|
287
|
+
readonly name: DOMExceptionName;
|
|
288
|
+
readonly code: ExceptionCode | 0;
|
|
289
|
+
static readonly INDEX_SIZE_ERR: 1;
|
|
290
|
+
static readonly DOMSTRING_SIZE_ERR: 2;
|
|
291
|
+
static readonly HIERARCHY_REQUEST_ERR: 3;
|
|
292
|
+
static readonly WRONG_DOCUMENT_ERR: 4;
|
|
293
|
+
static readonly INVALID_CHARACTER_ERR: 5;
|
|
294
|
+
static readonly NO_DATA_ALLOWED_ERR: 6;
|
|
295
|
+
static readonly NO_MODIFICATION_ALLOWED_ERR: 7;
|
|
296
|
+
static readonly NOT_FOUND_ERR: 8;
|
|
297
|
+
static readonly NOT_SUPPORTED_ERR: 9;
|
|
298
|
+
static readonly INUSE_ATTRIBUTE_ERR: 10;
|
|
299
|
+
static readonly INVALID_STATE_ERR: 11;
|
|
300
|
+
static readonly SYNTAX_ERR: 12;
|
|
301
|
+
static readonly INVALID_MODIFICATION_ERR: 13;
|
|
302
|
+
static readonly NAMESPACE_ERR: 14;
|
|
303
|
+
static readonly INVALID_ACCESS_ERR: 15;
|
|
304
|
+
static readonly VALIDATION_ERR: 16;
|
|
305
|
+
static readonly TYPE_MISMATCH_ERR: 17;
|
|
306
|
+
static readonly SECURITY_ERR: 18;
|
|
307
|
+
static readonly NETWORK_ERR: 19;
|
|
308
|
+
static readonly ABORT_ERR: 20;
|
|
309
|
+
static readonly URL_MISMATCH_ERR: 21;
|
|
310
|
+
static readonly QUOTA_EXCEEDED_ERR: 22;
|
|
311
|
+
static readonly TIMEOUT_ERR: 23;
|
|
312
|
+
static readonly INVALID_NODE_TYPE_ERR: 24;
|
|
313
|
+
static readonly DATA_CLONE_ERR: 25;
|
|
111
314
|
}
|
|
112
315
|
|
|
113
316
|
/**
|
|
114
|
-
*
|
|
317
|
+
* Creates an error that will not be caught by XMLReader aka the SAX parser.
|
|
115
318
|
*/
|
|
116
319
|
class ParseError extends Error {
|
|
117
|
-
constructor(message:string, locator?:any);
|
|
320
|
+
constructor(message: string, locator?: any, cause?: Error);
|
|
321
|
+
|
|
322
|
+
readonly message: string;
|
|
323
|
+
readonly locator?: any;
|
|
118
324
|
}
|
|
119
|
-
|
|
325
|
+
|
|
326
|
+
// END ./lib/errors.js
|
|
120
327
|
|
|
121
328
|
// START ./lib/dom.js
|
|
329
|
+
|
|
330
|
+
type InstanceOf<T> = {
|
|
331
|
+
// instanceof pre ts 5.3
|
|
332
|
+
(val: unknown): val is T;
|
|
333
|
+
// instanceof post ts 5.3
|
|
334
|
+
[Symbol.hasInstance](val: unknown): val is T;
|
|
335
|
+
};
|
|
122
336
|
/**
|
|
123
|
-
* The
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
337
|
+
* The DOM Node interface is an abstract base class upon which many other DOM API objects are
|
|
338
|
+
* based, thus letting those object types to be used similarly and often interchangeably. As an
|
|
339
|
+
* abstract class, there is no such thing as a plain Node object. All objects that implement
|
|
340
|
+
* Node functionality are based on one of its subclasses. Most notable are Document, Element,
|
|
341
|
+
* and DocumentFragment.
|
|
342
|
+
*
|
|
343
|
+
* In addition, every kind of DOM node is represented by an interface based on Node. These
|
|
344
|
+
* include Attr, CharacterData (which Text, Comment, CDATASection and ProcessingInstruction are
|
|
345
|
+
* all based on), and DocumentType.
|
|
346
|
+
*
|
|
347
|
+
* In some cases, a particular feature of the base Node interface may not apply to one of its
|
|
348
|
+
* child interfaces; in that case, the inheriting node may return null or throw an exception,
|
|
349
|
+
* depending on circumstances. For example, attempting to add children to a node type that
|
|
350
|
+
* cannot have children will throw an exception.
|
|
351
|
+
*
|
|
352
|
+
* **This behavior is slightly different from the in the specs**:
|
|
353
|
+
* - undeclared properties: nodeType, baseURI, isConnected, parentElement, textContent
|
|
354
|
+
* - missing methods: contains, getRootNode, isEqualNode, isSameNode
|
|
355
|
+
*
|
|
356
|
+
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
|
|
357
|
+
* @see https://dom.spec.whatwg.org/#node
|
|
358
|
+
* @prettierignore
|
|
127
359
|
*/
|
|
128
|
-
|
|
129
|
-
|
|
360
|
+
interface Node {
|
|
361
|
+
/**
|
|
362
|
+
* Returns the children.
|
|
363
|
+
*
|
|
364
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/childNodes)
|
|
365
|
+
*/
|
|
366
|
+
readonly childNodes: NodeList;
|
|
367
|
+
/**
|
|
368
|
+
* Returns the first child.
|
|
369
|
+
*
|
|
370
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/firstChild)
|
|
371
|
+
*/
|
|
372
|
+
readonly firstChild: Node | null;
|
|
373
|
+
/**
|
|
374
|
+
* Returns the last child.
|
|
375
|
+
*
|
|
376
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/lastChild)
|
|
377
|
+
*/
|
|
378
|
+
readonly lastChild: Node | null;
|
|
379
|
+
/**
|
|
380
|
+
* The local part of the qualified name of this node.
|
|
381
|
+
*/
|
|
382
|
+
localName: string | null;
|
|
383
|
+
/**
|
|
384
|
+
* The namespace URI of this node.
|
|
385
|
+
*/
|
|
386
|
+
readonly namespaceURI: string | null;
|
|
387
|
+
/**
|
|
388
|
+
* Returns the next sibling.
|
|
389
|
+
*
|
|
390
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)
|
|
391
|
+
*/
|
|
392
|
+
readonly nextSibling: Node | null;
|
|
393
|
+
/**
|
|
394
|
+
* Returns a string appropriate for the type of node.
|
|
395
|
+
*
|
|
396
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nodeName)
|
|
397
|
+
*/
|
|
398
|
+
readonly nodeName: string;
|
|
399
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nodeValue) */
|
|
400
|
+
nodeValue: string | null;
|
|
401
|
+
/**
|
|
402
|
+
* Returns the node document. Returns null for documents.
|
|
403
|
+
*
|
|
404
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/ownerDocument)
|
|
405
|
+
*/
|
|
406
|
+
readonly ownerDocument: Document | null;
|
|
407
|
+
/**
|
|
408
|
+
* Returns the parent.
|
|
409
|
+
*
|
|
410
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/parentNode)
|
|
411
|
+
*/
|
|
412
|
+
readonly parentNode: Node | null;
|
|
413
|
+
/**
|
|
414
|
+
* The prefix of the namespace for this node.
|
|
415
|
+
*/
|
|
416
|
+
prefix: string | null;
|
|
417
|
+
/**
|
|
418
|
+
* Returns the previous sibling.
|
|
419
|
+
*
|
|
420
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/previousSibling)
|
|
421
|
+
*/
|
|
422
|
+
readonly previousSibling: Node | null;
|
|
423
|
+
|
|
424
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/appendChild) */
|
|
425
|
+
appendChild(node: Node): Node;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Returns a copy of node. If deep is true, the copy also includes the node's descendants.
|
|
429
|
+
*
|
|
430
|
+
* @throws {DOMException}
|
|
431
|
+
* May throw a DOMException if operations within {@link Element#setAttributeNode} or
|
|
432
|
+
* {@link Node#appendChild} (which are potentially invoked in this method) do not meet their
|
|
433
|
+
* specific constraints.
|
|
434
|
+
*
|
|
435
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/cloneNode)
|
|
436
|
+
*/
|
|
437
|
+
cloneNode(deep?: boolean): Node;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Returns a bitmask indicating the position of other relative to node.
|
|
441
|
+
*
|
|
442
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/compareDocumentPosition)
|
|
443
|
+
*/
|
|
444
|
+
compareDocumentPosition(other: Node): number;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Returns whether node has children.
|
|
448
|
+
*
|
|
449
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/hasChildNodes)
|
|
450
|
+
*/
|
|
451
|
+
hasChildNodes(): boolean;
|
|
452
|
+
|
|
453
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/insertBefore) */
|
|
454
|
+
insertBefore(node: Node, child: Node | null): Node;
|
|
455
|
+
|
|
456
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/isDefaultNamespace) */
|
|
457
|
+
isDefaultNamespace(namespace: string | null): boolean;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Checks whether the DOM implementation implements a specific feature and its version.
|
|
461
|
+
*
|
|
462
|
+
* @deprecated
|
|
463
|
+
* Since `DOMImplementation.hasFeature` is deprecated and always returns true.
|
|
464
|
+
* @param feature
|
|
465
|
+
* The package name of the feature to test. This is the same name that can be passed to the
|
|
466
|
+
* method `hasFeature` on `DOMImplementation`.
|
|
467
|
+
* @param version
|
|
468
|
+
* This is the version number of the package name to test.
|
|
469
|
+
* @since Introduced in DOM Level 2
|
|
470
|
+
* @see {@link DOMImplementation.hasFeature}
|
|
471
|
+
*/
|
|
472
|
+
isSupported(feature: string, version: string): true;
|
|
473
|
+
|
|
474
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/lookupNamespaceURI) */
|
|
475
|
+
lookupNamespaceURI(prefix: string | null): string | null;
|
|
476
|
+
|
|
477
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/lookupPrefix) */
|
|
478
|
+
lookupPrefix(namespace: string | null): string | null;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Removes empty exclusive Text nodes and concatenates the data of remaining contiguous
|
|
482
|
+
* exclusive Text nodes into the first of their nodes.
|
|
483
|
+
*
|
|
484
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/normalize)
|
|
485
|
+
*/
|
|
486
|
+
normalize(): void;
|
|
487
|
+
|
|
488
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/removeChild) */
|
|
489
|
+
removeChild(child: Node): Node;
|
|
490
|
+
|
|
491
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/replaceChild) */
|
|
492
|
+
replaceChild(node: Node, child: Node): Node;
|
|
493
|
+
|
|
494
|
+
/** node is an element. */
|
|
495
|
+
readonly ELEMENT_NODE: 1;
|
|
496
|
+
readonly ATTRIBUTE_NODE: 2;
|
|
497
|
+
/** node is a Text node. */
|
|
498
|
+
readonly TEXT_NODE: 3;
|
|
499
|
+
/** node is a CDATASection node. */
|
|
500
|
+
readonly CDATA_SECTION_NODE: 4;
|
|
501
|
+
readonly ENTITY_REFERENCE_NODE: 5;
|
|
502
|
+
readonly ENTITY_NODE: 6;
|
|
503
|
+
/** node is a ProcessingInstruction node. */
|
|
504
|
+
readonly PROCESSING_INSTRUCTION_NODE: 7;
|
|
505
|
+
/** node is a Comment node. */
|
|
506
|
+
readonly COMMENT_NODE: 8;
|
|
507
|
+
/** node is a document. */
|
|
508
|
+
readonly DOCUMENT_NODE: 9;
|
|
509
|
+
/** node is a doctype. */
|
|
510
|
+
readonly DOCUMENT_TYPE_NODE: 10;
|
|
511
|
+
/** node is a DocumentFragment node. */
|
|
512
|
+
readonly DOCUMENT_FRAGMENT_NODE: 11;
|
|
513
|
+
readonly NOTATION_NODE: 12;
|
|
514
|
+
/** Set when node and other are not in the same tree. */
|
|
515
|
+
readonly DOCUMENT_POSITION_DISCONNECTED: 0x01;
|
|
516
|
+
/** Set when other is preceding node. */
|
|
517
|
+
readonly DOCUMENT_POSITION_PRECEDING: 0x02;
|
|
518
|
+
/** Set when other is following node. */
|
|
519
|
+
readonly DOCUMENT_POSITION_FOLLOWING: 0x04;
|
|
520
|
+
/** Set when other is an ancestor of node. */
|
|
521
|
+
readonly DOCUMENT_POSITION_CONTAINS: 0x08;
|
|
522
|
+
/** Set when other is a descendant of node. */
|
|
523
|
+
readonly DOCUMENT_POSITION_CONTAINED_BY: 0x10;
|
|
524
|
+
readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 0x20;
|
|
130
525
|
}
|
|
131
526
|
|
|
132
|
-
|
|
527
|
+
var Node: InstanceOf<Node> & {
|
|
528
|
+
/** node is an element. */
|
|
529
|
+
readonly ELEMENT_NODE: 1;
|
|
530
|
+
readonly ATTRIBUTE_NODE: 2;
|
|
531
|
+
/** node is a Text node. */
|
|
532
|
+
readonly TEXT_NODE: 3;
|
|
533
|
+
/** node is a CDATASection node. */
|
|
534
|
+
readonly CDATA_SECTION_NODE: 4;
|
|
535
|
+
readonly ENTITY_REFERENCE_NODE: 5;
|
|
536
|
+
readonly ENTITY_NODE: 6;
|
|
537
|
+
/** node is a ProcessingInstruction node. */
|
|
538
|
+
readonly PROCESSING_INSTRUCTION_NODE: 7;
|
|
539
|
+
/** node is a Comment node. */
|
|
540
|
+
readonly COMMENT_NODE: 8;
|
|
541
|
+
/** node is a document. */
|
|
542
|
+
readonly DOCUMENT_NODE: 9;
|
|
543
|
+
/** node is a doctype. */
|
|
544
|
+
readonly DOCUMENT_TYPE_NODE: 10;
|
|
545
|
+
/** node is a DocumentFragment node. */
|
|
546
|
+
readonly DOCUMENT_FRAGMENT_NODE: 11;
|
|
547
|
+
readonly NOTATION_NODE: 12;
|
|
548
|
+
/** Set when node and other are not in the same tree. */
|
|
549
|
+
readonly DOCUMENT_POSITION_DISCONNECTED: 0x01;
|
|
550
|
+
/** Set when other is preceding node. */
|
|
551
|
+
readonly DOCUMENT_POSITION_PRECEDING: 0x02;
|
|
552
|
+
/** Set when other is following node. */
|
|
553
|
+
readonly DOCUMENT_POSITION_FOLLOWING: 0x04;
|
|
554
|
+
/** Set when other is an ancestor of node. */
|
|
555
|
+
readonly DOCUMENT_POSITION_CONTAINS: 0x08;
|
|
556
|
+
/** Set when other is a descendant of node. */
|
|
557
|
+
readonly DOCUMENT_POSITION_CONTAINED_BY: 0x10;
|
|
558
|
+
readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 0x20;
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* A DOM element's attribute as an object. In most DOM methods, you will probably directly
|
|
563
|
+
* retrieve the attribute as a string (e.g., Element.getAttribute(), but certain functions (e.g.,
|
|
564
|
+
* Element.getAttributeNode()) or means of iterating give Attr types.
|
|
565
|
+
*
|
|
566
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr)
|
|
567
|
+
*/
|
|
568
|
+
interface Attr extends Node {
|
|
569
|
+
readonly nodeType: typeof Node.ATTRIBUTE_NODE;
|
|
570
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/name) */
|
|
571
|
+
readonly name: string;
|
|
572
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/namespaceURI) */
|
|
573
|
+
readonly namespaceURI: string | null;
|
|
574
|
+
readonly ownerDocument: Document;
|
|
575
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/ownerElement) */
|
|
576
|
+
readonly ownerElement: Element | null;
|
|
577
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/prefix) */
|
|
578
|
+
readonly prefix: string | null;
|
|
133
579
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
|
|
580
|
+
* @deprecated
|
|
581
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/specified)
|
|
582
|
+
*/
|
|
583
|
+
readonly specified: true;
|
|
584
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/value) */
|
|
585
|
+
value: string;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* A DOM element's attribute as an object. In most DOM methods, you will probably directly
|
|
589
|
+
* retrieve the attribute as a string (e.g., Element.getAttribute(), but certain functions (e.g.,
|
|
590
|
+
* Element.getAttributeNode()) or means of iterating give Attr types.
|
|
591
|
+
*
|
|
592
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr)
|
|
593
|
+
*/
|
|
594
|
+
var Attr: InstanceOf<Attr>;
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Objects implementing the NamedNodeMap interface are used to represent collections of nodes
|
|
598
|
+
* that can be accessed by name.
|
|
599
|
+
* Note that NamedNodeMap does not inherit from NodeList;
|
|
600
|
+
* NamedNodeMaps are not maintained in any particular order.
|
|
601
|
+
* Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal
|
|
602
|
+
* index,
|
|
603
|
+
* but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
|
|
604
|
+
* and does not imply that the DOM specifies an order to these Nodes.
|
|
605
|
+
* NamedNodeMap objects in the DOM are live.
|
|
606
|
+
* used for attributes or DocumentType entities
|
|
607
|
+
*
|
|
608
|
+
* This implementation only supports property indices, but does not support named properties,
|
|
609
|
+
* as specified in the living standard.
|
|
610
|
+
*
|
|
611
|
+
* @see https://dom.spec.whatwg.org/#interface-namednodemap
|
|
612
|
+
* @see https://webidl.spec.whatwg.org/#dfn-supported-property-names
|
|
613
|
+
*/
|
|
614
|
+
class NamedNodeMap implements Iterable<Attr> {
|
|
615
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/length) */
|
|
616
|
+
readonly length: number;
|
|
617
|
+
/**
|
|
618
|
+
* Get an attribute by name. Note: Name is in lower case in case of HTML namespace and
|
|
619
|
+
* document.
|
|
620
|
+
*
|
|
621
|
+
* @param {string} localName
|
|
622
|
+
* The local name of the attribute.
|
|
623
|
+
* @returns {Attr | null}
|
|
624
|
+
* The attribute with the given local name, or null if no such attribute exists.
|
|
625
|
+
* @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
|
|
626
|
+
*/
|
|
627
|
+
getNamedItem(qualifiedName: string): Attr | null;
|
|
628
|
+
/**
|
|
629
|
+
* Get an attribute by namespace and local name.
|
|
630
|
+
*
|
|
631
|
+
* @param {string | null} namespaceURI
|
|
632
|
+
* The namespace URI of the attribute.
|
|
633
|
+
* @param {string} localName
|
|
634
|
+
* The local name of the attribute.
|
|
635
|
+
* @returns {Attr | null}
|
|
636
|
+
* The attribute with the given namespace URI and local name, or null if no such attribute
|
|
637
|
+
* exists.
|
|
638
|
+
* @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
|
|
639
|
+
*/
|
|
640
|
+
getNamedItemNS(namespace: string | null, localName: string): Attr | null;
|
|
641
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/item) */
|
|
642
|
+
item(index: number): Attr | null;
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Removes an attribute specified by the local name.
|
|
646
|
+
*
|
|
647
|
+
* @param {string} localName
|
|
648
|
+
* The local name of the attribute to be removed.
|
|
649
|
+
* @returns {Attr}
|
|
650
|
+
* The attribute node that was removed.
|
|
651
|
+
* @throws {DOMException}
|
|
652
|
+
* With code:
|
|
653
|
+
* - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given name is found.
|
|
654
|
+
* @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem
|
|
655
|
+
* @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name
|
|
656
|
+
*/
|
|
657
|
+
removeNamedItem(qualifiedName: string): Attr;
|
|
658
|
+
/**
|
|
659
|
+
* Removes an attribute specified by the namespace and local name.
|
|
137
660
|
*
|
|
138
|
-
*
|
|
661
|
+
* @param {string | null} namespaceURI
|
|
662
|
+
* The namespace URI of the attribute to be removed.
|
|
663
|
+
* @param {string} localName
|
|
664
|
+
* The local name of the attribute to be removed.
|
|
665
|
+
* @returns {Attr}
|
|
666
|
+
* The attribute node that was removed.
|
|
667
|
+
* @throws {DOMException}
|
|
668
|
+
* With code:
|
|
669
|
+
* - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given namespace URI and
|
|
670
|
+
* local name is found.
|
|
671
|
+
* @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns
|
|
672
|
+
* @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace
|
|
673
|
+
*/
|
|
674
|
+
removeNamedItemNS(namespace: string | null, localName: string): Attr;
|
|
675
|
+
/**
|
|
676
|
+
* Set an attribute.
|
|
677
|
+
*
|
|
678
|
+
* @param {Attr} attr
|
|
679
|
+
* The attribute to set.
|
|
680
|
+
* @returns {Attr | null}
|
|
681
|
+
* The old attribute with the same local name and namespace URI as the new one, or null if no
|
|
682
|
+
* such attribute exists.
|
|
683
|
+
* @throws {DOMException}
|
|
684
|
+
* With code:
|
|
685
|
+
* - {@link INUSE_ATTRIBUTE_ERR} - If the attribute is already an attribute of another
|
|
686
|
+
* element.
|
|
687
|
+
* @see https://dom.spec.whatwg.org/#concept-element-attributes-set
|
|
688
|
+
*/
|
|
689
|
+
setNamedItem(attr: Attr): Attr | null;
|
|
690
|
+
/**
|
|
691
|
+
* Set an attribute, replacing an existing attribute with the same local name and namespace
|
|
692
|
+
* URI if one exists.
|
|
693
|
+
*
|
|
694
|
+
* @param {Attr} attr
|
|
695
|
+
* The attribute to set.
|
|
696
|
+
* @returns {Attr | null}
|
|
697
|
+
* The old attribute with the same local name and namespace URI as the new one, or null if no
|
|
698
|
+
* such attribute exists.
|
|
699
|
+
* @throws {DOMException}
|
|
700
|
+
* Throws a DOMException with the name "InUseAttributeError" if the attribute is already an
|
|
701
|
+
* attribute of another element.
|
|
702
|
+
* @see https://dom.spec.whatwg.org/#concept-element-attributes-set
|
|
703
|
+
*/
|
|
704
|
+
setNamedItemNS(attr: Attr): Attr | null;
|
|
705
|
+
[index: number]: Attr;
|
|
706
|
+
[Symbol.iterator](): Iterator<Attr>;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* NodeList objects are collections of nodes, usually returned by properties such as
|
|
711
|
+
* Node.childNodes and methods such as document.querySelectorAll().
|
|
712
|
+
*
|
|
713
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeList)
|
|
714
|
+
*/
|
|
715
|
+
class NodeList implements Iterable<Node> {
|
|
716
|
+
/**
|
|
717
|
+
* Returns the number of nodes in the collection.
|
|
718
|
+
*
|
|
719
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeList/length)
|
|
720
|
+
*/
|
|
721
|
+
readonly length: number;
|
|
722
|
+
/**
|
|
723
|
+
* Returns the node with index index from the collection. The nodes are sorted in tree order.
|
|
724
|
+
*
|
|
725
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeList/item)
|
|
726
|
+
*/
|
|
727
|
+
item(index: number): Node | null;
|
|
728
|
+
/**
|
|
729
|
+
* Returns a string representation of the NodeList.
|
|
730
|
+
*/
|
|
731
|
+
toString(nodeFilter: (node: Node) => Node | undefined): string;
|
|
732
|
+
/**
|
|
733
|
+
* Filters the NodeList based on a predicate.
|
|
734
|
+
*
|
|
735
|
+
* @private
|
|
736
|
+
*/
|
|
737
|
+
filter(predicate: (node: Node) => boolean): Node[];
|
|
738
|
+
/**
|
|
739
|
+
* Returns the first index at which a given node can be found in the NodeList, or -1 if it is
|
|
740
|
+
* not present.
|
|
741
|
+
*
|
|
742
|
+
* @private
|
|
743
|
+
*/
|
|
744
|
+
indexOf(node: Node): number;
|
|
745
|
+
[index: number]: Node | undefined;
|
|
746
|
+
|
|
747
|
+
[Symbol.iterator](): Iterator<Node>;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Represents a live collection of nodes that is automatically updated when its associated
|
|
752
|
+
* document changes.
|
|
753
|
+
*/
|
|
754
|
+
interface LiveNodeList extends NodeList {}
|
|
755
|
+
/**
|
|
756
|
+
* Represents a live collection of nodes that is automatically updated when its associated
|
|
757
|
+
* document changes.
|
|
758
|
+
*/
|
|
759
|
+
var LiveNodeList: InstanceOf<LiveNodeList>;
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Element is the most general base class from which all objects in a Document inherit. It only
|
|
763
|
+
* has methods and properties common to all kinds of elements. More specific classes inherit from
|
|
764
|
+
* Element.
|
|
765
|
+
*
|
|
766
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element)
|
|
767
|
+
*/
|
|
768
|
+
interface Element extends Node {
|
|
769
|
+
readonly nodeType: typeof Node.ELEMENT_NODE;
|
|
770
|
+
|
|
771
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/attributes) */
|
|
772
|
+
readonly attributes: NamedNodeMap;
|
|
773
|
+
/**
|
|
774
|
+
* Returns element's first attribute whose qualified name is qualifiedName, and null if there
|
|
775
|
+
* is no such attribute otherwise.
|
|
776
|
+
*
|
|
777
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttribute)
|
|
778
|
+
*/
|
|
779
|
+
getAttribute(qualifiedName: string): string | null;
|
|
780
|
+
/**
|
|
781
|
+
* Returns element's attribute whose namespace is namespace and local name is localName, and
|
|
782
|
+
* null if there is no such attribute otherwise.
|
|
783
|
+
*
|
|
784
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNS)
|
|
785
|
+
*/
|
|
786
|
+
getAttributeNS(namespace: string | null, localName: string): string | null;
|
|
787
|
+
/**
|
|
788
|
+
* Returns the qualified names of all element's attributes. Can contain duplicates.
|
|
789
|
+
*
|
|
790
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNames)
|
|
791
|
+
*/
|
|
792
|
+
getAttributeNames(): string[];
|
|
793
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNode) */
|
|
794
|
+
getAttributeNode(qualifiedName: string): Attr | null;
|
|
795
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNodeNS) */
|
|
796
|
+
getAttributeNodeNS(
|
|
797
|
+
namespace: string | null,
|
|
798
|
+
localName: string
|
|
799
|
+
): Attr | null;
|
|
800
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getBoundingClientRect) */
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Returns a LiveNodeList of elements with the given qualifiedName.
|
|
804
|
+
* Searching for all descendants can be done by passing `*` as `qualifiedName`.
|
|
139
805
|
*
|
|
140
|
-
*
|
|
806
|
+
* All descendants of the specified element are searched, but not the element itself.
|
|
807
|
+
* The returned list is live, which means it updates itself with the DOM tree automatically.
|
|
808
|
+
* Therefore, there is no need to call `Element.getElementsByTagName()`
|
|
809
|
+
* with the same element and arguments repeatedly if the DOM changes in between calls.
|
|
141
810
|
*
|
|
811
|
+
* When called on an HTML element in an HTML document,
|
|
812
|
+
* `getElementsByTagName` lower-cases the argument before searching for it.
|
|
813
|
+
* This is undesirable when trying to match camel-cased SVG elements (such as
|
|
814
|
+
* `<linearGradient>`) in an HTML document.
|
|
815
|
+
* Instead, use `Element.getElementsByTagNameNS()`,
|
|
816
|
+
* which preserves the capitalization of the tag name.
|
|
817
|
+
*
|
|
818
|
+
* `Element.getElementsByTagName` is similar to `Document.getElementsByTagName()`,
|
|
819
|
+
* except that it only searches for elements that are descendants of the specified element.
|
|
820
|
+
*
|
|
821
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName
|
|
822
|
+
* @see https://dom.spec.whatwg.org/#concept-getelementsbytagname
|
|
823
|
+
*/
|
|
824
|
+
getElementsByTagName(qualifiedName: string): LiveNodeList;
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Returns a `LiveNodeList` of elements with the given tag name belonging to the given
|
|
828
|
+
* namespace. It is similar to `Document.getElementsByTagNameNS`, except that its search is
|
|
829
|
+
* restricted to descendants of the specified element.
|
|
830
|
+
*
|
|
831
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getElementsByTagNameNS)
|
|
832
|
+
* */
|
|
833
|
+
getElementsByTagNameNS(
|
|
834
|
+
namespaceURI: string | null,
|
|
835
|
+
localName: string
|
|
836
|
+
): LiveNodeList;
|
|
837
|
+
|
|
838
|
+
getQualifiedName(): string;
|
|
839
|
+
/**
|
|
840
|
+
* Returns true if element has an attribute whose qualified name is qualifiedName, and false
|
|
841
|
+
* otherwise.
|
|
842
|
+
*
|
|
843
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/hasAttribute)
|
|
844
|
+
*/
|
|
845
|
+
hasAttribute(qualifiedName: string): boolean;
|
|
846
|
+
/**
|
|
847
|
+
* Returns true if element has an attribute whose namespace is namespace and local name is
|
|
848
|
+
* localName.
|
|
849
|
+
*
|
|
850
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/hasAttributeNS)
|
|
851
|
+
*/
|
|
852
|
+
hasAttributeNS(namespace: string | null, localName: string): boolean;
|
|
853
|
+
/**
|
|
854
|
+
* Returns true if element has attributes, and false otherwise.
|
|
855
|
+
*
|
|
856
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/hasAttributes)
|
|
857
|
+
*/
|
|
858
|
+
hasAttributes(): boolean;
|
|
859
|
+
/**
|
|
860
|
+
* Removes element's first attribute whose qualified name is qualifiedName.
|
|
861
|
+
*
|
|
862
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/removeAttribute)
|
|
863
|
+
*/
|
|
864
|
+
removeAttribute(qualifiedName: string): void;
|
|
865
|
+
/**
|
|
866
|
+
* Removes element's attribute whose namespace is namespace and local name is localName.
|
|
867
|
+
*
|
|
868
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/removeAttributeNS)
|
|
869
|
+
*/
|
|
870
|
+
removeAttributeNS(namespace: string | null, localName: string): void;
|
|
871
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/removeAttributeNode) */
|
|
872
|
+
removeAttributeNode(attr: Attr): Attr;
|
|
873
|
+
/**
|
|
874
|
+
* Sets the value of element's first attribute whose qualified name is qualifiedName to value.
|
|
875
|
+
*
|
|
876
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttribute)
|
|
877
|
+
*/
|
|
878
|
+
setAttribute(qualifiedName: string, value: string): void;
|
|
879
|
+
/**
|
|
880
|
+
* Sets the value of element's attribute whose namespace is namespace and local name is
|
|
881
|
+
* localName to value.
|
|
882
|
+
*
|
|
883
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNS)
|
|
884
|
+
*/
|
|
885
|
+
setAttributeNS(
|
|
886
|
+
namespace: string | null,
|
|
887
|
+
qualifiedName: string,
|
|
888
|
+
value: string
|
|
889
|
+
): void;
|
|
890
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNode) */
|
|
891
|
+
setAttributeNode(attr: Attr): Attr | null;
|
|
892
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNodeNS) */
|
|
893
|
+
setAttributeNodeNS(attr: Attr): Attr | null;
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Element is the most general base class from which all objects in a Document inherit. It only
|
|
897
|
+
* has methods and properties common to all kinds of elements. More specific classes inherit from
|
|
898
|
+
* Element.
|
|
899
|
+
*
|
|
900
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element)
|
|
901
|
+
*/
|
|
902
|
+
var Element: InstanceOf<Element>;
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* The CharacterData abstract interface represents a Node object that contains characters. This
|
|
906
|
+
* is an abstract interface, meaning there aren't any object of type CharacterData: it is
|
|
907
|
+
* implemented by other interfaces, like Text, Comment, or ProcessingInstruction which aren't
|
|
908
|
+
* abstract.
|
|
909
|
+
*
|
|
910
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData)
|
|
911
|
+
*/
|
|
912
|
+
interface CharacterData extends Node {
|
|
913
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/data) */
|
|
914
|
+
data: string;
|
|
915
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/length) */
|
|
916
|
+
readonly length: number;
|
|
917
|
+
readonly ownerDocument: Document;
|
|
918
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/appendData) */
|
|
919
|
+
appendData(data: string): void;
|
|
920
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/deleteData) */
|
|
921
|
+
deleteData(offset: number, count: number): void;
|
|
922
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/insertData) */
|
|
923
|
+
insertData(offset: number, data: string): void;
|
|
924
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/replaceData) */
|
|
925
|
+
replaceData(offset: number, count: number, data: string): void;
|
|
926
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/substringData) */
|
|
927
|
+
substringData(offset: number, count: number): string;
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* The CharacterData abstract interface represents a Node object that contains characters. This
|
|
931
|
+
* is an abstract interface, meaning there aren't any object of type CharacterData: it is
|
|
932
|
+
* implemented by other interfaces, like Text, Comment, or ProcessingInstruction which aren't
|
|
933
|
+
* abstract.
|
|
934
|
+
*
|
|
935
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData)
|
|
936
|
+
*/
|
|
937
|
+
var CharacterData: {
|
|
938
|
+
// instanceof pre ts 5.3
|
|
939
|
+
(val: unknown): val is CharacterData;
|
|
940
|
+
// instanceof post ts 5.3
|
|
941
|
+
[Symbol.hasInstance](val: unknown): val is CharacterData;
|
|
942
|
+
};
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* The textual content of Element or Attr. If an element has no markup within its content, it has
|
|
946
|
+
* a single child implementing Text that contains the element's text. However, if the element
|
|
947
|
+
* contains markup, it is parsed into information items and Text nodes that form its children.
|
|
948
|
+
*
|
|
949
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Text)
|
|
950
|
+
*/
|
|
951
|
+
interface Text extends CharacterData {
|
|
952
|
+
nodeName: '#text' | '#cdata-section';
|
|
953
|
+
nodeType: typeof Node.TEXT_NODE | typeof Node.CDATA_SECTION_NODE;
|
|
954
|
+
/**
|
|
955
|
+
* Splits data at the given offset and returns the remainder as Text node.
|
|
956
|
+
*
|
|
957
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Text/splitText)
|
|
958
|
+
*/
|
|
959
|
+
splitText(offset: number): Text;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* The textual content of Element or Attr. If an element has no markup within its content, it has
|
|
964
|
+
* a single child implementing Text that contains the element's text. However, if the element
|
|
965
|
+
* contains markup, it is parsed into information items and Text nodes that form its children.
|
|
966
|
+
*
|
|
967
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Text)
|
|
968
|
+
*/
|
|
969
|
+
var Text: InstanceOf<Text>;
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* The Comment interface represents textual notations within markup; although it is generally not
|
|
973
|
+
* visually shown, such comments are available to be read in the source view. Comments are
|
|
974
|
+
* represented in HTML and XML as content between '<!--' and '-->'. In XML, like inside SVG or
|
|
975
|
+
* MathML markup, the character sequence '--' cannot be used within a comment.
|
|
976
|
+
*
|
|
977
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Comment)
|
|
978
|
+
*/
|
|
979
|
+
interface Comment extends CharacterData {
|
|
980
|
+
nodeName: '#comment';
|
|
981
|
+
nodeType: typeof Node.COMMENT_NODE;
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* The Comment interface represents textual notations within markup; although it is generally not
|
|
985
|
+
* visually shown, such comments are available to be read in the source view. Comments are
|
|
986
|
+
* represented in HTML and XML as content between '<!--' and '-->'. In XML, like inside SVG or
|
|
987
|
+
* MathML markup, the character sequence '--' cannot be used within a comment.
|
|
988
|
+
*
|
|
989
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Comment)
|
|
990
|
+
*/
|
|
991
|
+
var Comment: InstanceOf<Comment>;
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* A CDATA section that can be used within XML to include extended portions of unescaped text.
|
|
995
|
+
* The symbols < and & don’t need escaping as they normally do when inside a CDATA section.
|
|
996
|
+
*
|
|
997
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CDATASection)
|
|
998
|
+
*/
|
|
999
|
+
interface CDATASection extends Text {
|
|
1000
|
+
nodeName: '#cdata-section';
|
|
1001
|
+
nodeType: typeof Node.CDATA_SECTION_NODE;
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* A CDATA section that can be used within XML to include extended portions of unescaped text.
|
|
1005
|
+
* The symbols < and & don’t need escaping as they normally do when inside a CDATA section.
|
|
1006
|
+
*
|
|
1007
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CDATASection)
|
|
1008
|
+
*/
|
|
1009
|
+
var CDATASection: InstanceOf<CDATASection>;
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* The DocumentFragment interface represents a minimal document object that has no parent.
|
|
1013
|
+
* It is used as a lightweight version of Document that stores a segment of a document structure
|
|
1014
|
+
* comprised of nodes just like a standard document.
|
|
1015
|
+
* The key difference is due to the fact that the document fragment isn't part
|
|
1016
|
+
* of the active document tree structure.
|
|
1017
|
+
* Changes made to the fragment don't affect the document.
|
|
1018
|
+
*/
|
|
1019
|
+
interface DocumentFragment extends Node {
|
|
1020
|
+
readonly ownerDocument: Document;
|
|
1021
|
+
getElementById(elementId: string): Element | null;
|
|
1022
|
+
}
|
|
1023
|
+
var DocumentFragment: InstanceOf<DocumentFragment>;
|
|
1024
|
+
|
|
1025
|
+
interface Entity extends Node {
|
|
1026
|
+
nodeType: typeof Node.ENTITY_NODE;
|
|
1027
|
+
}
|
|
1028
|
+
var Entity: InstanceOf<Entity>;
|
|
1029
|
+
|
|
1030
|
+
interface EntityReference extends Node {
|
|
1031
|
+
nodeType: typeof Node.ENTITY_REFERENCE_NODE;
|
|
1032
|
+
}
|
|
1033
|
+
var EntityReference: InstanceOf<EntityReference>;
|
|
1034
|
+
|
|
1035
|
+
interface Notation extends Node {
|
|
1036
|
+
nodeType: typeof Node.NOTATION_NODE;
|
|
1037
|
+
}
|
|
1038
|
+
var Notation: InstanceOf<Notation>;
|
|
1039
|
+
|
|
1040
|
+
interface ProcessingInstruction extends Node {
|
|
1041
|
+
nodeType: typeof Node.PROCESSING_INSTRUCTION_NODE;
|
|
1042
|
+
}
|
|
1043
|
+
var ProcessingInstruction: InstanceOf<ProcessingInstruction>;
|
|
1044
|
+
|
|
1045
|
+
interface Document extends Node {
|
|
1046
|
+
/**
|
|
1047
|
+
* The mime type of the document is determined at creation time and can not be modified.
|
|
1048
|
+
*
|
|
1049
|
+
* @see https://dom.spec.whatwg.org/#concept-document-content-type
|
|
1050
|
+
* @see {@link DOMImplementation}
|
|
1051
|
+
* @see {@link MIME_TYPE}
|
|
1052
|
+
*/
|
|
1053
|
+
readonly contentType: MIME_TYPE;
|
|
1054
|
+
/**
|
|
1055
|
+
* @see https://dom.spec.whatwg.org/#concept-document-type
|
|
1056
|
+
* @see {@link DOMImplementation}
|
|
1057
|
+
*/
|
|
1058
|
+
readonly type: 'html' | 'xml';
|
|
1059
|
+
/**
|
|
1060
|
+
* The implementation that created this document.
|
|
1061
|
+
*
|
|
1062
|
+
* @type DOMImplementation
|
|
1063
|
+
* @readonly
|
|
1064
|
+
*/
|
|
1065
|
+
readonly implementation: DOMImplementation;
|
|
1066
|
+
readonly ownerDocument: Document;
|
|
1067
|
+
readonly nodeName: '#document';
|
|
1068
|
+
readonly nodeType: typeof Node.DOCUMENT_NODE;
|
|
1069
|
+
readonly doctype: DocumentType | null;
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* Creates an attribute object with a specified name.
|
|
1073
|
+
*
|
|
1074
|
+
* @param name
|
|
1075
|
+
* String that sets the attribute object's name.
|
|
1076
|
+
*
|
|
1077
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createAttribute)
|
|
1078
|
+
*/
|
|
1079
|
+
createAttribute(localName: string): Attr;
|
|
1080
|
+
|
|
1081
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createAttributeNS) */
|
|
1082
|
+
createAttributeNS(namespace: string | null, qualifiedName: string): Attr;
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* Returns a CDATASection node whose data is data.
|
|
1086
|
+
*
|
|
1087
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createCDATASection)
|
|
1088
|
+
*/
|
|
1089
|
+
createCDATASection(data: string): CDATASection;
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* Creates a comment object with the specified data.
|
|
1093
|
+
*
|
|
1094
|
+
* @param data
|
|
1095
|
+
* Sets the comment object's data.
|
|
1096
|
+
*
|
|
1097
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createComment)
|
|
1098
|
+
*/
|
|
1099
|
+
createComment(data: string): Comment;
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* Creates a new document.
|
|
1103
|
+
*
|
|
1104
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createDocumentFragment)
|
|
1105
|
+
*/
|
|
1106
|
+
createDocumentFragment(): DocumentFragment;
|
|
1107
|
+
|
|
1108
|
+
|
|
1109
|
+
createElement(tagName: string): Element;
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* Returns an element with namespace namespace. Its namespace prefix will be everything before
|
|
1113
|
+
* ":" (U+003E) in qualifiedName or null. Its local name will be everything after ":" (U+003E)
|
|
1114
|
+
* in qualifiedName or qualifiedName.
|
|
1115
|
+
*
|
|
1116
|
+
* If localName does not match the Name production an "InvalidCharacterError" DOMException will
|
|
1117
|
+
* be thrown.
|
|
1118
|
+
*
|
|
1119
|
+
* If one of the following conditions is true a "NamespaceError" DOMException will be thrown:
|
|
1120
|
+
*
|
|
1121
|
+
* localName does not match the QName production.
|
|
1122
|
+
* Namespace prefix is not null and namespace is the empty string.
|
|
1123
|
+
* Namespace prefix is "xml" and namespace is not the XML namespace.
|
|
1124
|
+
* qualifiedName or namespace prefix is "xmlns" and namespace is not the XMLNS namespace.
|
|
1125
|
+
* namespace is the XMLNS namespace and neither qualifiedName nor namespace prefix is "xmlns".
|
|
1126
|
+
*
|
|
1127
|
+
* When supplied, options's is can be used to create a customized built-in element.
|
|
1128
|
+
*
|
|
1129
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createElementNS)
|
|
1130
|
+
*/
|
|
1131
|
+
createElementNS(
|
|
1132
|
+
namespace: string | null,
|
|
1133
|
+
qualifiedName: string,
|
|
1134
|
+
): Element;
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* Returns a ProcessingInstruction node whose target is target and data is data. If target does
|
|
1138
|
+
* not match the Name production an "InvalidCharacterError" DOMException will be thrown. If
|
|
1139
|
+
* data contains "?>" an "InvalidCharacterError" DOMException will be thrown.
|
|
1140
|
+
*
|
|
1141
|
+
* [MDN
|
|
1142
|
+
* Reference](https://developer.mozilla.org/docs/Web/API/Document/createProcessingInstruction)
|
|
1143
|
+
*/
|
|
1144
|
+
createProcessingInstruction(
|
|
1145
|
+
target: string,
|
|
1146
|
+
data: string
|
|
1147
|
+
): ProcessingInstruction;
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Creates a text string from the specified value.
|
|
1151
|
+
*
|
|
1152
|
+
* @param data
|
|
1153
|
+
* String that specifies the nodeValue property of the text node.
|
|
1154
|
+
*
|
|
1155
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createTextNode)
|
|
1156
|
+
*/
|
|
1157
|
+
createTextNode(data: string): Text;
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* Returns a reference to the first object with the specified value of the ID attribute.
|
|
1161
|
+
*
|
|
1162
|
+
* @param elementId
|
|
1163
|
+
* String that specifies the ID value.
|
|
1164
|
+
*/
|
|
1165
|
+
getElementById(elementId: string): Element | null;
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* The `getElementsByClassName` method of `Document` interface returns an array-like object
|
|
1169
|
+
* of all child elements which have **all** of the given class name(s).
|
|
1170
|
+
*
|
|
1171
|
+
* Returns an empty list if `classeNames` is an empty string or only contains HTML white
|
|
1172
|
+
* space characters.
|
|
1173
|
+
*
|
|
1174
|
+
* Warning: This is a live LiveNodeList.
|
|
1175
|
+
* Changes in the DOM will reflect in the array as the changes occur.
|
|
1176
|
+
* If an element selected by this array no longer qualifies for the selector,
|
|
1177
|
+
* it will automatically be removed. Be aware of this for iteration purposes.
|
|
1178
|
+
*
|
|
1179
|
+
* @param {string} classNames
|
|
1180
|
+
* Is a string representing the class name(s) to match; multiple class names are separated by
|
|
1181
|
+
* (ASCII-)whitespace.
|
|
1182
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
|
|
1183
|
+
* @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
|
|
1184
|
+
*/
|
|
1185
|
+
getElementsByClassName(classNames: string): LiveNodeList;
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* Returns a LiveNodeList of elements with the given qualifiedName.
|
|
1189
|
+
* Searching for all descendants can be done by passing `*` as `qualifiedName`.
|
|
1190
|
+
*
|
|
1191
|
+
* The complete document is searched, including the root node.
|
|
1192
|
+
* The returned list is live, which means it updates itself with the DOM tree automatically.
|
|
1193
|
+
* Therefore, there is no need to call `Element.getElementsByTagName()`
|
|
1194
|
+
* with the same element and arguments repeatedly if the DOM changes in between calls.
|
|
1195
|
+
*
|
|
1196
|
+
* When called on an HTML element in an HTML document,
|
|
1197
|
+
* `getElementsByTagName` lower-cases the argument before searching for it.
|
|
1198
|
+
* This is undesirable when trying to match camel-cased SVG elements (such as
|
|
1199
|
+
* `<linearGradient>`) in an HTML document.
|
|
1200
|
+
* Instead, use `Element.getElementsByTagNameNS()`,
|
|
1201
|
+
* which preserves the capitalization of the tag name.
|
|
1202
|
+
*
|
|
1203
|
+
* `Element.getElementsByTagName` is similar to `Document.getElementsByTagName()`,
|
|
1204
|
+
* except that it only searches for elements that are descendants of the specified element.
|
|
1205
|
+
*
|
|
1206
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName
|
|
1207
|
+
* @see https://dom.spec.whatwg.org/#concept-getelementsbytagname
|
|
1208
|
+
*/
|
|
1209
|
+
getElementsByTagName(qualifiedName: string): LiveNodeList;
|
|
1210
|
+
|
|
1211
|
+
/**
|
|
1212
|
+
* Returns a `LiveNodeList` of elements with the given tag name belonging to the given
|
|
1213
|
+
* namespace. The complete document is searched, including the root node.
|
|
1214
|
+
*
|
|
1215
|
+
* The returned list is live, which means it updates itself with the DOM tree automatically.
|
|
1216
|
+
* Therefore, there is no need to call `Element.getElementsByTagName()`
|
|
1217
|
+
* with the same element and arguments repeatedly if the DOM changes in between calls.
|
|
1218
|
+
*
|
|
1219
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getElementsByTagNameNS)
|
|
1220
|
+
* */
|
|
1221
|
+
getElementsByTagNameNS(
|
|
1222
|
+
namespaceURI: string | null,
|
|
1223
|
+
localName: string
|
|
1224
|
+
): LiveNodeList;
|
|
1225
|
+
/**
|
|
1226
|
+
* Returns a copy of node. If deep is true, the copy also includes the node's descendants.
|
|
1227
|
+
*
|
|
1228
|
+
* If node is a document or a shadow root, throws a "NotSupportedError" DOMException.
|
|
1229
|
+
*
|
|
1230
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/importNode)
|
|
1231
|
+
*/
|
|
1232
|
+
importNode<T extends Node>(node: T, deep?: boolean): T;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
var Document: InstanceOf<Document>;
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* A Node containing a doctype.
|
|
1239
|
+
*
|
|
1240
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType)
|
|
1241
|
+
*/
|
|
1242
|
+
interface DocumentType extends Node {
|
|
1243
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType/name) */
|
|
1244
|
+
readonly name: string;
|
|
1245
|
+
readonly internalSubset: string;
|
|
1246
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType/publicId) */
|
|
1247
|
+
readonly publicId: string;
|
|
1248
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentType/systemId) */
|
|
1249
|
+
readonly systemId: string;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
var DocumentType: InstanceOf<DocumentFragment>;
|
|
1253
|
+
|
|
1254
|
+
class DOMImplementation {
|
|
1255
|
+
/**
|
|
1256
|
+
* The DOMImplementation interface represents an object providing methods which are not
|
|
1257
|
+
* dependent on any particular document.
|
|
1258
|
+
* Such an object is returned by the `Document.implementation` property.
|
|
1259
|
+
*
|
|
1260
|
+
* __The individual methods describe the differences compared to the specs.__.
|
|
1261
|
+
*
|
|
1262
|
+
* @class
|
|
142
1263
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN
|
|
143
|
-
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1
|
|
144
|
-
*
|
|
1264
|
+
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1
|
|
1265
|
+
* Core (Initial)
|
|
145
1266
|
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core
|
|
146
1267
|
* @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core
|
|
147
1268
|
* @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard
|
|
148
1269
|
*/
|
|
149
|
-
|
|
1270
|
+
constructor();
|
|
150
1271
|
|
|
151
1272
|
/**
|
|
152
1273
|
* Creates an XML Document object of the specified type with its document element.
|
|
@@ -156,17 +1277,16 @@ declare module '@xmldom/xmldom' {
|
|
|
156
1277
|
* `type` set to `'xml'`).
|
|
157
1278
|
* - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
|
|
158
1279
|
*
|
|
159
|
-
* @returns {Document}
|
|
160
|
-
*
|
|
161
|
-
* @see DOMImplementation.createHTMLDocument
|
|
162
|
-
*
|
|
1280
|
+
* @returns {Document}
|
|
1281
|
+
* The XML document.
|
|
1282
|
+
* @see {@link DOMImplementation.createHTMLDocument}
|
|
163
1283
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
|
|
164
1284
|
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM
|
|
165
|
-
*
|
|
166
|
-
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument
|
|
1285
|
+
* Level 2 Core (initial)
|
|
1286
|
+
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
|
|
167
1287
|
*/
|
|
168
1288
|
createDocument(
|
|
169
|
-
namespaceURI: string | null,
|
|
1289
|
+
namespaceURI: NAMESPACE | string | null,
|
|
170
1290
|
qualifiedName: string,
|
|
171
1291
|
doctype?: DocumentType | null
|
|
172
1292
|
): Document;
|
|
@@ -177,16 +1297,16 @@ declare module '@xmldom/xmldom' {
|
|
|
177
1297
|
* __This behavior is slightly different from the in the specs__:
|
|
178
1298
|
* - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
|
|
179
1299
|
*
|
|
180
|
-
* @returns {DocumentType}
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
1300
|
+
* @returns {DocumentType}
|
|
1301
|
+
* which can either be used with `DOMImplementation.createDocument`
|
|
1302
|
+
* upon document creation or can be put into the document via methods like
|
|
1303
|
+
* `Node.insertBefore()` or `Node.replaceChild()`
|
|
184
1304
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType
|
|
185
|
-
*
|
|
1305
|
+
* MDN
|
|
186
1306
|
* @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM
|
|
187
|
-
*
|
|
1307
|
+
* Level 2 Core
|
|
188
1308
|
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living
|
|
189
|
-
*
|
|
1309
|
+
* Standard
|
|
190
1310
|
*/
|
|
191
1311
|
createDocumentType(
|
|
192
1312
|
qualifiedName: string,
|
|
@@ -200,10 +1320,9 @@ declare module '@xmldom/xmldom' {
|
|
|
200
1320
|
* __It behaves slightly different from the description in the living standard__:
|
|
201
1321
|
* - If the first argument is `false` no initial nodes are added (steps 3-7 in the specs are
|
|
202
1322
|
* omitted)
|
|
203
|
-
* -
|
|
204
|
-
*
|
|
205
|
-
* @see DOMImplementation.createDocument
|
|
1323
|
+
* - several properties and methods are missing - Nothing related to events is implemented.
|
|
206
1324
|
*
|
|
1325
|
+
* @see {@link DOMImplementation.createDocument}
|
|
207
1326
|
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
|
208
1327
|
* @see https://dom.spec.whatwg.org/#html-document
|
|
209
1328
|
*/
|
|
@@ -211,80 +1330,76 @@ declare module '@xmldom/xmldom' {
|
|
|
211
1330
|
|
|
212
1331
|
/**
|
|
213
1332
|
* The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given
|
|
214
|
-
* feature is supported. The different implementations fairly diverged in what kind of
|
|
215
|
-
* were reported. The latest version of the spec settled to force this method to
|
|
216
|
-
* true, where the functionality was accurate and in use.
|
|
217
|
-
*
|
|
218
|
-
* @deprecated It is deprecated and modern browsers return true in all cases.
|
|
1333
|
+
* feature is supported. The different implementations fairly diverged in what kind of
|
|
1334
|
+
* features were reported. The latest version of the spec settled to force this method to
|
|
1335
|
+
* always return true, where the functionality was accurate and in use.
|
|
219
1336
|
*
|
|
1337
|
+
* @deprecated
|
|
1338
|
+
* It is deprecated and modern browsers return true in all cases.
|
|
220
1339
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
|
|
221
|
-
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1
|
|
1340
|
+
* @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1
|
|
1341
|
+
* Core
|
|
222
1342
|
* @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
|
|
223
1343
|
*/
|
|
224
1344
|
hasFeature(feature: string, version?: string): true;
|
|
225
1345
|
}
|
|
226
1346
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
new (): XMLSerializer;
|
|
1347
|
+
class XMLSerializer {
|
|
1348
|
+
serializeToString(node: Node, nodeFilter?: (node: Node) => boolean): string;
|
|
230
1349
|
}
|
|
1350
|
+
|
|
231
1351
|
// END ./lib/dom.js
|
|
232
1352
|
|
|
233
1353
|
// START ./lib/dom-parser.js
|
|
234
|
-
|
|
235
|
-
|
|
1354
|
+
/**
|
|
1355
|
+
* The DOMParser interface provides the ability to parse XML or HTML source code from a string
|
|
1356
|
+
* into a DOM `Document`.
|
|
1357
|
+
*
|
|
1358
|
+
* _xmldom is different from the spec in that it allows an `options` parameter,
|
|
1359
|
+
* to control the behavior._.
|
|
1360
|
+
*
|
|
1361
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
|
|
1362
|
+
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
|
|
1363
|
+
*/
|
|
1364
|
+
class DOMParser {
|
|
236
1365
|
/**
|
|
237
|
-
* The DOMParser interface provides the ability to parse XML or HTML source code
|
|
238
|
-
*
|
|
1366
|
+
* The DOMParser interface provides the ability to parse XML or HTML source code from a
|
|
1367
|
+
* string into a DOM `Document`.
|
|
239
1368
|
*
|
|
240
1369
|
* _xmldom is different from the spec in that it allows an `options` parameter,
|
|
241
|
-
* to control the behavior._
|
|
1370
|
+
* to control the behavior._.
|
|
242
1371
|
*
|
|
1372
|
+
* @class
|
|
243
1373
|
* @param {DOMParserOptions} [options]
|
|
244
|
-
* @constructor
|
|
245
|
-
*
|
|
246
1374
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
|
|
247
1375
|
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
|
|
248
1376
|
*/
|
|
249
|
-
|
|
250
|
-
}
|
|
1377
|
+
constructor(options?: DOMParserOptions);
|
|
251
1378
|
|
|
252
|
-
/**
|
|
253
|
-
* The DOMParser interface provides the ability to parse XML or HTML source code
|
|
254
|
-
* from a string into a DOM `Document`.
|
|
255
|
-
*
|
|
256
|
-
* _xmldom is different from the spec in that it allows an `options` parameter,
|
|
257
|
-
* to control the behavior._
|
|
258
|
-
*
|
|
259
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
|
|
260
|
-
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
|
|
261
|
-
*/
|
|
262
|
-
interface DOMParser {
|
|
263
1379
|
/**
|
|
264
|
-
* Parses `source` using the options in the way configured by the `DOMParserOptions` of
|
|
1380
|
+
* Parses `source` using the options in the way configured by the `DOMParserOptions` of
|
|
1381
|
+
* `this`
|
|
265
1382
|
* `DOMParser`. If `mimeType` is `text/html` an HTML `Document` is created, otherwise an XML
|
|
266
1383
|
* `Document` is created.
|
|
267
1384
|
*
|
|
268
1385
|
* __It behaves different from the description in the living standard__:
|
|
269
|
-
* - Uses the `options` passed to the `DOMParser` constructor to modify the
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
* - If no `Document` was created during parsing it is reported as a `fatalError`.
|
|
275
|
-
*
|
|
276
|
-
* @throws ParseError for any `fatalError` or anything that is thrown by `onError`
|
|
277
|
-
* @throws TypeError for any invalid `mimeType`
|
|
278
|
-
* @returns the `Document` node
|
|
1386
|
+
* - Uses the `options` passed to the `DOMParser` constructor to modify the behavior.
|
|
1387
|
+
* - Any unexpected input is reported to `onError` with either a `warning`, `error` or
|
|
1388
|
+
* `fatalError` level.
|
|
1389
|
+
* - Any `fatalError` throws a `ParseError` which prevents further processing.
|
|
1390
|
+
* - Any error thrown by `onError` is converted to a `ParseError` which prevents further
|
|
1391
|
+
* processing - If no `Document` was created during parsing it is reported as a `fatalError`.
|
|
279
1392
|
*
|
|
1393
|
+
* @returns
|
|
1394
|
+
* The `Document` node.
|
|
1395
|
+
* @throws {ParseError}
|
|
1396
|
+
* for any `fatalError` or anything that is thrown by `onError`
|
|
1397
|
+
* @throws {TypeError}
|
|
1398
|
+
* for any invalid `mimeType`
|
|
280
1399
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
|
|
281
1400
|
* @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev
|
|
282
1401
|
*/
|
|
283
|
-
parseFromString(source: string, mimeType: MIME_TYPE
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
interface XMLSerializer {
|
|
287
|
-
serializeToString(node: Node, nodeFilter?: (node: Node) => boolean): string;
|
|
1402
|
+
parseFromString(source: string, mimeType: MIME_TYPE | string): Document;
|
|
288
1403
|
}
|
|
289
1404
|
|
|
290
1405
|
interface DOMParserOptions {
|
|
@@ -293,14 +1408,14 @@ declare module '@xmldom/xmldom' {
|
|
|
293
1408
|
* which is used to copy values from the options before they are used for parsing.
|
|
294
1409
|
*
|
|
295
1410
|
* @private
|
|
296
|
-
* @see
|
|
1411
|
+
* @see {@link assign}
|
|
297
1412
|
*/
|
|
298
1413
|
readonly assign?: typeof Object.assign;
|
|
299
1414
|
/**
|
|
300
1415
|
* For internal testing: The class for creating an instance for handling events from the SAX
|
|
301
1416
|
* parser.
|
|
302
|
-
*
|
|
303
|
-
* the specified behavior can completely be broken
|
|
1417
|
+
* *****Warning: By configuring a faulty implementation,
|
|
1418
|
+
* the specified behavior can completely be broken*****.
|
|
304
1419
|
*
|
|
305
1420
|
* @private
|
|
306
1421
|
*/
|
|
@@ -312,8 +1427,10 @@ declare module '@xmldom/xmldom' {
|
|
|
312
1427
|
* For backwards compatibility:
|
|
313
1428
|
* If it is a function, it will be used as a value for `onError`,
|
|
314
1429
|
* but it receives different argument types than before 0.9.0.
|
|
315
|
-
*
|
|
1430
|
+
*
|
|
316
1431
|
* @deprecated
|
|
1432
|
+
* @throws {TypeError}
|
|
1433
|
+
* If it is an object.
|
|
317
1434
|
*/
|
|
318
1435
|
readonly errorHandler?: ErrorHandlerFunction;
|
|
319
1436
|
|
|
@@ -339,15 +1456,17 @@ declare module '@xmldom/xmldom' {
|
|
|
339
1456
|
* If the provided method throws, a `ParserError` is thrown,
|
|
340
1457
|
* which prevents any further processing.
|
|
341
1458
|
*
|
|
342
|
-
* Be aware that many `warning`s are considered an error
|
|
343
|
-
*
|
|
1459
|
+
* Be aware that many `warning`s are considered an error that prevents further processing in
|
|
1460
|
+
* most implementations.
|
|
344
1461
|
*
|
|
345
|
-
* @param level
|
|
346
|
-
*
|
|
347
|
-
* @param
|
|
348
|
-
*
|
|
349
|
-
* @
|
|
350
|
-
*
|
|
1462
|
+
* @param level
|
|
1463
|
+
* The error level as reported by the SAXParser.
|
|
1464
|
+
* @param message
|
|
1465
|
+
* The error message.
|
|
1466
|
+
* @param context
|
|
1467
|
+
* The DOMHandler instance used for parsing.
|
|
1468
|
+
* @see {@link onErrorStopParsing}
|
|
1469
|
+
* @see {@link onWarningStopParsing}
|
|
351
1470
|
*/
|
|
352
1471
|
readonly onError?: ErrorHandlerFunction;
|
|
353
1472
|
|
|
@@ -369,17 +1488,19 @@ declare module '@xmldom/xmldom' {
|
|
|
369
1488
|
* A method that prevents any further parsing when an `error`
|
|
370
1489
|
* with level `error` is reported during parsing.
|
|
371
1490
|
*
|
|
372
|
-
* @see DOMParserOptions.onError
|
|
373
|
-
* @see onWarningStopParsing
|
|
1491
|
+
* @see {@link DOMParserOptions.onError}
|
|
1492
|
+
* @see {@link onWarningStopParsing}
|
|
374
1493
|
*/
|
|
375
1494
|
function onErrorStopParsing(): void | never;
|
|
1495
|
+
|
|
376
1496
|
/**
|
|
377
1497
|
* A method that prevents any further parsing when an `error`
|
|
378
1498
|
* with any level is reported during parsing.
|
|
379
1499
|
*
|
|
380
|
-
* @see DOMParserOptions.onError
|
|
381
|
-
* @see onErrorStopParsing
|
|
1500
|
+
* @see {@link DOMParserOptions.onError}
|
|
1501
|
+
* @see {@link onErrorStopParsing}
|
|
382
1502
|
*/
|
|
383
1503
|
function onWarningStopParsing(): never;
|
|
1504
|
+
|
|
384
1505
|
// END ./lib/dom-parser.js
|
|
385
1506
|
}
|