forked from xmldom/xmldom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
1594 lines (1502 loc) · 59.4 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
declare module '@xmldom/xmldom' {
// START ./lib/conventions.js
/**
* Since xmldom can not rely on `Object.assign`,
* it uses/provides a simplified version that is sufficient for its needs.
*
* @throws {TypeError}
* If target is not an object.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
* @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign
*/
function assign<T, S>(target: T, source: S): T & S;
/**
* For both the `text/html` and the `application/xhtml+xml` namespace the spec defines that
* the HTML namespace is provided as the default.
*
* @param {string} mimeType
* @returns {boolean}
* @see https://dom.spec.whatwg.org/#dom-document-createelement
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
*/
function hasDefaultHTMLNamespace(
mimeType: string
): mimeType is typeof MIME_TYPE.HTML | typeof MIME_TYPE.XML_XHTML_APPLICATION;
/**
* Only returns true if `value` matches MIME_TYPE.HTML, which indicates an HTML document.
*
* @see https://www.iana.org/assignments/media-types/text/html
* @see https://en.wikipedia.org/wiki/HTML
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
*/
function isHTMLMimeType(mimeType: string): mimeType is typeof MIME_TYPE.HTML;
/**
* Only returns true if `mimeType` is one of the allowed values for `DOMParser.parseFromString`.
*/
function isValidMimeType(mimeType: string): mimeType is MIME_TYPE;
/**
* All mime types that are allowed as input to `DOMParser.parseFromString`
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02
* MDN
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype
* WHATWG HTML Spec
* @see {@link DOMParser.prototype.parseFromString}
*/
type MIME_TYPE = (typeof MIME_TYPE)[keyof typeof MIME_TYPE];
/**
* All mime types that are allowed as input to `DOMParser.parseFromString`
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02
* MDN
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype
* WHATWG HTML Spec
* @see {@link DOMParser.prototype.parseFromString}
*/
var MIME_TYPE: {
/**
* `text/html`, the only mime type that triggers treating an XML document as HTML.
*
* @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
* @see https://en.wikipedia.org/wiki/HTML Wikipedia
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
* @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring
* WHATWG HTML Spec
*/
readonly HTML: 'text/html';
/**
* `application/xml`, the standard mime type for XML documents.
*
* @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType
* registration
* @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
* @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
*/
readonly XML_APPLICATION: 'application/xml';
/**
* `text/html`, an alias for `application/xml`.
*
* @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
* @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
* @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
*/
readonly XML_TEXT: 'text/xml';
/**
* `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
* but is parsed as an XML document.
*
* @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType
* registration
* @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
* @see https://en.wikipedia.org/wiki/XHTML Wikipedia
*/
readonly XML_XHTML_APPLICATION: 'application/xhtml+xml';
/**
* `image/svg+xml`,
*
* @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
* @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
* @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
*/
readonly XML_SVG_IMAGE: 'image/svg+xml';
};
/**
* Namespaces that are used in xmldom.
*
* @see http://www.w3.org/TR/REC-xml-names
*/
type NAMESPACE = (typeof NAMESPACE)[keyof typeof NAMESPACE];
/**
* Namespaces that are used in xmldom.
*
* @see http://www.w3.org/TR/REC-xml-names
*/
var NAMESPACE: {
/**
* The XHTML namespace.
*
* @see http://www.w3.org/1999/xhtml
*/
readonly HTML: 'http://www.w3.org/1999/xhtml';
/**
* The SVG namespace.
*
* @see http://www.w3.org/2000/svg
*/
readonly SVG: 'http://www.w3.org/2000/svg';
/**
* The `xml:` namespace.
*
* @see http://www.w3.org/XML/1998/namespace
*/
readonly XML: 'http://www.w3.org/XML/1998/namespace';
/**
* The `xmlns:` namespace.
*
* @see https://www.w3.org/2000/xmlns/
*/
readonly XMLNS: 'http://www.w3.org/2000/xmlns/';
};
// END ./lib/conventions.js
// START ./lib/errors.js
type DOMExceptionName =
(typeof DOMExceptionName)[keyof typeof DOMExceptionName];
var DOMExceptionName: {
/**
* the default value as defined by the spec
*/
readonly Error: 'Error';
/**
* @deprecated
* Use RangeError instead.
*/
readonly IndexSizeError: 'IndexSizeError';
/**
* @deprecated
* Just to match the related static code, not part of the spec.
*/
readonly DomstringSizeError: 'DomstringSizeError';
readonly HierarchyRequestError: 'HierarchyRequestError';
readonly WrongDocumentError: 'WrongDocumentError';
readonly InvalidCharacterError: 'InvalidCharacterError';
/**
* @deprecated
* Just to match the related static code, not part of the spec.
*/
readonly NoDataAllowedError: 'NoDataAllowedError';
readonly NoModificationAllowedError: 'NoModificationAllowedError';
readonly NotFoundError: 'NotFoundError';
readonly NotSupportedError: 'NotSupportedError';
readonly InUseAttributeError: 'InUseAttributeError';
readonly InvalidStateError: 'InvalidStateError';
readonly SyntaxError: 'SyntaxError';
readonly InvalidModificationError: 'InvalidModificationError';
readonly NamespaceError: 'NamespaceError';
/**
* @deprecated
* Use TypeError for invalid arguments,
* "NotSupportedError" DOMException for unsupported operations,
* and "NotAllowedError" DOMException for denied requests instead.
*/
readonly InvalidAccessError: 'InvalidAccessError';
/**
* @deprecated
* Just to match the related static code, not part of the spec.
*/
readonly ValidationError: 'ValidationError';
/**
* @deprecated
* Use TypeError instead.
*/
readonly TypeMismatchError: 'TypeMismatchError';
readonly SecurityError: 'SecurityError';
readonly NetworkError: 'NetworkError';
readonly AbortError: 'AbortError';
/**
* @deprecated
* Just to match the related static code, not part of the spec.
*/
readonly URLMismatchError: 'URLMismatchError';
readonly QuotaExceededError: 'QuotaExceededError';
readonly TimeoutError: 'TimeoutError';
readonly InvalidNodeTypeError: 'InvalidNodeTypeError';
readonly DataCloneError: 'DataCloneError';
readonly EncodingError: 'EncodingError';
readonly NotReadableError: 'NotReadableError';
readonly UnknownError: 'UnknownError';
readonly ConstraintError: 'ConstraintError';
readonly DataError: 'DataError';
readonly TransactionInactiveError: 'TransactionInactiveError';
readonly ReadOnlyError: 'ReadOnlyError';
readonly VersionError: 'VersionError';
readonly OperationError: 'OperationError';
readonly NotAllowedError: 'NotAllowedError';
readonly OptOutError: 'OptOutError';
};
type ExceptionCode = (typeof ExceptionCode)[keyof typeof ExceptionCode];
var ExceptionCode: {
readonly INDEX_SIZE_ERR: 1;
readonly DOMSTRING_SIZE_ERR: 2;
readonly HIERARCHY_REQUEST_ERR: 3;
readonly WRONG_DOCUMENT_ERR: 4;
readonly INVALID_CHARACTER_ERR: 5;
readonly NO_DATA_ALLOWED_ERR: 6;
readonly NO_MODIFICATION_ALLOWED_ERR: 7;
readonly NOT_FOUND_ERR: 8;
readonly NOT_SUPPORTED_ERR: 9;
readonly INUSE_ATTRIBUTE_ERR: 10;
readonly INVALID_STATE_ERR: 11;
readonly SYNTAX_ERR: 12;
readonly INVALID_MODIFICATION_ERR: 13;
readonly NAMESPACE_ERR: 14;
readonly INVALID_ACCESS_ERR: 15;
readonly VALIDATION_ERR: 16;
readonly TYPE_MISMATCH_ERR: 17;
readonly SECURITY_ERR: 18;
readonly NETWORK_ERR: 19;
readonly ABORT_ERR: 20;
readonly URL_MISMATCH_ERR: 21;
readonly QUOTA_EXCEEDED_ERR: 22;
readonly TIMEOUT_ERR: 23;
readonly INVALID_NODE_TYPE_ERR: 24;
readonly DATA_CLONE_ERR: 25;
};
/**
* DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an
* operation is impossible to perform (either for logical reasons, because data is lost, or
* because the implementation has become unstable). In general, DOM methods return specific
* error values in ordinary processing situations, such as out-of-bound errors when using
* NodeList.
*
* Implementations should raise other exceptions under other circumstances. For example,
* implementations should raise an implementation-dependent exception if a null argument is
* passed when null was not expected.
*
* This implementation supports the following usages:
* 1. according to the living standard (both arguments are optional):
* ```
* new DOMException("message (can be empty)", DOMExceptionNames.HierarchyRequestError)
* ```
* 2. according to previous xmldom implementation (only the first argument is required):
* ```
* new DOMException(DOMException.HIERARCHY_REQUEST_ERR, "optional message")
* ```
* both result in the proper name being set.
*
* @see https://webidl.spec.whatwg.org/#idl-DOMException
* @see https://webidl.spec.whatwg.org/#dfn-error-names-table
* @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-17189187
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
* @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
*/
class DOMException extends Error {
constructor(message?: string, name?: DOMExceptionName | string);
constructor(code?: ExceptionCode, message?: string);
readonly name: DOMExceptionName;
readonly code: ExceptionCode | 0;
static readonly INDEX_SIZE_ERR: 1;
static readonly DOMSTRING_SIZE_ERR: 2;
static readonly HIERARCHY_REQUEST_ERR: 3;
static readonly WRONG_DOCUMENT_ERR: 4;
static readonly INVALID_CHARACTER_ERR: 5;
static readonly NO_DATA_ALLOWED_ERR: 6;
static readonly NO_MODIFICATION_ALLOWED_ERR: 7;
static readonly NOT_FOUND_ERR: 8;
static readonly NOT_SUPPORTED_ERR: 9;
static readonly INUSE_ATTRIBUTE_ERR: 10;
static readonly INVALID_STATE_ERR: 11;
static readonly SYNTAX_ERR: 12;
static readonly INVALID_MODIFICATION_ERR: 13;
static readonly NAMESPACE_ERR: 14;
static readonly INVALID_ACCESS_ERR: 15;
static readonly VALIDATION_ERR: 16;
static readonly TYPE_MISMATCH_ERR: 17;
static readonly SECURITY_ERR: 18;
static readonly NETWORK_ERR: 19;
static readonly ABORT_ERR: 20;
static readonly URL_MISMATCH_ERR: 21;
static readonly QUOTA_EXCEEDED_ERR: 22;
static readonly TIMEOUT_ERR: 23;
static readonly INVALID_NODE_TYPE_ERR: 24;
static readonly DATA_CLONE_ERR: 25;
}
/**
* Creates an error that will not be caught by XMLReader aka the SAX parser.
*/
class ParseError extends Error {
constructor(message: string, locator?: any, cause?: Error);
readonly message: string;
readonly locator?: any;
}
// END ./lib/errors.js
// START ./lib/dom.js
type InstanceOf<T> = {
// instanceof pre ts 5.3
(val: unknown): val is T;
// instanceof post ts 5.3
[Symbol.hasInstance](val: unknown): val is T;
};
type GetRootNodeOptions = {
composed?: boolean;
};
/**
* The DOM Node interface is an abstract base class upon which many other DOM API objects are
* based, thus letting those object types to be used similarly and often interchangeably. As an
* abstract class, there is no such thing as a plain Node object. All objects that implement
* Node functionality are based on one of its subclasses. Most notable are Document, Element,
* and DocumentFragment.
*
* In addition, every kind of DOM node is represented by an interface based on Node. These
* include Attr, CharacterData (which Text, Comment, CDATASection and ProcessingInstruction are
* all based on), and DocumentType.
*
* In some cases, a particular feature of the base Node interface may not apply to one of its
* child interfaces; in that case, the inheriting node may return null or throw an exception,
* depending on circumstances. For example, attempting to add children to a node type that
* cannot have children will throw an exception.
*
* **This behavior is slightly different from the in the specs**:
* - unimplemented interfaces: EventTarget
*
* @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
* @see https://dom.spec.whatwg.org/#node
* @prettierignore
*/
interface Node {
/**
* Returns the children.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/childNodes)
*/
readonly childNodes: NodeList;
/**
* Returns the first child.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/firstChild)
*/
readonly firstChild: Node | null;
/**
* Returns the last child.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/lastChild)
*/
readonly lastChild: Node | null;
/**
* The local part of the qualified name of this node.
*/
localName: string | null;
/**
* Always returns `about:blank` currently.
*
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/baseURI)
*/
readonly baseURI: 'about:blank';
/**
* Returns true if this node is inside of a document or is the document node itself.
*
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected)
*/
readonly isConnected: boolean;
/**
* The namespace URI of this node.
*/
readonly namespaceURI: string | null;
/**
* Returns the next sibling.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)
*/
readonly nextSibling: Node | null;
/**
* Returns a string appropriate for the type of node.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nodeName)
*/
readonly nodeName: string;
/**
* Returns the type of node.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nodeType)
*/
readonly nodeType: number;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nodeValue) */
nodeValue: string | null;
/**
* Returns the node document. Returns null for documents.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/ownerDocument)
*/
readonly ownerDocument: Document | null;
/**
* Returns the parent.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/parentNode)
*/
readonly parentNode: Node | null;
/**
* Returns the parent `Node` if it is of type `Element`, otherwise `null`.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/parentElement)
*/
readonly parentElement: Element | null;
/**
* The prefix of the namespace for this node.
*/
prefix: string | null;
/**
* Returns the previous sibling.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/previousSibling)
*/
readonly previousSibling: Node | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/textContent) */
textContent: string | null;
/**
* Zero based line position inside the parsed source,
* if the `locator` was not disabled.
*/
lineNumber?: number;
/**
* One based column position inside the parsed source,
* if the `locator` was not disabled.
*/
columnNumber?: number;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/appendChild) */
appendChild(node: Node): Node;
/**
* Checks whether `other` is an inclusive descendant of this node.
*
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/contains)
*/
contains(other: Node | null | undefined): boolean;
/**
* Searches for the root node of this node.
*
* **This behavior is slightly different from the one in the specs**:
* - ignores `options.composed`, since `ShadowRoot`s are unsupported, therefore always
* returning root.
*
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/getRootNode)
*
* @see https://dom.spec.whatwg.org/#dom-node-getrootnode
* @see https://dom.spec.whatwg.org/#concept-shadow-including-root
*/
getRootNode(options: GetRootNodeOptions): Node;
/**
* Checks whether the given node is equal to this node.
*
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/isEqualNode)
*/
isEqualNode(other: Node): boolean;
/**
* Checks whether the given node is this node.
*
* [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/isSameNode)
*/
isSameNode(other: Node): boolean;
/**
* Returns a copy of node. If deep is true, the copy also includes the node's descendants.
*
* @throws {DOMException}
* May throw a DOMException if operations within {@link Element#setAttributeNode} or
* {@link Node#appendChild} (which are potentially invoked in this method) do not meet their
* specific constraints.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/cloneNode)
*/
cloneNode(deep?: boolean): Node;
/**
* Returns a bitmask indicating the position of other relative to node.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/compareDocumentPosition)
*/
compareDocumentPosition(other: Node): number;
/**
* Returns whether node has children.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/hasChildNodes)
*/
hasChildNodes(): boolean;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/insertBefore) */
insertBefore(node: Node, child: Node | null): Node;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/isDefaultNamespace) */
isDefaultNamespace(namespace: string | null): boolean;
/**
* Checks whether the DOM implementation implements a specific feature and its version.
*
* @deprecated
* Since `DOMImplementation.hasFeature` is deprecated and always returns true.
* @param feature
* The package name of the feature to test. This is the same name that can be passed to the
* method `hasFeature` on `DOMImplementation`.
* @param version
* This is the version number of the package name to test.
* @since Introduced in DOM Level 2
* @see {@link DOMImplementation.hasFeature}
*/
isSupported(feature: string, version: string): true;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/lookupNamespaceURI) */
lookupNamespaceURI(prefix: string | null): string | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/lookupPrefix) */
lookupPrefix(namespace: string | null): string | null;
/**
* Removes empty exclusive Text nodes and concatenates the data of remaining contiguous
* exclusive Text nodes into the first of their nodes.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/normalize)
*/
normalize(): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/removeChild) */
removeChild(child: Node): Node;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/replaceChild) */
replaceChild(node: Node, child: Node): Node;
/** node is an element. */
readonly ELEMENT_NODE: 1;
readonly ATTRIBUTE_NODE: 2;
/** node is a Text node. */
readonly TEXT_NODE: 3;
/** node is a CDATASection node. */
readonly CDATA_SECTION_NODE: 4;
readonly ENTITY_REFERENCE_NODE: 5;
readonly ENTITY_NODE: 6;
/** node is a ProcessingInstruction node. */
readonly PROCESSING_INSTRUCTION_NODE: 7;
/** node is a Comment node. */
readonly COMMENT_NODE: 8;
/** node is a document. */
readonly DOCUMENT_NODE: 9;
/** node is a doctype. */
readonly DOCUMENT_TYPE_NODE: 10;
/** node is a DocumentFragment node. */
readonly DOCUMENT_FRAGMENT_NODE: 11;
readonly NOTATION_NODE: 12;
/** Set when node and other are not in the same tree. */
readonly DOCUMENT_POSITION_DISCONNECTED: 0x01;
/** Set when other is preceding node. */
readonly DOCUMENT_POSITION_PRECEDING: 0x02;
/** Set when other is following node. */
readonly DOCUMENT_POSITION_FOLLOWING: 0x04;
/** Set when other is an ancestor of node. */
readonly DOCUMENT_POSITION_CONTAINS: 0x08;
/** Set when other is a descendant of node. */
readonly DOCUMENT_POSITION_CONTAINED_BY: 0x10;
readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 0x20;
}
var Node: InstanceOf<Node> & {
/** node is an element. */
readonly ELEMENT_NODE: 1;
readonly ATTRIBUTE_NODE: 2;
/** node is a Text node. */
readonly TEXT_NODE: 3;
/** node is a CDATASection node. */
readonly CDATA_SECTION_NODE: 4;
readonly ENTITY_REFERENCE_NODE: 5;
readonly ENTITY_NODE: 6;
/** node is a ProcessingInstruction node. */
readonly PROCESSING_INSTRUCTION_NODE: 7;
/** node is a Comment node. */
readonly COMMENT_NODE: 8;
/** node is a document. */
readonly DOCUMENT_NODE: 9;
/** node is a doctype. */
readonly DOCUMENT_TYPE_NODE: 10;
/** node is a DocumentFragment node. */
readonly DOCUMENT_FRAGMENT_NODE: 11;
readonly NOTATION_NODE: 12;
/** Set when node and other are not in the same tree. */
readonly DOCUMENT_POSITION_DISCONNECTED: 0x01;
/** Set when other is preceding node. */
readonly DOCUMENT_POSITION_PRECEDING: 0x02;
/** Set when other is following node. */
readonly DOCUMENT_POSITION_FOLLOWING: 0x04;
/** Set when other is an ancestor of node. */
readonly DOCUMENT_POSITION_CONTAINS: 0x08;
/** Set when other is a descendant of node. */
readonly DOCUMENT_POSITION_CONTAINED_BY: 0x10;
readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 0x20;
};
/**
* A DOM element's attribute as an object. In most DOM methods, you will probably directly
* retrieve the attribute as a string (e.g., Element.getAttribute(), but certain functions (e.g.,
* Element.getAttributeNode()) or means of iterating give Attr types.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr)
*/
interface Attr extends Node {
readonly nodeType: typeof Node.ATTRIBUTE_NODE;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/name) */
readonly name: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/namespaceURI) */
readonly namespaceURI: string | null;
readonly ownerDocument: Document;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/ownerElement) */
readonly ownerElement: Element | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/prefix) */
readonly prefix: string | null;
/**
* @deprecated
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/specified)
*/
readonly specified: true;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr/value) */
value: string;
}
/**
* A DOM element's attribute as an object. In most DOM methods, you will probably directly
* retrieve the attribute as a string (e.g., Element.getAttribute(), but certain functions (e.g.,
* Element.getAttributeNode()) or means of iterating give Attr types.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Attr)
*/
var Attr: InstanceOf<Attr>;
/**
* Objects implementing the NamedNodeMap interface are used to represent collections of nodes
* that can be accessed by name.
* Note that NamedNodeMap does not inherit from NodeList;
* NamedNodeMaps are not maintained in any particular order.
* Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal
* index,
* but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
* and does not imply that the DOM specifies an order to these Nodes.
* NamedNodeMap objects in the DOM are live.
* used for attributes or DocumentType entities
*
* This implementation only supports property indices, but does not support named properties,
* as specified in the living standard.
*
* @see https://dom.spec.whatwg.org/#interface-namednodemap
* @see https://webidl.spec.whatwg.org/#dfn-supported-property-names
*/
class NamedNodeMap implements Iterable<Attr> {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/length) */
readonly length: number;
/**
* Get an attribute by name. Note: Name is in lower case in case of HTML namespace and
* document.
*
* @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
*/
getNamedItem(qualifiedName: string): Attr | null;
/**
* Get an attribute by namespace and local name.
*
* @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
*/
getNamedItemNS(namespace: string | null, localName: string): Attr | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/NamedNodeMap/item) */
item(index: number): Attr | null;
/**
* Removes an attribute specified by the local name.
*
* @throws {DOMException}
* With code:
* - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given name is found.
* @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem
* @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name
*/
removeNamedItem(qualifiedName: string): Attr;
/**
* Removes an attribute specified by the namespace and local name.
*
* @throws {DOMException}
* With code:
* - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given namespace URI and
* local name is found.
* @see https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns
* @see https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace
*/
removeNamedItemNS(namespace: string | null, localName: string): Attr;
/**
* Set an attribute.
*
* @throws {DOMException}
* With code:
* - {@link INUSE_ATTRIBUTE_ERR} - If the attribute is already an attribute of another
* element.
* @see https://dom.spec.whatwg.org/#concept-element-attributes-set
*/
setNamedItem(attr: Attr): Attr | null;
/**
* Set an attribute, replacing an existing attribute with the same local name and namespace
* URI if one exists.
*
* @throws {DOMException}
* Throws a DOMException with the name "InUseAttributeError" if the attribute is already an
* attribute of another element.
* @see https://dom.spec.whatwg.org/#concept-element-attributes-set
*/
setNamedItemNS(attr: Attr): Attr | null;
[index: number]: Attr;
[Symbol.iterator](): Iterator<Attr>;
}
/**
* NodeList objects are collections of nodes, usually returned by properties such as
* Node.childNodes and methods such as document.querySelectorAll().
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeList)
*/
class NodeList<T extends Node = Node> implements Iterable<T> {
/**
* Returns the number of nodes in the collection.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeList/length)
*/
readonly length: number;
/**
* Returns the node with index index from the collection. The nodes are sorted in tree order.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeList/item)
*/
item(index: number): T | null;
/**
* Returns a string representation of the NodeList.
*/
toString(nodeFilter: (node: T) => T | undefined): string;
/**
* Filters the NodeList based on a predicate.
*
* @private
*/
filter(predicate: (node: T) => boolean): T[];
/**
* Returns the first index at which a given node can be found in the NodeList, or -1 if it is
* not present.
*
* @private
*/
indexOf(node: T): number;
/**
* Index based access returns `undefined`, when accessing indexes >= `length`.
* But it would break a lot of code (like `Array.from` usages),
* if it would be typed as `T | undefined`.
*/
[index: number]: T;
[Symbol.iterator](): Iterator<T>;
}
/**
* Represents a live collection of nodes that is automatically updated when its associated
* document changes.
*/
interface LiveNodeList<T extends Node = Node> extends NodeList<T> {}
/**
* Represents a live collection of nodes that is automatically updated when its associated
* document changes.
*/
var LiveNodeList: InstanceOf<LiveNodeList>;
/**
* Element is the most general base class from which all objects in a Document inherit. It only
* has methods and properties common to all kinds of elements. More specific classes inherit from
* Element.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element)
*/
interface Element extends Node {
readonly nodeType: typeof Node.ELEMENT_NODE;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/attributes) */
readonly attributes: NamedNodeMap;
/**
* Returns the HTML-uppercased qualified name.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/tagName)
*/
readonly tagName: string;
/**
* Returns element's first attribute whose qualified name is qualifiedName, and null if there
* is no such attribute otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttribute)
*/
getAttribute(qualifiedName: string): string | null;
/**
* Returns element's attribute whose namespace is namespace and local name is localName, and
* null if there is no such attribute otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNS)
*/
getAttributeNS(namespace: string | null, localName: string): string | null;
/**
* Returns the qualified names of all element's attributes. Can contain duplicates.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNames)
*/
getAttributeNames(): string[];
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNode) */
getAttributeNode(qualifiedName: string): Attr | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getAttributeNodeNS) */
getAttributeNodeNS(
namespace: string | null,
localName: string
): Attr | null;
/**
* Returns a LiveNodeList of all child elements which have **all** of the given class
* name(s).
*
* Returns an empty list if `classNames` is an empty string or only contains HTML white space
* characters.
*
* Warning: This returns a live LiveNodeList.
* Changes in the DOM will reflect in the array as the changes occur.
* If an element selected by this array no longer qualifies for the selector,
* it will automatically be removed. Be aware of this for iteration purposes.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName
* @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
*/
getElementsByClassName(classNames: string): LiveNodeList<Element>;
/**
* Returns a LiveNodeList of elements with the given qualifiedName.
* Searching for all descendants can be done by passing `*` as `qualifiedName`.
*
* All descendants of the specified element are searched, but not the element itself.
* The returned list is live, which means it updates itself with the DOM tree automatically.
* Therefore, there is no need to call `Element.getElementsByTagName()`
* with the same element and arguments repeatedly if the DOM changes in between calls.
*
* When called on an HTML element in an HTML document,
* `getElementsByTagName` lower-cases the argument before searching for it.
* This is undesirable when trying to match camel-cased SVG elements (such as
* `<linearGradient>`) in an HTML document.
* Instead, use `Element.getElementsByTagNameNS()`,
* which preserves the capitalization of the tag name.
*
* `Element.getElementsByTagName` is similar to `Document.getElementsByTagName()`,
* except that it only searches for elements that are descendants of the specified element.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName
* @see https://dom.spec.whatwg.org/#concept-getelementsbytagname
*/
getElementsByTagName(qualifiedName: string): LiveNodeList<Element>;
/**
* Returns a `LiveNodeList` of elements with the given tag name belonging to the given
* namespace. It is similar to `Document.getElementsByTagNameNS`, except that its search is
* restricted to descendants of the specified element.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getElementsByTagNameNS)
* */
getElementsByTagNameNS(
namespaceURI: string | null,
localName: string
): LiveNodeList<Element>;
getQualifiedName(): string;
/**
* Returns true if element has an attribute whose qualified name is qualifiedName, and false
* otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/hasAttribute)
*/
hasAttribute(qualifiedName: string): boolean;
/**
* Returns true if element has an attribute whose namespace is namespace and local name is
* localName.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/hasAttributeNS)
*/
hasAttributeNS(namespace: string | null, localName: string): boolean;
/**
* Returns true if element has attributes, and false otherwise.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/hasAttributes)
*/
hasAttributes(): boolean;
/**
* Removes element's first attribute whose qualified name is qualifiedName.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/removeAttribute)
*/
removeAttribute(qualifiedName: string): void;
/**
* Removes element's attribute whose namespace is namespace and local name is localName.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/removeAttributeNS)
*/
removeAttributeNS(namespace: string | null, localName: string): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/removeAttributeNode) */
removeAttributeNode(attr: Attr): Attr;
/**
* Sets the value of element's first attribute whose qualified name is qualifiedName to value.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttribute)
*/
setAttribute(qualifiedName: string, value: string): void;
/**
* Sets the value of element's attribute whose namespace is namespace and local name is
* localName to value.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNS)
*/
setAttributeNS(
namespace: string | null,
qualifiedName: string,
value: string
): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNode) */
setAttributeNode(attr: Attr): Attr | null;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/setAttributeNodeNS) */
setAttributeNodeNS(attr: Attr): Attr | null;
}
/**
* Element is the most general base class from which all objects in a Document inherit. It only
* has methods and properties common to all kinds of elements. More specific classes inherit from
* Element.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element)
*/
var Element: InstanceOf<Element>;
/**
* The CharacterData abstract interface represents a Node object that contains characters. This
* is an abstract interface, meaning there aren't any object of type CharacterData: it is
* implemented by other interfaces, like Text, Comment, or ProcessingInstruction which aren't
* abstract.
*
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData)
*/
interface CharacterData extends Node {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/data) */
data: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/length) */
readonly length: number;
readonly ownerDocument: Document;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/appendData) */
appendData(data: string): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/deleteData) */
deleteData(offset: number, count: number): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/insertData) */
insertData(offset: number, data: string): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/replaceData) */
replaceData(offset: number, count: number, data: string): void;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/substringData) */
substringData(offset: number, count: number): string;
}