@xmldom/xmldom 0.9.1 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,50 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.9.3](https://github.com/xmldom/xmldom/compare/0.9.2...0.9.3)
8
+
9
+ ### Fixed
10
+
11
+ - restore more `Node` and `ProcessingInstruction` types [`#725`](https://github.com/xmldom/xmldom/issues/725) / [`#726`](https://github.com/xmldom/xmldom/pull/726)
12
+ - `getElements*` methods return `LiveNodeList<Element>` [`#731`](https://github.com/xmldom/xmldom/issues/731) / [`#734`](https://github.com/xmldom/xmldom/pull/734)
13
+ - Add more missing `Node` props [`#728`](https://github.com/xmldom/xmldom/pull/728), triggered by unclosed [`#724`](https://github.com/xmldom/xmldom/pull/724)
14
+
15
+ ### Docs
16
+
17
+ - Update supported runtimes in readme (NodeJS >= 14.6 and other [ES5 compatible runtimes](https://compat-table.github.io/compat-table/es5/))
18
+
19
+ ### Chore
20
+
21
+ - updates devDependencies
22
+
23
+ Thank you,
24
+ [@Ponynjaa](https://github.com/Ponynjaa),
25
+ [@ayZagen](https://github.com/ayZagen),
26
+ [@sserdyuk](https://github.com/sserdyuk),
27
+ [@wydengyre](https://github.com/wydengyre),
28
+ [@mykola-mokhnach](https://github.com/mykola-mokhnach),
29
+ [@benkroeger](https://github.com/benkroeger),
30
+ for your contributions.
31
+
32
+ # Changelog
33
+
34
+ All notable changes to this project will be documented in this file.
35
+
36
+ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
37
+
38
+ ## [0.9.2](https://github.com/xmldom/xmldom/compare/0.9.1...0.9.2)
39
+
40
+ ### Feature
41
+
42
+ - add `Element.getElementsByClassName` [`#722`](https://github.com/xmldom/xmldom/pull/722)
43
+
44
+ ### Fixed
45
+
46
+ - add missing types for `Document.documentElement` and `Element.tagName` [`#721`](https://github.com/xmldom/xmldom/pull/721) [`#720`](https://github.com/xmldom/xmldom/issues/720)
47
+
48
+ Thank you, [@censujiang](https://github.com/censujiang), [@Mathias-S](https://github.com/Mathias-S), for your contributions
49
+
50
+
7
51
  ## [0.9.1](https://github.com/xmldom/xmldom/compare/0.9.0...0.9.1)
8
52
 
9
53
  ### Fixed
@@ -16,8 +60,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
16
60
 
17
61
  - minimum tested node version is 14 [`#710`](https://github.com/xmldom/xmldom/pull/710)
18
62
 
19
- Thank you, [@krystofwoldrich](https://github.com/krystofwoldrich), [@marvinruder](https://github.com/marvinruder),
20
- [@amacneil](https://github.com/amacneil), [@defunctzombie](https://github.com/defunctzombie),
63
+ Thank you, [@krystofwoldrich](https://github.com/krystofwoldrich), [@marvinruder](https://github.com/marvinruder), [@amacneil](https://github.com/amacneil), [@defunctzombie](https://github.com/defunctzombie),
21
64
  [@tjhorner](https://github.com/tjhorner), [@danon](https://github.com/danon), for your contributions
22
65
 
23
66
 
package/index.d.ts CHANGED
@@ -333,6 +333,11 @@ declare module '@xmldom/xmldom' {
333
333
  // instanceof post ts 5.3
334
334
  [Symbol.hasInstance](val: unknown): val is T;
335
335
  };
336
+
337
+ type GetRootNodeOptions = {
338
+ composed?: boolean;
339
+ };
340
+
336
341
  /**
337
342
  * The DOM Node interface is an abstract base class upon which many other DOM API objects are
338
343
  * based, thus letting those object types to be used similarly and often interchangeably. As an
@@ -350,8 +355,7 @@ declare module '@xmldom/xmldom' {
350
355
  * cannot have children will throw an exception.
351
356
  *
352
357
  * **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
358
+ * - unimplemented interfaces: EventTarget
355
359
  *
356
360
  * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
357
361
  * @see https://dom.spec.whatwg.org/#node
@@ -380,6 +384,18 @@ declare module '@xmldom/xmldom' {
380
384
  * The local part of the qualified name of this node.
381
385
  */
382
386
  localName: string | null;
387
+ /**
388
+ * Always returns `about:blank` currently.
389
+ *
390
+ * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/baseURI)
391
+ */
392
+ readonly baseURI: 'about:blank';
393
+ /**
394
+ * Returns true if this node is inside of a document or is the document node itself.
395
+ *
396
+ * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected)
397
+ */
398
+ readonly isConnected: boolean;
383
399
  /**
384
400
  * The namespace URI of this node.
385
401
  */
@@ -396,6 +412,12 @@ declare module '@xmldom/xmldom' {
396
412
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nodeName)
397
413
  */
398
414
  readonly nodeName: string;
415
+ /**
416
+ * Returns the type of node.
417
+ *
418
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nodeType)
419
+ */
420
+ readonly nodeType: number;
399
421
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/nodeValue) */
400
422
  nodeValue: string | null;
401
423
  /**
@@ -410,6 +432,12 @@ declare module '@xmldom/xmldom' {
410
432
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/parentNode)
411
433
  */
412
434
  readonly parentNode: Node | null;
435
+ /**
436
+ * Returns the parent `Node` if it is of type `Element`, otherwise `null`.
437
+ *
438
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/parentElement)
439
+ */
440
+ readonly parentElement: Element | null;
413
441
  /**
414
442
  * The prefix of the namespace for this node.
415
443
  */
@@ -420,10 +448,57 @@ declare module '@xmldom/xmldom' {
420
448
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/previousSibling)
421
449
  */
422
450
  readonly previousSibling: Node | null;
451
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/textContent) */
452
+ textContent: string | null;
453
+
454
+ /**
455
+ * Zero based line position inside the parsed source,
456
+ * if the `locator` was not disabled.
457
+ */
458
+ lineNumber?: number;
459
+ /**
460
+ * One based column position inside the parsed source,
461
+ * if the `locator` was not disabled.
462
+ */
463
+ columnNumber?: number;
423
464
 
424
465
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Node/appendChild) */
425
466
  appendChild(node: Node): Node;
426
467
 
468
+ /**
469
+ * Checks whether `other` is an inclusive descendant of this node.
470
+ *
471
+ * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/contains)
472
+ */
473
+ contains(other: Node | null | undefined): boolean;
474
+ /**
475
+ * Searches for the root node of this node.
476
+ *
477
+ * **This behavior is slightly different from the one in the specs**:
478
+ * - ignores `options.composed`, since `ShadowRoot`s are unsupported, therefore always
479
+ * returning root.
480
+ *
481
+ * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/getRootNode)
482
+ *
483
+ * @see https://dom.spec.whatwg.org/#dom-node-getrootnode
484
+ * @see https://dom.spec.whatwg.org/#concept-shadow-including-root
485
+ */
486
+ getRootNode(options: GetRootNodeOptions): Node;
487
+
488
+ /**
489
+ * Checks whether the given node is equal to this node.
490
+ *
491
+ * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/isEqualNode)
492
+ */
493
+ isEqualNode(other: Node): boolean;
494
+
495
+ /**
496
+ * Checks whether the given node is this node.
497
+ *
498
+ * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Node/isSameNode)
499
+ */
500
+ isSameNode(other: Node): boolean;
501
+
427
502
  /**
428
503
  * Returns a copy of node. If deep is true, the copy also includes the node's descendants.
429
504
  *
@@ -618,23 +693,12 @@ declare module '@xmldom/xmldom' {
618
693
  * Get an attribute by name. Note: Name is in lower case in case of HTML namespace and
619
694
  * document.
620
695
  *
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
696
  * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
626
697
  */
627
698
  getNamedItem(qualifiedName: string): Attr | null;
628
699
  /**
629
700
  * Get an attribute by namespace and local name.
630
701
  *
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
702
  * @see https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
639
703
  */
640
704
  getNamedItemNS(namespace: string | null, localName: string): Attr | null;
@@ -644,10 +708,6 @@ declare module '@xmldom/xmldom' {
644
708
  /**
645
709
  * Removes an attribute specified by the local name.
646
710
  *
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
711
  * @throws {DOMException}
652
712
  * With code:
653
713
  * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given name is found.
@@ -658,12 +718,6 @@ declare module '@xmldom/xmldom' {
658
718
  /**
659
719
  * Removes an attribute specified by the namespace and local name.
660
720
  *
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
721
  * @throws {DOMException}
668
722
  * With code:
669
723
  * - {@link DOMException.NOT_FOUND_ERR} if no attribute with the given namespace URI and
@@ -675,11 +729,6 @@ declare module '@xmldom/xmldom' {
675
729
  /**
676
730
  * Set an attribute.
677
731
  *
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
732
  * @throws {DOMException}
684
733
  * With code:
685
734
  * - {@link INUSE_ATTRIBUTE_ERR} - If the attribute is already an attribute of another
@@ -691,11 +740,6 @@ declare module '@xmldom/xmldom' {
691
740
  * Set an attribute, replacing an existing attribute with the same local name and namespace
692
741
  * URI if one exists.
693
742
  *
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
743
  * @throws {DOMException}
700
744
  * Throws a DOMException with the name "InUseAttributeError" if the attribute is already an
701
745
  * attribute of another element.
@@ -712,7 +756,7 @@ declare module '@xmldom/xmldom' {
712
756
  *
713
757
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeList)
714
758
  */
715
- class NodeList implements Iterable<Node> {
759
+ class NodeList<T extends Node = Node> implements Iterable<T> {
716
760
  /**
717
761
  * Returns the number of nodes in the collection.
718
762
  *
@@ -724,34 +768,40 @@ declare module '@xmldom/xmldom' {
724
768
  *
725
769
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/NodeList/item)
726
770
  */
727
- item(index: number): Node | null;
771
+ item(index: number): T | null;
728
772
  /**
729
773
  * Returns a string representation of the NodeList.
730
774
  */
731
- toString(nodeFilter: (node: Node) => Node | undefined): string;
775
+ toString(nodeFilter: (node: T) => T | undefined): string;
732
776
  /**
733
777
  * Filters the NodeList based on a predicate.
734
778
  *
735
779
  * @private
736
780
  */
737
- filter(predicate: (node: Node) => boolean): Node[];
781
+ filter(predicate: (node: T) => boolean): T[];
738
782
  /**
739
783
  * Returns the first index at which a given node can be found in the NodeList, or -1 if it is
740
784
  * not present.
741
785
  *
742
786
  * @private
743
787
  */
744
- indexOf(node: Node): number;
745
- [index: number]: Node | undefined;
788
+ indexOf(node: T): number;
789
+
790
+ /**
791
+ * Index based access returns `undefined`, when accessing indexes >= `length`.
792
+ * But it would break a lot of code (like `Array.from` usages),
793
+ * if it would be typed as `T | undefined`.
794
+ */
795
+ [index: number]: T;
746
796
 
747
- [Symbol.iterator](): Iterator<Node>;
797
+ [Symbol.iterator](): Iterator<T>;
748
798
  }
749
799
 
750
800
  /**
751
801
  * Represents a live collection of nodes that is automatically updated when its associated
752
802
  * document changes.
753
803
  */
754
- interface LiveNodeList extends NodeList {}
804
+ interface LiveNodeList<T extends Node = Node> extends NodeList<T> {}
755
805
  /**
756
806
  * Represents a live collection of nodes that is automatically updated when its associated
757
807
  * document changes.
@@ -770,6 +820,13 @@ declare module '@xmldom/xmldom' {
770
820
 
771
821
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/attributes) */
772
822
  readonly attributes: NamedNodeMap;
823
+ /**
824
+ * Returns the HTML-uppercased qualified name.
825
+ *
826
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/tagName)
827
+ */
828
+ readonly tagName: string;
829
+
773
830
  /**
774
831
  * Returns element's first attribute whose qualified name is qualifiedName, and null if there
775
832
  * is no such attribute otherwise.
@@ -797,7 +854,22 @@ declare module '@xmldom/xmldom' {
797
854
  namespace: string | null,
798
855
  localName: string
799
856
  ): Attr | null;
800
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/getBoundingClientRect) */
857
+ /**
858
+ * Returns a LiveNodeList of all child elements which have **all** of the given class
859
+ * name(s).
860
+ *
861
+ * Returns an empty list if `classNames` is an empty string or only contains HTML white space
862
+ * characters.
863
+ *
864
+ * Warning: This returns a live LiveNodeList.
865
+ * Changes in the DOM will reflect in the array as the changes occur.
866
+ * If an element selected by this array no longer qualifies for the selector,
867
+ * it will automatically be removed. Be aware of this for iteration purposes.
868
+ *
869
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName
870
+ * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
871
+ */
872
+ getElementsByClassName(classNames: string): LiveNodeList<Element>;
801
873
 
802
874
  /**
803
875
  * Returns a LiveNodeList of elements with the given qualifiedName.
@@ -821,7 +893,7 @@ declare module '@xmldom/xmldom' {
821
893
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName
822
894
  * @see https://dom.spec.whatwg.org/#concept-getelementsbytagname
823
895
  */
824
- getElementsByTagName(qualifiedName: string): LiveNodeList;
896
+ getElementsByTagName(qualifiedName: string): LiveNodeList<Element>;
825
897
 
826
898
  /**
827
899
  * Returns a `LiveNodeList` of elements with the given tag name belonging to the given
@@ -833,7 +905,7 @@ declare module '@xmldom/xmldom' {
833
905
  getElementsByTagNameNS(
834
906
  namespaceURI: string | null,
835
907
  localName: string
836
- ): LiveNodeList;
908
+ ): LiveNodeList<Element>;
837
909
 
838
910
  getQualifiedName(): string;
839
911
  /**
@@ -934,12 +1006,7 @@ declare module '@xmldom/xmldom' {
934
1006
  *
935
1007
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData)
936
1008
  */
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
- };
1009
+ var CharacterData: InstanceOf<CharacterData>;
943
1010
 
944
1011
  /**
945
1012
  * The textual content of Element or Attr. If an element has no markup within its content, it has
@@ -1037,8 +1104,20 @@ declare module '@xmldom/xmldom' {
1037
1104
  }
1038
1105
  var Notation: InstanceOf<Notation>;
1039
1106
 
1040
- interface ProcessingInstruction extends Node {
1107
+ interface ProcessingInstruction extends CharacterData {
1041
1108
  nodeType: typeof Node.PROCESSING_INSTRUCTION_NODE;
1109
+ /**
1110
+ * A string representing the textual data contained in this object.
1111
+ * For `ProcessingInstruction`, that means everything that goes after the `target`, excluding
1112
+ * `?>`.
1113
+ *
1114
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CharacterData/data)
1115
+ */
1116
+ data: string;
1117
+ /**
1118
+ * A string containing the name of the application.
1119
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ProcessingInstruction/target) */
1120
+ readonly target: string;
1042
1121
  }
1043
1122
  var ProcessingInstruction: InstanceOf<ProcessingInstruction>;
1044
1123
 
@@ -1059,7 +1138,6 @@ declare module '@xmldom/xmldom' {
1059
1138
  /**
1060
1139
  * The implementation that created this document.
1061
1140
  *
1062
- * @type DOMImplementation
1063
1141
  * @readonly
1064
1142
  */
1065
1143
  readonly implementation: DOMImplementation;
@@ -1067,13 +1145,16 @@ declare module '@xmldom/xmldom' {
1067
1145
  readonly nodeName: '#document';
1068
1146
  readonly nodeType: typeof Node.DOCUMENT_NODE;
1069
1147
  readonly doctype: DocumentType | null;
1148
+ /**
1149
+ * Gets a reference to the root node of the document.
1150
+ *
1151
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/documentElement)
1152
+ */
1153
+ readonly documentElement: Element | null;
1070
1154
 
1071
1155
  /**
1072
1156
  * Creates an attribute object with a specified name.
1073
1157
  *
1074
- * @param name
1075
- * String that sets the attribute object's name.
1076
- *
1077
1158
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createAttribute)
1078
1159
  */
1079
1160
  createAttribute(localName: string): Attr;
@@ -1091,9 +1172,6 @@ declare module '@xmldom/xmldom' {
1091
1172
  /**
1092
1173
  * Creates a comment object with the specified data.
1093
1174
  *
1094
- * @param data
1095
- * Sets the comment object's data.
1096
- *
1097
1175
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createComment)
1098
1176
  */
1099
1177
  createComment(data: string): Comment;
@@ -1105,7 +1183,6 @@ declare module '@xmldom/xmldom' {
1105
1183
  */
1106
1184
  createDocumentFragment(): DocumentFragment;
1107
1185
 
1108
-
1109
1186
  createElement(tagName: string): Element;
1110
1187
 
1111
1188
  /**
@@ -1128,10 +1205,24 @@ declare module '@xmldom/xmldom' {
1128
1205
  *
1129
1206
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/createElementNS)
1130
1207
  */
1131
- createElementNS(
1132
- namespace: string | null,
1133
- qualifiedName: string,
1134
- ): Element;
1208
+ createElementNS(namespace: string | null, qualifiedName: string): Element;
1209
+ /**
1210
+ * Creates an EntityReference object.
1211
+ * The current implementation does not fill the `childNodes` with those of the corresponding
1212
+ * `Entity`
1213
+ *
1214
+ * The name of the entity to reference. No namespace well-formedness checks are performed.
1215
+ *
1216
+ * @deprecated
1217
+ * In DOM Level 4.
1218
+ * @returns {EntityReference}
1219
+ * @throws {DOMException}
1220
+ * With code `INVALID_CHARACTER_ERR` when `name` is not valid.
1221
+ * @throws {DOMException}
1222
+ * with code `NOT_SUPPORTED_ERR` when the document is of type `html`
1223
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE
1224
+ */
1225
+ createEntityReference(name: string): EntityReference;
1135
1226
 
1136
1227
  /**
1137
1228
  * Returns a ProcessingInstruction node whose target is target and data is data. If target does
@@ -1158,31 +1249,25 @@ declare module '@xmldom/xmldom' {
1158
1249
 
1159
1250
  /**
1160
1251
  * 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
1252
  */
1165
1253
  getElementById(elementId: string): Element | null;
1166
1254
 
1167
1255
  /**
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).
1256
+ * Returns a LiveNodeList of all child elements which have **all** of the given class
1257
+ * name(s).
1170
1258
  *
1171
- * Returns an empty list if `classeNames` is an empty string or only contains HTML white
1172
- * space characters.
1259
+ * Returns an empty list if `classNames` is an empty string or only contains HTML white space
1260
+ * characters.
1173
1261
  *
1174
- * Warning: This is a live LiveNodeList.
1262
+ * Warning: This returns a live LiveNodeList.
1175
1263
  * Changes in the DOM will reflect in the array as the changes occur.
1176
1264
  * If an element selected by this array no longer qualifies for the selector,
1177
1265
  * it will automatically be removed. Be aware of this for iteration purposes.
1178
1266
  *
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
1267
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
1183
1268
  * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
1184
1269
  */
1185
- getElementsByClassName(classNames: string): LiveNodeList;
1270
+ getElementsByClassName(classNames: string): LiveNodeList<Element>;
1186
1271
 
1187
1272
  /**
1188
1273
  * Returns a LiveNodeList of elements with the given qualifiedName.
@@ -1206,7 +1291,7 @@ declare module '@xmldom/xmldom' {
1206
1291
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName
1207
1292
  * @see https://dom.spec.whatwg.org/#concept-getelementsbytagname
1208
1293
  */
1209
- getElementsByTagName(qualifiedName: string): LiveNodeList;
1294
+ getElementsByTagName(qualifiedName: string): LiveNodeList<Element>;
1210
1295
 
1211
1296
  /**
1212
1297
  * Returns a `LiveNodeList` of elements with the given tag name belonging to the given
@@ -1221,7 +1306,7 @@ declare module '@xmldom/xmldom' {
1221
1306
  getElementsByTagNameNS(
1222
1307
  namespaceURI: string | null,
1223
1308
  localName: string
1224
- ): LiveNodeList;
1309
+ ): LiveNodeList<Element>;
1225
1310
  /**
1226
1311
  * Returns a copy of node. If deep is true, the copy also includes the node's descendants.
1227
1312
  *
@@ -1347,7 +1432,6 @@ declare module '@xmldom/xmldom' {
1347
1432
  class XMLSerializer {
1348
1433
  serializeToString(node: Node, nodeFilter?: (node: Node) => boolean): string;
1349
1434
  }
1350
-
1351
1435
  // END ./lib/dom.js
1352
1436
 
1353
1437
  // START ./lib/dom-parser.js
package/lib/dom.js CHANGED
@@ -22,6 +22,7 @@ var PDC = Symbol();
22
22
 
23
23
  var errors = require('./errors');
24
24
  var DOMException = errors.DOMException;
25
+ var DOMExceptionName = errors.DOMExceptionName;
25
26
 
26
27
  var g = require('./grammar');
27
28
 
@@ -870,7 +871,7 @@ DOMImplementation.prototype = {
870
871
  * Creates an empty DocumentType node. Entity declarations and notations are not made
871
872
  * available. Entity reference expansions and default attribute additions do not occur.
872
873
  *
873
- * **This behavior is slightly different from the in the specs**:
874
+ * **This behavior is slightly different from the one in the specs**:
874
875
  * - `encoding`, `mode`, `origin`, `url` fields are currently not declared.
875
876
  * - `publicId` and `systemId` contain the raw data including any possible quotes,
876
877
  * so they can always be serialized back to the original value
@@ -919,6 +920,7 @@ DOMImplementation.prototype = {
919
920
  node.publicId = publicId || '';
920
921
  node.systemId = systemId || '';
921
922
  node.internalSubset = internalSubset || '';
923
+ node.childNodes = new NodeList();
922
924
 
923
925
  return node;
924
926
  },
@@ -979,8 +981,7 @@ DOMImplementation.prototype = {
979
981
  * cannot have children will throw an exception.
980
982
  *
981
983
  * **This behavior is slightly different from the in the specs**:
982
- * - undeclared properties: nodeType, baseURI, isConnected, parentElement, textContent
983
- * - missing methods: contains, getRootNode, isEqualNode, isSameNode
984
+ * - unimplemented interfaces: `EventTarget`
984
985
  *
985
986
  * @class
986
987
  * @abstract
@@ -1024,10 +1025,18 @@ Node.prototype = {
1024
1025
  * @type {Node | null}
1025
1026
  */
1026
1027
  parentNode: null,
1028
+ /**
1029
+ * The parent element of this node.
1030
+ *
1031
+ * @type {Element | null}
1032
+ */
1033
+ get parentElement() {
1034
+ return this.parentNode && this.parentNode.nodeType === this.ELEMENT_NODE ? this.parentNode : null;
1035
+ },
1027
1036
  /**
1028
1037
  * The child nodes of this node.
1029
1038
  *
1030
- * @type {NodeList | null}
1039
+ * @type {NodeList}
1031
1040
  */
1032
1041
  childNodes: null,
1033
1042
  /**
@@ -1060,6 +1069,131 @@ Node.prototype = {
1060
1069
  * @type {string | null}
1061
1070
  */
1062
1071
  localName: null,
1072
+ /**
1073
+ * The baseURI is currently always `about:blank`,
1074
+ * since that's what happens when you create a document from scratch.
1075
+ *
1076
+ * @type {'about:blank'}
1077
+ */
1078
+ baseURI: 'about:blank',
1079
+ /**
1080
+ * Is true if this node is part of a document.
1081
+ *
1082
+ * @type {boolean}
1083
+ */
1084
+ get isConnected() {
1085
+ var rootNode = this.getRootNode();
1086
+ return rootNode && rootNode.nodeType === rootNode.DOCUMENT_NODE;
1087
+ },
1088
+ /**
1089
+ * Checks whether `other` is an inclusive descendant of this node.
1090
+ *
1091
+ * @param {Node | null | undefined} other
1092
+ * The node to check.
1093
+ * @returns {boolean}
1094
+ * True if `other` is an inclusive descendant of this node; false otherwise.
1095
+ * @see https://dom.spec.whatwg.org/#dom-node-contains
1096
+ */
1097
+ contains: function (other) {
1098
+ if (!other) return false;
1099
+ var parent = other;
1100
+ do {
1101
+ if (this === parent) return true;
1102
+ parent = other.parentNode;
1103
+ } while (parent);
1104
+ return false;
1105
+ },
1106
+ /**
1107
+ * @typedef GetRootNodeOptions
1108
+ * @property {boolean} [composed=false]
1109
+ */
1110
+ /**
1111
+ * Searches for the root node of this node.
1112
+ *
1113
+ * **This behavior is slightly different from the in the specs**:
1114
+ * - ignores `options.composed`, since `ShadowRoot`s are unsupported, always returns root.
1115
+ *
1116
+ * @param {GetRootNodeOptions} [options]
1117
+ * @returns {Node}
1118
+ * Root node.
1119
+ * @see https://dom.spec.whatwg.org/#dom-node-getrootnode
1120
+ * @see https://dom.spec.whatwg.org/#concept-shadow-including-root
1121
+ */
1122
+ getRootNode: function (options) {
1123
+ var parent = this;
1124
+ do {
1125
+ if (!parent.parentNode) {
1126
+ return parent;
1127
+ }
1128
+ parent = parent.parentNode;
1129
+ } while (parent);
1130
+ },
1131
+ /**
1132
+ * Checks whether the given node is equal to this node.
1133
+ *
1134
+ * @param {Node} [otherNode]
1135
+ * @see https://dom.spec.whatwg.org/#concept-node-equals
1136
+ */
1137
+ isEqualNode: function (otherNode) {
1138
+ if (!otherNode) return false;
1139
+
1140
+ if (this.nodeType !== otherNode.nodeType) return false;
1141
+
1142
+ switch (this.nodeType) {
1143
+ case this.DOCUMENT_TYPE_NODE:
1144
+ if (this.name !== otherNode.name) return false;
1145
+ if (this.publicId !== otherNode.publicId) return false;
1146
+ if (this.systemId !== otherNode.systemId) return false;
1147
+ break;
1148
+ case this.ELEMENT_NODE:
1149
+ if (this.namespaceURI !== otherNode.namespaceURI) return false;
1150
+ if (this.prefix !== otherNode.prefix) return false;
1151
+ if (this.localName !== otherNode.localName) return false;
1152
+ if (this.attributes.length !== otherNode.attributes.length) return false;
1153
+ for (var i = 0; i < this.attributes.length; i++) {
1154
+ var attr = this.attributes.item(i);
1155
+ if (!attr.isEqualNode(otherNode.getAttributeNodeNS(attr.namespaceURI, attr.localName))) {
1156
+ return false;
1157
+ }
1158
+ }
1159
+ break;
1160
+ case this.ATTRIBUTE_NODE:
1161
+ if (this.namespaceURI !== otherNode.namespaceURI) return false;
1162
+ if (this.localName !== otherNode.localName) return false;
1163
+ if (this.value !== otherNode.value) return false;
1164
+
1165
+ break;
1166
+ case this.PROCESSING_INSTRUCTION_NODE:
1167
+ if (this.target !== otherNode.target || this.data !== otherNode.data) {
1168
+ return false;
1169
+ }
1170
+ break;
1171
+ case this.TEXT_NODE:
1172
+ case this.COMMENT_NODE:
1173
+ if (this.data !== otherNode.data) return false;
1174
+ break;
1175
+ }
1176
+
1177
+ if (this.childNodes.length !== otherNode.childNodes.length) {
1178
+ return false;
1179
+ }
1180
+
1181
+ for (var i = 0; i < this.childNodes.length; i++) {
1182
+ if (!this.childNodes[i].isEqualNode(otherNode.childNodes[i])) {
1183
+ return false;
1184
+ }
1185
+ }
1186
+
1187
+ return true;
1188
+ },
1189
+ /**
1190
+ * Checks whether or not the given node is this node.
1191
+ *
1192
+ * @param {Node} [otherNode]
1193
+ */
1194
+ isSameNode: function (otherNode) {
1195
+ return this === otherNode;
1196
+ },
1063
1197
  /**
1064
1198
  * Inserts a node before a reference node as a child of this node.
1065
1199
  *
@@ -1545,7 +1679,6 @@ function _removeChild(parentNode, child) {
1545
1679
  if (parentNode !== child.parentNode) {
1546
1680
  throw new DOMException(DOMException.NOT_FOUND_ERR, "child's parent is not parent");
1547
1681
  }
1548
- //var index = parentNode.childNodes.
1549
1682
  var oldPreviousSibling = child.previousSibling;
1550
1683
  var oldNextSibling = child.nextSibling;
1551
1684
  if (oldPreviousSibling) {
@@ -1587,12 +1720,13 @@ function hasValidParentNodeType(node) {
1587
1720
  function hasInsertableNodeType(node) {
1588
1721
  return (
1589
1722
  node &&
1590
- (isElementNode(node) ||
1591
- node instanceof CharacterData ||
1592
- isDocTypeNode(node) ||
1593
- node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||
1723
+ (node.nodeType === Node.CDATA_SECTION_NODE ||
1594
1724
  node.nodeType === Node.COMMENT_NODE ||
1595
- node.nodeType === Node.PROCESSING_INSTRUCTION_NODE)
1725
+ node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||
1726
+ node.nodeType === Node.DOCUMENT_TYPE_NODE ||
1727
+ node.nodeType === Node.ELEMENT_NODE ||
1728
+ node.nodeType === Node.PROCESSING_INSTRUCTION_NODE ||
1729
+ node.nodeType === Node.TEXT_NODE)
1596
1730
  );
1597
1731
  }
1598
1732
 
@@ -1921,10 +2055,10 @@ function _insertBefore(parent, node, child, _inDocumentAssertion) {
1921
2055
  newFirst.parentNode = parent;
1922
2056
  } while (newFirst !== newLast && (newFirst = newFirst.nextSibling));
1923
2057
  _onUpdateChild(parent.ownerDocument || parent, parent);
1924
- //console.log(parent.lastChild.nextSibling == null)
1925
2058
  if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
1926
2059
  node.firstChild = node.lastChild = null;
1927
2060
  }
2061
+
1928
2062
  return node;
1929
2063
  }
1930
2064
 
@@ -2003,51 +2137,6 @@ Document.prototype = {
2003
2137
  return rtv;
2004
2138
  },
2005
2139
 
2006
- /**
2007
- * The `getElementsByClassName` method of `Document` interface returns an array-like object of
2008
- * all child elements which have **all** of the given class name(s).
2009
- *
2010
- * Returns an empty list if `classeNames` is an empty string or only contains HTML white space
2011
- * characters.
2012
- *
2013
- * Warning: This is a live LiveNodeList.
2014
- * Changes in the DOM will reflect in the array as the changes occur.
2015
- * If an element selected by this array no longer qualifies for the selector,
2016
- * it will automatically be removed. Be aware of this for iteration purposes.
2017
- *
2018
- * @param {string} classNames
2019
- * Is a string representing the class name(s) to match; multiple class names are separated by
2020
- * (ASCII-)whitespace.
2021
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
2022
- * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
2023
- */
2024
- getElementsByClassName: function (classNames) {
2025
- var classNamesSet = toOrderedSet(classNames);
2026
- return new LiveNodeList(this, function (base) {
2027
- var ls = [];
2028
- if (classNamesSet.length > 0) {
2029
- _visitNode(base.documentElement, function (node) {
2030
- if (node !== base && node.nodeType === ELEMENT_NODE) {
2031
- var nodeClassNames = node.getAttribute('class');
2032
- // can be null if the attribute does not exist
2033
- if (nodeClassNames) {
2034
- // before splitting and iterating just compare them for the most common case
2035
- var matches = classNames === nodeClassNames;
2036
- if (!matches) {
2037
- var nodeClassNamesSet = toOrderedSet(nodeClassNames);
2038
- matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
2039
- }
2040
- if (matches) {
2041
- ls.push(node);
2042
- }
2043
- }
2044
- }
2045
- });
2046
- }
2047
- return ls;
2048
- });
2049
- },
2050
-
2051
2140
  /**
2052
2141
  * Creates a new `Element` that is owned by this `Document`.
2053
2142
  * In HTML Documents `localName` is the lower cased `tagName`,
@@ -2083,33 +2172,57 @@ Document.prototype = {
2083
2172
  attrs._ownerElement = node;
2084
2173
  return node;
2085
2174
  },
2175
+ /**
2176
+ * @returns {DocumentFragment}
2177
+ */
2086
2178
  createDocumentFragment: function () {
2087
2179
  var node = new DocumentFragment(PDC);
2088
2180
  node.ownerDocument = this;
2089
2181
  node.childNodes = new NodeList();
2090
2182
  return node;
2091
2183
  },
2184
+ /**
2185
+ * @param {string} data
2186
+ * @returns {Text}
2187
+ */
2092
2188
  createTextNode: function (data) {
2093
2189
  var node = new Text(PDC);
2094
2190
  node.ownerDocument = this;
2191
+ node.childNodes = new NodeList();
2095
2192
  node.appendData(data);
2096
2193
  return node;
2097
2194
  },
2195
+ /**
2196
+ * @param {string} data
2197
+ * @returns {Comment}
2198
+ */
2098
2199
  createComment: function (data) {
2099
2200
  var node = new Comment(PDC);
2100
2201
  node.ownerDocument = this;
2202
+ node.childNodes = new NodeList();
2101
2203
  node.appendData(data);
2102
2204
  return node;
2103
2205
  },
2206
+ /**
2207
+ * @param {string} data
2208
+ * @returns {CDATASection}
2209
+ */
2104
2210
  createCDATASection: function (data) {
2105
2211
  var node = new CDATASection(PDC);
2106
2212
  node.ownerDocument = this;
2213
+ node.childNodes = new NodeList();
2107
2214
  node.appendData(data);
2108
2215
  return node;
2109
2216
  },
2217
+ /**
2218
+ * @param {string} target
2219
+ * @param {string} data
2220
+ * @returns {ProcessingInstruction}
2221
+ */
2110
2222
  createProcessingInstruction: function (target, data) {
2111
2223
  var node = new ProcessingInstruction(PDC);
2112
2224
  node.ownerDocument = this;
2225
+ node.childNodes = new NodeList();
2113
2226
  node.nodeName = node.target = target;
2114
2227
  node.nodeValue = node.data = data;
2115
2228
  return node;
@@ -2140,19 +2253,49 @@ Document.prototype = {
2140
2253
  _createAttribute: function (name) {
2141
2254
  var node = new Attr(PDC);
2142
2255
  node.ownerDocument = this;
2256
+ node.childNodes = new NodeList();
2143
2257
  node.name = name;
2144
2258
  node.nodeName = name;
2145
2259
  node.localName = name;
2146
2260
  node.specified = true;
2147
2261
  return node;
2148
2262
  },
2263
+ /**
2264
+ * Creates an EntityReference object.
2265
+ * The current implementation does not fill the `childNodes` with those of the corresponding
2266
+ * `Entity`
2267
+ *
2268
+ * @deprecated
2269
+ * In DOM Level 4.
2270
+ * @param {string} name
2271
+ * The name of the entity to reference. No namespace well-formedness checks are performed.
2272
+ * @returns {EntityReference}
2273
+ * @throws {DOMException}
2274
+ * With code `INVALID_CHARACTER_ERR` when `name` is not valid.
2275
+ * @throws {DOMException}
2276
+ * with code `NOT_SUPPORTED_ERR` when the document is of type `html`
2277
+ * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-392B75AE
2278
+ */
2149
2279
  createEntityReference: function (name) {
2280
+ if (!g.Name.test(name)) {
2281
+ throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 'not a valid xml name "' + name + '"');
2282
+ }
2283
+ if (this.type === 'html') {
2284
+ throw new DOMException('document is an html document', DOMExceptionName.NotSupportedError);
2285
+ }
2286
+
2150
2287
  var node = new EntityReference(PDC);
2151
2288
  node.ownerDocument = this;
2289
+ node.childNodes = new NodeList();
2152
2290
  node.nodeName = name;
2153
2291
  return node;
2154
2292
  },
2155
2293
  // Introduced in DOM Level 2:
2294
+ /**
2295
+ * @param {string} namespaceURI
2296
+ * @param {string} qualifiedName
2297
+ * @returns {Element}
2298
+ */
2156
2299
  createElementNS: function (namespaceURI, qualifiedName) {
2157
2300
  var validated = validateAndExtract(namespaceURI, qualifiedName);
2158
2301
  var node = new Element(PDC);
@@ -2168,10 +2311,16 @@ Document.prototype = {
2168
2311
  return node;
2169
2312
  },
2170
2313
  // Introduced in DOM Level 2:
2314
+ /**
2315
+ * @param {string} namespaceURI
2316
+ * @param {string} qualifiedName
2317
+ * @returns {Attr}
2318
+ */
2171
2319
  createAttributeNS: function (namespaceURI, qualifiedName) {
2172
2320
  var validated = validateAndExtract(namespaceURI, qualifiedName);
2173
2321
  var node = new Attr(PDC);
2174
2322
  node.ownerDocument = this;
2323
+ node.childNodes = new NodeList();
2175
2324
  node.nodeName = qualifiedName;
2176
2325
  node.name = qualifiedName;
2177
2326
  node.specified = true;
@@ -2302,6 +2451,51 @@ Element.prototype = {
2302
2451
  return this.attributes.getNamedItemNS(namespaceURI, localName);
2303
2452
  },
2304
2453
 
2454
+ /**
2455
+ * Returns a LiveNodeList of all child elements which have **all** of the given class name(s).
2456
+ *
2457
+ * Returns an empty list if `classNames` is an empty string or only contains HTML white space
2458
+ * characters.
2459
+ *
2460
+ * Warning: This returns a live LiveNodeList.
2461
+ * Changes in the DOM will reflect in the array as the changes occur.
2462
+ * If an element selected by this array no longer qualifies for the selector,
2463
+ * it will automatically be removed. Be aware of this for iteration purposes.
2464
+ *
2465
+ * @param {string} classNames
2466
+ * Is a string representing the class name(s) to match; multiple class names are separated by
2467
+ * (ASCII-)whitespace.
2468
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByClassName
2469
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
2470
+ * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
2471
+ */
2472
+ getElementsByClassName: function (classNames) {
2473
+ var classNamesSet = toOrderedSet(classNames);
2474
+ return new LiveNodeList(this, function (base) {
2475
+ var ls = [];
2476
+ if (classNamesSet.length > 0) {
2477
+ _visitNode(base, function (node) {
2478
+ if (node !== base && node.nodeType === ELEMENT_NODE) {
2479
+ var nodeClassNames = node.getAttribute('class');
2480
+ // can be null if the attribute does not exist
2481
+ if (nodeClassNames) {
2482
+ // before splitting and iterating just compare them for the most common case
2483
+ var matches = classNames === nodeClassNames;
2484
+ if (!matches) {
2485
+ var nodeClassNamesSet = toOrderedSet(nodeClassNames);
2486
+ matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet));
2487
+ }
2488
+ if (matches) {
2489
+ ls.push(node);
2490
+ }
2491
+ }
2492
+ }
2493
+ });
2494
+ }
2495
+ return ls;
2496
+ });
2497
+ },
2498
+
2305
2499
  /**
2306
2500
  * Returns a LiveNodeList of elements with the given qualifiedName.
2307
2501
  * Searching for all descendants can be done by passing `*` as `qualifiedName`.
@@ -2365,6 +2559,7 @@ Element.prototype = {
2365
2559
  });
2366
2560
  },
2367
2561
  };
2562
+ Document.prototype.getElementsByClassName = Element.prototype.getElementsByClassName;
2368
2563
  Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
2369
2564
  Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
2370
2565
 
@@ -2480,7 +2675,7 @@ function ProcessingInstruction(symbol) {
2480
2675
  checkSymbol(symbol);
2481
2676
  }
2482
2677
  ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
2483
- _extends(ProcessingInstruction, Node);
2678
+ _extends(ProcessingInstruction, CharacterData);
2484
2679
  function XMLSerializer() {}
2485
2680
  XMLSerializer.prototype.serializeToString = function (node, nodeFilter) {
2486
2681
  return nodeSerializeToString.call(node, nodeFilter);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmldom/xmldom",
3
- "version": "0.9.1",
3
+ "version": "0.9.3",
4
4
  "description": "A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.",
5
5
  "keywords": [
6
6
  "w3c",
@@ -40,22 +40,22 @@
40
40
  "release": "np --no-yarn --test-script testrelease"
41
41
  },
42
42
  "engines": {
43
- "node": ">=14.0.0"
43
+ "node": ">=14.6"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@homer0/prettier-plugin-jsdoc": "9.0.2",
47
47
  "@jazzer.js/core": "2.1.0",
48
48
  "@jazzer.js/jest-runner": "2.1.0",
49
- "auto-changelog": "2.4.0",
50
- "eslint": "8.57.0",
49
+ "auto-changelog": "2.5.0",
50
+ "eslint": "8.57.1",
51
51
  "eslint-config-prettier": "9.1.0",
52
52
  "eslint-plugin-anti-trojan-source": "1.1.1",
53
53
  "eslint-plugin-es5": "1.5.0",
54
- "eslint-plugin-n": "17.10.2",
54
+ "eslint-plugin-n": "17.10.3",
55
55
  "eslint-plugin-prettier": "5.2.1",
56
56
  "get-stream": "6.0.1",
57
57
  "jest": "29.7.0",
58
- "nodemon": "3.1.4",
58
+ "nodemon": "3.1.5",
59
59
  "np": "8.0.4",
60
60
  "prettier": "3.3.3",
61
61
  "rxjs": "7.8.1",
package/readme.md CHANGED
@@ -34,7 +34,7 @@ xmldom is a javascript [ponyfill](https://ponyfill.com/) to provide the followin
34
34
  new XMLSerializer().serializeToString(node) => string
35
35
  ```
36
36
 
37
- The target runtimes `xmldom` supports are currently Node >= v10 (ES5) and Rhino ([not tested as part of CI](https://github.com/xmldom/xmldom/discussions/214)).
37
+ The target runtimes `xmldom` supports are currently Node >= v14.6 (and very likely any other [ES5 compatible runtime](https://compat-table.github.io/compat-table/es5/)).
38
38
 
39
39
  When deciding how to fix bugs or implement features, `xmldom` tries to stay as close as possible to the various [related specifications/standards](#specs).
40
40
  As indicated by the version starting with `0.`, this implementation is not feature complete and some implemented features differ from what the specifications describe.
@@ -99,7 +99,7 @@ import { DOMParser } from '@xmldom/xmldom'
99
99
  readonly class properties (aka `NodeType`),
100
100
  these can be accessed from any `Node` instance `node`:
101
101
  `if (node.nodeType === node.ELEMENT_NODE) {...`
102
-
102
+
103
103
  1. `ELEMENT_NODE` (`1`)
104
104
  2. `ATTRIBUTE_NODE` (`2`)
105
105
  3. `TEXT_NODE` (`3`)
@@ -112,14 +112,14 @@ import { DOMParser } from '@xmldom/xmldom'
112
112
  10. `DOCUMENT_TYPE_NODE` (`10`)
113
113
  11. `DOCUMENT_FRAGMENT_NODE` (`11`)
114
114
  12. `NOTATION_NODE` (`12`)
115
-
115
+
116
116
  attribute:
117
- - `nodeValue` | `prefix`
118
-
117
+ - `nodeValue` | `prefix` | `textContent`
118
+
119
119
  readonly attribute:
120
- - `nodeName` | `nodeType` | `parentNode` | `childNodes` | `firstChild` | `lastChild` | `previousSibling` | `nextSibling` | `attributes` | `ownerDocument` | `namespaceURI` | `localName`
121
-
122
- method:
120
+ - `nodeName` | `nodeType` | `parentNode` | `parentElement` | `childNodes` | `firstChild` | `lastChild` | `previousSibling` | `nextSibling` | `attributes` | `ownerDocument` | `namespaceURI` | `localName` | `isConnected` | `baseURI`
121
+
122
+ method:
123
123
  * `insertBefore(newChild, refChild)`
124
124
  * `replaceChild(newChild, oldChild)`
125
125
  * `removeChild(oldChild)`
@@ -127,6 +127,10 @@ import { DOMParser } from '@xmldom/xmldom'
127
127
  * `hasChildNodes()`
128
128
  * `cloneNode(deep)`
129
129
  * `normalize()`
130
+ * `contains(otherNode)`
131
+ * `getRootNode()`
132
+ * `isEqualNode(otherNode)`
133
+ * `isSameNode(otherNode)`
130
134
  * `isSupported(feature, version)`
131
135
  * `hasAttributes()`
132
136
  * [DOMException](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html)
@@ -149,7 +153,7 @@ import { DOMParser } from '@xmldom/xmldom'
149
153
  - `INVALID_MODIFICATION_ERR` (`13`)
150
154
  - `NAMESPACE_ERR` (`14`)
151
155
  - `INVALID_ACCESS_ERR` (`15`)
152
-
156
+
153
157
  attributes:
154
158
  - `code` with a value matching one of the above constants.
155
159
 
@@ -183,7 +187,7 @@ import { DOMParser } from '@xmldom/xmldom'
183
187
 
184
188
  * [DocumentFragment](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-B63ED1A3) : Node
185
189
  * [Element](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-745549614) : Node
186
-
190
+
187
191
  readonly attribute:
188
192
  - `tagName`
189
193
 
@@ -317,23 +321,23 @@ The original author claims that xmldom implements [DOM Level 2] in a "fully comp
317
321
  In the past, there have been multiple (even breaking) changes to align xmldom with the living standard,
318
322
  so if you find a difference that is not documented, any contribution to resolve the difference is very welcome (even just reporting it as an issue).
319
323
 
320
- xmldom implements the following interfaces (only the ones marked with `*` are currently exposed):
321
- - `Attr` *
324
+ xmldom implements the following interfaces:
325
+ - `Attr`
322
326
  - `CDATASection`
323
327
  - `CharacterData`
324
328
  - `Comment`
325
- - `Document` *
329
+ - `Document`
326
330
  - `DocumentFragment`
327
- - `DocumentType` *
328
- - `DOMException` *
329
- - `DOMImplementation` *
330
- - `Element` *
331
+ - `DocumentType`
332
+ - `DOMException`
333
+ - `DOMImplementation`
334
+ - `Element`
331
335
  - `Entity`
332
336
  - `EntityReference`
333
337
  - `LiveNodeList`
334
- - `NamedNodeMap` *
335
- - `Node` *
336
- - `NodeList` *
338
+ - `NamedNodeMap`
339
+ - `Node`
340
+ - `NodeList`
337
341
  - `Notation`
338
342
  - `ProcessingInstruction`
339
343
  - `Text`