@xmldom/xmldom 0.9.0 → 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/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- /// <reference lib="dom" />
2
-
3
1
  declare module '@xmldom/xmldom' {
4
2
  // START ./lib/conventions.js
5
3
  /**
@@ -12,6 +10,21 @@ declare module '@xmldom/xmldom' {
12
10
  * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign
13
11
  */
14
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 isHtmlMimeType(mimeType: string): mimeType is MIME_TYPE.HTML;
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
  */
@@ -32,10 +46,20 @@ declare module '@xmldom/xmldom' {
32
46
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02
33
47
  * MDN
34
48
  * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype
35
- * WHATWG HTML Spec
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
36
60
  * @see {@link DOMParser.prototype.parseFromString}
37
61
  */
38
- enum MIME_TYPE {
62
+ var MIME_TYPE: {
39
63
  /**
40
64
  * `text/html`, the only mime type that triggers treating an XML document as HTML.
41
65
  *
@@ -43,9 +67,9 @@ declare module '@xmldom/xmldom' {
43
67
  * @see https://en.wikipedia.org/wiki/HTML Wikipedia
44
68
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
45
69
  * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
46
- * WHATWG HTML Spec
70
+ * WHATWG HTML Spec
47
71
  */
48
- HTML = 'text/html',
72
+ readonly HTML: 'text/html';
49
73
  /**
50
74
  * `application/xml`, the standard mime type for XML documents.
51
75
  *
@@ -54,7 +78,7 @@ declare module '@xmldom/xmldom' {
54
78
  * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
55
79
  * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
56
80
  */
57
- XML_APPLICATION = 'application/xml',
81
+ readonly XML_APPLICATION: 'application/xml';
58
82
  /**
59
83
  * `text/html`, an alias for `application/xml`.
60
84
  *
@@ -62,7 +86,7 @@ declare module '@xmldom/xmldom' {
62
86
  * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
63
87
  * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
64
88
  */
65
- XML_TEXT = 'text/xml',
89
+ readonly XML_TEXT: 'text/xml';
66
90
  /**
67
91
  * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
68
92
  * but is parsed as an XML document.
@@ -72,7 +96,7 @@ declare module '@xmldom/xmldom' {
72
96
  * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
73
97
  * @see https://en.wikipedia.org/wiki/XHTML Wikipedia
74
98
  */
75
- XML_XHTML_APPLICATION = 'application/xhtml+xml',
99
+ readonly XML_XHTML_APPLICATION: 'application/xhtml+xml';
76
100
  /**
77
101
  * `image/svg+xml`,
78
102
  *
@@ -80,62 +104,1154 @@ declare module '@xmldom/xmldom' {
80
104
  * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
81
105
  * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
82
106
  */
83
- XML_SVG_IMAGE = 'image/svg+xml',
84
- }
107
+ readonly XML_SVG_IMAGE: 'image/svg+xml';
108
+ };
85
109
  /**
86
110
  * Namespaces that are used in xmldom.
87
111
  *
88
112
  * @see http://www.w3.org/TR/REC-xml-names
89
113
  */
90
- enum NAMESPACE {
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: {
91
121
  /**
92
122
  * The XHTML namespace.
93
123
  *
94
124
  * @see http://www.w3.org/1999/xhtml
95
125
  */
96
- HTML = 'http://www.w3.org/1999/xhtml',
126
+ readonly HTML: 'http://www.w3.org/1999/xhtml';
97
127
  /**
98
128
  * The SVG namespace.
99
129
  *
100
130
  * @see http://www.w3.org/2000/svg
101
131
  */
102
- SVG = 'http://www.w3.org/2000/svg',
132
+ readonly SVG: 'http://www.w3.org/2000/svg';
103
133
  /**
104
134
  * The `xml:` namespace.
105
135
  *
106
136
  * @see http://www.w3.org/XML/1998/namespace
107
137
  */
108
- XML = 'http://www.w3.org/XML/1998/namespace',
138
+ readonly XML: 'http://www.w3.org/XML/1998/namespace';
109
139
 
110
140
  /**
111
141
  * The `xmlns:` namespace.
112
142
  *
113
143
  * @see https://www.w3.org/2000/xmlns/
114
144
  */
115
- XMLNS = 'http://www.w3.org/2000/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;
116
314
  }
117
315
 
118
316
  /**
119
- * A custom error that will not be caught by XMLReader aka the SAX parser.
317
+ * Creates an error that will not be caught by XMLReader aka the SAX parser.
120
318
  */
121
319
  class ParseError extends Error {
122
- constructor(message: string, locator?: any);
320
+ constructor(message: string, locator?: any, cause?: Error);
321
+
322
+ readonly message: string;
323
+ readonly locator?: any;
123
324
  }
124
- // END ./lib/conventions.js
325
+
326
+ // END ./lib/errors.js
125
327
 
126
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
+ };
127
336
  /**
128
- * The error class for errors reported by the DOM API.
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.
129
342
  *
130
- * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMException
131
- * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
132
- * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
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
133
359
  */
134
- class DOMException extends Error {
135
- constructor(code: number, message: string);
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;
136
525
  }
137
526
 
138
- interface DOMImplementation {
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;
579
+ /**
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.
660
+ *
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`.
805
+ *
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.
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 {
139
1255
  /**
140
1256
  * The DOMImplementation interface represents an object providing methods which are not
141
1257
  * dependent on any particular document.
@@ -151,7 +1267,7 @@ declare module '@xmldom/xmldom' {
151
1267
  * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core
152
1268
  * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard
153
1269
  */
154
- new (): DOMImplementation;
1270
+ constructor();
155
1271
 
156
1272
  /**
157
1273
  * Creates an XML Document object of the specified type with its document element.
@@ -161,7 +1277,8 @@ declare module '@xmldom/xmldom' {
161
1277
  * `type` set to `'xml'`).
162
1278
  * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
163
1279
  *
164
- * @returns {Document} The XML document.
1280
+ * @returns {Document}
1281
+ * The XML document.
165
1282
  * @see {@link DOMImplementation.createHTMLDocument}
166
1283
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
167
1284
  * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM
@@ -169,7 +1286,7 @@ declare module '@xmldom/xmldom' {
169
1286
  * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
170
1287
  */
171
1288
  createDocument(
172
- namespaceURI: string | null,
1289
+ namespaceURI: NAMESPACE | string | null,
173
1290
  qualifiedName: string,
174
1291
  doctype?: DocumentType | null
175
1292
  ): Document;
@@ -180,9 +1297,10 @@ declare module '@xmldom/xmldom' {
180
1297
  * __This behavior is slightly different from the in the specs__:
181
1298
  * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
182
1299
  *
183
- * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument`
184
- * upon document creation or can be put into the document via methods
185
- * like `Node.insertBefore()` or `Node.replaceChild()`
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()`
186
1304
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType
187
1305
  * MDN
188
1306
  * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM
@@ -202,7 +1320,7 @@ declare module '@xmldom/xmldom' {
202
1320
  * __It behaves slightly different from the description in the living standard__:
203
1321
  * - If the first argument is `false` no initial nodes are added (steps 3-7 in the specs are
204
1322
  * omitted)
205
- * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
1323
+ * - several properties and methods are missing - Nothing related to events is implemented.
206
1324
  *
207
1325
  * @see {@link DOMImplementation.createDocument}
208
1326
  * @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
@@ -226,15 +1344,24 @@ declare module '@xmldom/xmldom' {
226
1344
  hasFeature(feature: string, version?: string): true;
227
1345
  }
228
1346
 
229
- var XMLSerializer: XMLSerializerStatic;
230
- interface XMLSerializerStatic {
231
- new (): XMLSerializer;
1347
+ class XMLSerializer {
1348
+ serializeToString(node: Node, nodeFilter?: (node: Node) => boolean): string;
232
1349
  }
1350
+
233
1351
  // END ./lib/dom.js
234
1352
 
235
1353
  // START ./lib/dom-parser.js
236
- var DOMParser: DOMParserStatic;
237
- interface DOMParserStatic {
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 {
238
1365
  /**
239
1366
  * The DOMParser interface provides the ability to parse XML or HTML source code from a
240
1367
  * string into a DOM `Document`.
@@ -247,20 +1374,8 @@ declare module '@xmldom/xmldom' {
247
1374
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
248
1375
  * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
249
1376
  */
250
- new (options?: DOMParserOptions): DOMParser;
251
- }
1377
+ constructor(options?: DOMParserOptions);
252
1378
 
253
- /**
254
- * The DOMParser interface provides the ability to parse XML or HTML source code from a string
255
- * into a DOM `Document`.
256
- *
257
- * _xmldom is different from the spec in that it allows an `options` parameter,
258
- * to control the behavior._.
259
- *
260
- * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
261
- * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
262
- */
263
- interface DOMParser {
264
1379
  /**
265
1380
  * Parses `source` using the options in the way configured by the `DOMParserOptions` of
266
1381
  * `this`
@@ -275,21 +1390,16 @@ declare module '@xmldom/xmldom' {
275
1390
  * - Any error thrown by `onError` is converted to a `ParseError` which prevents further
276
1391
  * processing - If no `Document` was created during parsing it is reported as a `fatalError`.
277
1392
  *
278
- * @returns The `Document` node.
1393
+ * @returns
1394
+ * The `Document` node.
279
1395
  * @throws {ParseError}
280
1396
  * for any `fatalError` or anything that is thrown by `onError`
281
- * @throws {TypeError} for any invalid `mimeType`
1397
+ * @throws {TypeError}
1398
+ * for any invalid `mimeType`
282
1399
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
283
1400
  * @see https://html.spec.whatwg.org/#dom-domparser-parsefromstring-dev
284
1401
  */
285
- parseFromString(
286
- source: string,
287
- mimeType: MIME_TYPE = MIME_TYPE.XML_TEXT
288
- ): Document;
289
- }
290
-
291
- interface XMLSerializer {
292
- serializeToString(node: Node, nodeFilter?: (node: Node) => boolean): string;
1402
+ parseFromString(source: string, mimeType: MIME_TYPE | string): Document;
293
1403
  }
294
1404
 
295
1405
  interface DOMParserOptions {
@@ -298,7 +1408,7 @@ declare module '@xmldom/xmldom' {
298
1408
  * which is used to copy values from the options before they are used for parsing.
299
1409
  *
300
1410
  * @private
301
- * @see {@link conventions.assign}
1411
+ * @see {@link assign}
302
1412
  */
303
1413
  readonly assign?: typeof Object.assign;
304
1414
  /**
@@ -319,7 +1429,8 @@ declare module '@xmldom/xmldom' {
319
1429
  * but it receives different argument types than before 0.9.0.
320
1430
  *
321
1431
  * @deprecated
322
- * @throws {TypeError} If it is an object.
1432
+ * @throws {TypeError}
1433
+ * If it is an object.
323
1434
  */
324
1435
  readonly errorHandler?: ErrorHandlerFunction;
325
1436
 
@@ -381,6 +1492,7 @@ declare module '@xmldom/xmldom' {
381
1492
  * @see {@link onWarningStopParsing}
382
1493
  */
383
1494
  function onErrorStopParsing(): void | never;
1495
+
384
1496
  /**
385
1497
  * A method that prevents any further parsing when an `error`
386
1498
  * with any level is reported during parsing.
@@ -389,5 +1501,6 @@ declare module '@xmldom/xmldom' {
389
1501
  * @see {@link onErrorStopParsing}
390
1502
  */
391
1503
  function onWarningStopParsing(): never;
1504
+
392
1505
  // END ./lib/dom-parser.js
393
1506
  }