@xmldom/xmldom 0.7.5 → 0.8.2

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,54 @@ 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.8.2](https://github.com/xmldom/xmldom/compare/0.8.1...0.8.2)
8
+
9
+ ### Fixed
10
+ - fix(dom): Serialize `>` as specified (#395) [`#58`](https://github.com/xmldom/xmldom/issues/58)
11
+
12
+ ### Other
13
+ - docs: Add `nodeType` values to public interface description [`#396`](https://github.com/xmldom/xmldom/pull/396)
14
+ - test: Add executable examples for node and typescript [`#317`](https://github.com/xmldom/xmldom/pull/317)
15
+ - fix(dom): Serialize `>` as specified [`#395`](https://github.com/xmldom/xmldom/pull/395)
16
+ - chore: Add minimal `Object.assign` ponyfill [`#379`](https://github.com/xmldom/xmldom/pull/379)
17
+ - docs: Refine release documentation [`#378`](https://github.com/xmldom/xmldom/pull/378)
18
+ - chore: update various dev dependencies
19
+
20
+ Thank you [@niklasl](https://github.com/niklasl), [@cburatto](https://github.com/cburatto), [@SheetJSDev](https://github.com/SheetJSDev), [@pyrsmk](https://github.com/pyrsmk) for your contributions
21
+
22
+ ## [0.8.1](https://github.com/xmldom/xmldom/compare/0.8.0...0.8.1)
23
+
24
+ ### Fixes
25
+ - Only use own properties in entityMap [`#374`](https://github.com/xmldom/xmldom/pull/374)
26
+
27
+ ### Docs
28
+ - Add security policy [`#365`](https://github.com/xmldom/xmldom/pull/365)
29
+ - changelog: Correct contributor name and link [`#366`](https://github.com/xmldom/xmldom/pull/366)
30
+ - Describe release/publish steps [`#358`](https://github.com/xmldom/xmldom/pull/358), [`#376`](https://github.com/xmldom/xmldom/pull/376)
31
+ - Add snyk package health badge [`#360`](https://github.com/xmldom/xmldom/pull/360)
32
+
33
+
34
+ ## [0.8.0](https://github.com/xmldom/xmldom/compare/0.7.5...0.8.0)
35
+
36
+ ### Fixed
37
+ - Normalize all line endings according to XML specs [1.0](https://w3.org/TR/xml/#sec-line-ends) and [1.1](https://www.w3.org/TR/xml11/#sec-line-ends) \
38
+ BREAKING CHANGE: Certain combination of line break characters are normalized to a single `\n` before parsing takes place and will no longer be preserved.
39
+ - [`#303`](https://github.com/xmldom/xmldom/issues/303) / [`#307`](https://github.com/xmldom/xmldom/pull/307)
40
+ - [`#49`](https://github.com/xmldom/xmldom/issues/49), [`#97`](https://github.com/xmldom/xmldom/issues/97), [`#324`](https://github.com/xmldom/xmldom/issues/324) / [`#314`](https://github.com/xmldom/xmldom/pull/314)
41
+ - XMLSerializer: Preserve whitespace character references [`#284`](https://github.com/xmldom/xmldom/issues/284) / [`#310`](https://github.com/xmldom/xmldom/pull/310) \
42
+ BREAKING CHANGE: If you relied on the not spec compliant preservation of literal `\t`, `\n` or `\r` in **attribute values**.
43
+ To preserve those you will have to create XML that instead contains the correct numerical (or hexadecimal) equivalent (e.g. `	`, `
`, `
`).
44
+ - Drop deprecated exports `DOMImplementation` and `XMLSerializer` from `lib/dom-parser.js` [#53](https://github.com/xmldom/xmldom/issues/53) / [`#309`](https://github.com/xmldom/xmldom/pull/309)
45
+ BREAKING CHANGE: Use the one provided by the main package export.
46
+ - dom: Remove all links as part of `removeChild` [`#343`](https://github.com/xmldom/xmldom/issues/343) / [`#355`](https://github.com/xmldom/xmldom/pull/355)
47
+
48
+ ### Chore
49
+ - ci: Restore latest tested node version to 16.x [`#325`](https://github.com/xmldom/xmldom/pull/325)
50
+ - ci: Split test and lint steps into jobs [`#111`](https://github.com/xmldom/xmldom/issues/111) / [`#304`](https://github.com/xmldom/xmldom/pull/304)
51
+ - Pinned and updated devDependencies
52
+
53
+ Thank you [@marrus-sh](https://github.com/marrus-sh), [@victorandree](https://github.com/victorandree), [@mdierolf](https://github.com/mdierolf), [@tsabbay](https://github.com/tsabbay), [@fatihpense](https://github.com/fatihpense) for your contributions
54
+
7
55
  ## 0.7.5
8
56
 
9
57
  [Commits](https://github.com/xmldom/xmldom/compare/0.7.4...0.7.5)
@@ -20,7 +68,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
20
68
  ### Fixes:
21
69
 
22
70
  - Restore ability to parse `__prototype__` attributes [`#315`](https://github.com/xmldom/xmldom/pull/315)
23
- Thank you [@dsimsonOMF](https://github.com/dsimsonOMF)
71
+ Thank you [@dsimpsonOMF](https://github.com/dsimpsonOMF)
24
72
 
25
73
  ## 0.7.3
26
74
 
package/SECURITY.md ADDED
@@ -0,0 +1,50 @@
1
+ # Security Policy
2
+
3
+ The most up-to-date version of this document can be found at <https://github.com/xmldom/xmldom/security/policy>.
4
+
5
+ ## Supported Versions
6
+
7
+ This repository contains the code for the libraries `xmldom` and `@xmldom/xmldom` on npm.
8
+
9
+ As long as we didn't publish v1, we aim to maintain the last two minor versions with security fixes. If it is possible we provide security fixes as path versions.
10
+ If you think there is a good reason to also patch an earlier version let us know in a github issue or the release discussion once the fix has been provided.
11
+ The maintainers will consider it and if we agree and have/find the required resources, a patch for that version will be provided.
12
+
13
+ Please notice that [we are no longer able to publish the (unscoped) `xmldom` package](https://github.com/xmldom/xmldom/issues/271),
14
+ and that all existing versions of `xmldom` are affected by at least one security vulnerability and should be considered deprecated.
15
+ You can still report issues regarding `xmldom` as described below.
16
+
17
+ If you need help with migrating from `xmldom` to `@xmldom/xmldom`, file a github issue or PR in the affected repository and mention @karfau.
18
+
19
+ ## Reporting vulnerabilities
20
+
21
+ Please email reports about any security related issues you find to `security@xmldom.org`, which will forward it to the list of maintainers.
22
+ The maintainers will try to respond within 7 calendar days. (If nobody peplies after 7 days, please us send a reminder!)
23
+ As part of you communication please make sure to always hit "Reply all", so all maintainers are kept in the loop.
24
+
25
+ In addition, please include the following information along with your report:
26
+
27
+ - Your name and affiliation (if any).
28
+ - A description of the technical details of the vulnerabilities. It is very important to let us know how we can reproduce your findings.
29
+ - An explanation who can exploit this vulnerability, and what they gain when doing so -- write an attack scenario. This will help us evaluate your report quickly, especially if the issue is complex.
30
+ - Whether this vulnerability public or known to third parties. If it is, please provide details.
31
+
32
+ If you believe that an existing (public) issue is security-related, please send an email to `security@xmldom.org`.
33
+ The email should include the issue URL and a short description of why it should be handled according to this security policy.
34
+
35
+ Once an issue is reported, the maintainers use the following disclosure process:
36
+
37
+ - When a report is received, we confirm the issue, determine its severity and the affected versions.
38
+ - If we know of specific third-party services or software based on xmldom that require mitigation before publication, those projects will be notified.
39
+ - A [github security advisory](https://docs.github.com/en/code-security/security-advisories/about-github-security-advisories) is [created](https://docs.github.com/en/code-security/security-advisories/creating-a-security-advisory) (but not published) which details the problem and steps for mitigation.
40
+ - If the reporter provides a github account and agrees to it, we (add that github account as a collaborator on the advisuory)[https://docs.github.com/en/code-security/security-advisories/adding-a-collaborator-to-a-security-advisory].
41
+ - The vulnerability is fixed in a [private fork](https://docs.github.com/en/code-security/security-advisories/collaborating-in-a-temporary-private-fork-to-resolve-a-security-vulnerability) and potential workarounds are identified.
42
+ - The maintainers audit the existing code to find any potential similar problems.
43
+ - The release for the current minor version and the [security advisory are published](https://docs.github.com/en/code-security/security-advisories/publishing-a-security-advisory).
44
+ - The release(s) for previous minor version(s) are published.
45
+
46
+ We credit reporters for identifying security issues, if they confirm that they want to.
47
+
48
+ ## Known vulnerabilities
49
+
50
+ See https://github.com/xmldom/xmldom/security/advisories?state=published
@@ -22,6 +22,31 @@ function freeze(object, oc) {
22
22
  return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object
23
23
  }
24
24
 
25
+ /**
26
+ * Since we can not rely on `Object.assign` we provide a simplified version
27
+ * that is sufficient for our needs.
28
+ *
29
+ * @param {Object} target
30
+ * @param {Object | null | undefined} source
31
+ *
32
+ * @returns {Object} target
33
+ * @throws TypeError if target is not an object
34
+ *
35
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
36
+ * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign
37
+ */
38
+ function assign(target, source) {
39
+ if (target === null || typeof target !== 'object') {
40
+ throw new TypeError('target is not an object')
41
+ }
42
+ for (var key in source) {
43
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
44
+ target[key] = source[key]
45
+ }
46
+ }
47
+ return target
48
+ }
49
+
25
50
  /**
26
51
  * All mime types that are allowed as input to `DOMParser.parseFromString`
27
52
  *
@@ -139,6 +164,7 @@ var NAMESPACE = freeze({
139
164
  XMLNS: 'http://www.w3.org/2000/xmlns/',
140
165
  })
141
166
 
167
+ exports.assign = assign;
142
168
  exports.freeze = freeze;
143
169
  exports.MIME_TYPE = MIME_TYPE;
144
170
  exports.NAMESPACE = NAMESPACE;
package/lib/dom-parser.js CHANGED
@@ -10,6 +10,64 @@ var NAMESPACE = conventions.NAMESPACE;
10
10
  var ParseError = sax.ParseError;
11
11
  var XMLReader = sax.XMLReader;
12
12
 
13
+ /**
14
+ * Normalizes line ending according to https://www.w3.org/TR/xml11/#sec-line-ends:
15
+ *
16
+ * > XML parsed entities are often stored in computer files which,
17
+ * > for editing convenience, are organized into lines.
18
+ * > These lines are typically separated by some combination
19
+ * > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).
20
+ * >
21
+ * > To simplify the tasks of applications, the XML processor must behave
22
+ * > as if it normalized all line breaks in external parsed entities (including the document entity)
23
+ * > on input, before parsing, by translating all of the following to a single #xA character:
24
+ * >
25
+ * > 1. the two-character sequence #xD #xA
26
+ * > 2. the two-character sequence #xD #x85
27
+ * > 3. the single character #x85
28
+ * > 4. the single character #x2028
29
+ * > 5. any #xD character that is not immediately followed by #xA or #x85.
30
+ *
31
+ * @param {string} input
32
+ * @returns {string}
33
+ */
34
+ function normalizeLineEndings(input) {
35
+ return input
36
+ .replace(/\r[\n\u0085]/g, '\n')
37
+ .replace(/[\r\u0085\u2028]/g, '\n')
38
+ }
39
+
40
+ /**
41
+ * @typedef Locator
42
+ * @property {number} [columnNumber]
43
+ * @property {number} [lineNumber]
44
+ */
45
+
46
+ /**
47
+ * @typedef DOMParserOptions
48
+ * @property {DOMHandler} [domBuilder]
49
+ * @property {Function} [errorHandler]
50
+ * @property {(string) => string} [normalizeLineEndings] used to replace line endings before parsing
51
+ * defaults to `normalizeLineEndings`
52
+ * @property {Locator} [locator]
53
+ * @property {Record<string, string>} [xmlns]
54
+ *
55
+ * @see normalizeLineEndings
56
+ */
57
+
58
+ /**
59
+ * The DOMParser interface provides the ability to parse XML or HTML source code
60
+ * from a string into a DOM `Document`.
61
+ *
62
+ * _xmldom is different from the spec in that it allows an `options` parameter,
63
+ * to override the default behavior._
64
+ *
65
+ * @param {DOMParserOptions} [options]
66
+ * @constructor
67
+ *
68
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
69
+ * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
70
+ */
13
71
  function DOMParser(options){
14
72
  this.options = options ||{locator:{}};
15
73
  }
@@ -33,10 +91,15 @@ DOMParser.prototype.parseFromString = function(source,mimeType){
33
91
  defaultNSMap[''] = NAMESPACE.HTML;
34
92
  }
35
93
  defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML;
36
- if(source && typeof source === 'string'){
37
- sax.parse(source,defaultNSMap,entityMap);
38
- }else{
39
- sax.errorHandler.error("invalid doc source");
94
+ var normalize = options.normalizeLineEndings || normalizeLineEndings;
95
+ if (source && typeof source === 'string') {
96
+ sax.parse(
97
+ normalize(source),
98
+ defaultNSMap,
99
+ entityMap
100
+ )
101
+ } else {
102
+ sax.errorHandler.error('invalid doc source')
40
103
  }
41
104
  return domBuilder.doc;
42
105
  }
@@ -255,14 +318,5 @@ function appendElement (hander,node) {
255
318
  }//appendChild and setAttributeNS are preformance key
256
319
 
257
320
  exports.__DOMHandler = DOMHandler;
321
+ exports.normalizeLineEndings = normalizeLineEndings;
258
322
  exports.DOMParser = DOMParser;
259
-
260
- /**
261
- * @deprecated Import/require from main entry point instead
262
- */
263
- exports.DOMImplementation = dom.DOMImplementation;
264
-
265
- /**
266
- * @deprecated Import/require from main entry point instead
267
- */
268
- exports.XMLSerializer = dom.XMLSerializer;
package/lib/dom.js CHANGED
@@ -591,48 +591,67 @@ function _onRemoveAttribute(doc,el,newAttr,remove){
591
591
  }
592
592
  }
593
593
 
594
- function _onUpdateChild(doc,el,newChild){
594
+ /**
595
+ * Updates `el.childNodes`, updating the indexed items and it's `length`.
596
+ * Passing `newChild` means it will be appended.
597
+ * Otherwise it's assumed that an item has been removed,
598
+ * and `el.firstNode` and it's `.nextSibling` are used
599
+ * to walk the current list of child nodes.
600
+ *
601
+ * @param {Document} doc
602
+ * @param {Node} el
603
+ * @param {Node} [newChild]
604
+ * @private
605
+ */
606
+ function _onUpdateChild (doc, el, newChild) {
595
607
  if(doc && doc._inc){
596
608
  doc._inc++;
597
609
  //update childNodes
598
610
  var cs = el.childNodes;
599
- if(newChild){
611
+ if (newChild) {
600
612
  cs[cs.length++] = newChild;
601
- }else{
602
- //console.log(1)
613
+ } else {
603
614
  var child = el.firstChild;
604
615
  var i = 0;
605
- while(child){
616
+ while (child) {
606
617
  cs[i++] = child;
607
- child =child.nextSibling;
618
+ child = child.nextSibling;
608
619
  }
609
620
  cs.length = i;
621
+ delete cs[cs.length];
610
622
  }
611
623
  }
612
624
  }
613
625
 
614
626
  /**
615
- * attributes;
616
- * children;
617
- *
618
- * writeable properties:
619
- * nodeValue,Attr:value,CharacterData:data
620
- * prefix
627
+ * Removes the connections between `parentNode` and `child`
628
+ * and any existing `child.previousSibling` or `child.nextSibling`.
629
+ *
630
+ * @see https://github.com/xmldom/xmldom/issues/135
631
+ * @see https://github.com/xmldom/xmldom/issues/145
632
+ *
633
+ * @param {Node} parentNode
634
+ * @param {Node} child
635
+ * @returns {Node} the child that was removed.
636
+ * @private
621
637
  */
622
- function _removeChild(parentNode,child){
638
+ function _removeChild (parentNode, child) {
623
639
  var previous = child.previousSibling;
624
640
  var next = child.nextSibling;
625
- if(previous){
641
+ if (previous) {
626
642
  previous.nextSibling = next;
627
- }else{
628
- parentNode.firstChild = next
643
+ } else {
644
+ parentNode.firstChild = next;
629
645
  }
630
- if(next){
646
+ if (next) {
631
647
  next.previousSibling = previous;
632
- }else{
648
+ } else {
633
649
  parentNode.lastChild = previous;
634
650
  }
635
- _onUpdateChild(parentNode.ownerDocument,parentNode);
651
+ child.parentNode = null;
652
+ child.previousSibling = null;
653
+ child.nextSibling = null;
654
+ _onUpdateChild(parentNode.ownerDocument, parentNode);
636
655
  return child;
637
656
  }
638
657
  /**
@@ -678,27 +697,35 @@ function _insertBefore(parentNode,newChild,nextChild){
678
697
  }
679
698
  return newChild;
680
699
  }
681
- function _appendSingleChild(parentNode,newChild){
682
- var cp = newChild.parentNode;
683
- if(cp){
684
- var pre = parentNode.lastChild;
685
- cp.removeChild(newChild);//remove and update
686
- var pre = parentNode.lastChild;
700
+
701
+ /**
702
+ * Appends `newChild` to `parentNode`.
703
+ * If `newChild` is already connected to a `parentNode` it is first removed from it.
704
+ *
705
+ * @see https://github.com/xmldom/xmldom/issues/135
706
+ * @see https://github.com/xmldom/xmldom/issues/145
707
+ * @param {Node} parentNode
708
+ * @param {Node} newChild
709
+ * @returns {Node}
710
+ * @private
711
+ */
712
+ function _appendSingleChild (parentNode, newChild) {
713
+ if (newChild.parentNode) {
714
+ newChild.parentNode.removeChild(newChild);
687
715
  }
688
- var pre = parentNode.lastChild;
689
716
  newChild.parentNode = parentNode;
690
- newChild.previousSibling = pre;
717
+ newChild.previousSibling = parentNode.lastChild;
691
718
  newChild.nextSibling = null;
692
- if(pre){
693
- pre.nextSibling = newChild;
694
- }else{
719
+ if (newChild.previousSibling) {
720
+ newChild.previousSibling.nextSibling = newChild;
721
+ } else {
695
722
  parentNode.firstChild = newChild;
696
723
  }
697
724
  parentNode.lastChild = newChild;
698
- _onUpdateChild(parentNode.ownerDocument,parentNode,newChild);
725
+ _onUpdateChild(parentNode.ownerDocument, parentNode, newChild);
699
726
  return newChild;
700
- //console.log("__aa",parentNode.lastChild.nextSibling == null)
701
727
  }
728
+
702
729
  Document.prototype = {
703
730
  //implementation : null,
704
731
  nodeName : '#document',
@@ -1151,12 +1178,19 @@ function needNamespaceDefine(node, isHTML, visibleNamespaces) {
1151
1178
  }
1152
1179
  /**
1153
1180
  * Well-formed constraint: No < in Attribute Values
1154
- * The replacement text of any entity referred to directly or indirectly in an attribute value must not contain a <.
1155
- * @see https://www.w3.org/TR/xml/#CleanAttrVals
1156
- * @see https://www.w3.org/TR/xml/#NT-AttValue
1181
+ * > The replacement text of any entity referred to directly or indirectly
1182
+ * > in an attribute value must not contain a <.
1183
+ * @see https://www.w3.org/TR/xml11/#CleanAttrVals
1184
+ * @see https://www.w3.org/TR/xml11/#NT-AttValue
1185
+ *
1186
+ * Literal whitespace other than space that appear in attribute values
1187
+ * are serialized as their entity references, so they will be preserved.
1188
+ * (In contrast to whitespace literals in the input which are normalized to spaces)
1189
+ * @see https://www.w3.org/TR/xml11/#AVNormalize
1190
+ * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes
1157
1191
  */
1158
1192
  function addSerializedAttribute(buf, qualifiedName, value) {
1159
- buf.push(' ', qualifiedName, '="', value.replace(/[<&"]/g,_xmlEncoder), '"')
1193
+ buf.push(' ', qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"')
1160
1194
  }
1161
1195
 
1162
1196
  function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
@@ -1301,10 +1335,10 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
1301
1335
  * and does not include the CDATA-section-close delimiter, `]]>`.
1302
1336
  *
1303
1337
  * @see https://www.w3.org/TR/xml/#NT-CharData
1338
+ * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
1304
1339
  */
1305
1340
  return buf.push(node.data
1306
- .replace(/[<&]/g,_xmlEncoder)
1307
- .replace(/]]>/g, ']]&gt;')
1341
+ .replace(/[<&>]/g,_xmlEncoder)
1308
1342
  );
1309
1343
  case CDATA_SECTION_NODE:
1310
1344
  return buf.push( '<![CDATA[',node.data,']]>');
package/lib/sax.js CHANGED
@@ -12,7 +12,7 @@ var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:
12
12
  //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
13
13
  //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
14
14
  var S_TAG = 0;//tag name offerring
15
- var S_ATTR = 1;//attr name offerring
15
+ var S_ATTR = 1;//attr name offerring
16
16
  var S_ATTR_SPACE=2;//attr name end and space offer
17
17
  var S_EQ = 3;//=space?
18
18
  var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)
@@ -36,7 +36,7 @@ ParseError.prototype = new Error();
36
36
  ParseError.prototype.name = ParseError.name
37
37
 
38
38
  function XMLReader(){
39
-
39
+
40
40
  }
41
41
 
42
42
  XMLReader.prototype = {
@@ -65,8 +65,8 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
65
65
  }
66
66
  function entityReplacer(a){
67
67
  var k = a.slice(1,-1);
68
- if(k in entityMap){
69
- return entityMap[k];
68
+ if (Object.hasOwnProperty.call(entityMap, k)) {
69
+ return entityMap[k];
70
70
  }else if(k.charAt(0) === '#'){
71
71
  return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
72
72
  }else{
@@ -95,7 +95,7 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
95
95
  var lineEnd = 0;
96
96
  var linePattern = /.*(?:\r\n?|\n)|.*$/g
97
97
  var locator = domBuilder.locator;
98
-
98
+
99
99
  var parseStack = [{currentNSMap:defaultNSMapCopy}]
100
100
  var closeMap = {};
101
101
  var start = 0;
@@ -120,7 +120,7 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
120
120
  var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, '');
121
121
  var config = parseStack.pop();
122
122
  if(end<0){
123
-
123
+
124
124
  tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
125
125
  errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
126
126
  end = tagStart+1+tagName.length;
@@ -145,7 +145,7 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
145
145
  }else{
146
146
  parseStack.push(config)
147
147
  }
148
-
148
+
149
149
  end++;
150
150
  break;
151
151
  // end elment
@@ -164,8 +164,8 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
164
164
  //elStartEnd
165
165
  var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
166
166
  var len = el.length;
167
-
168
-
167
+
168
+
169
169
  if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
170
170
  el.closed = true;
171
171
  if(!entityMap.nbsp){
@@ -233,7 +233,15 @@ function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,error
233
233
  if (el.attributeNames.hasOwnProperty(qname)) {
234
234
  errorHandler.fatalError('Attribute ' + qname + ' redefined')
235
235
  }
236
- el.addValue(qname, value, startIndex)
236
+ el.addValue(
237
+ qname,
238
+ // @see https://www.w3.org/TR/xml/#AVNormalize
239
+ // since the xmldom sax parser does not "interpret" DTD the following is not implemented:
240
+ // - recursive replacement of (DTD) entity references
241
+ // - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA
242
+ value.replace(/[\t\n\r]/g, ' ').replace(/&#?\w+;/g, entityReplacer),
243
+ startIndex
244
+ )
237
245
  }
238
246
  var attrName;
239
247
  var value;
@@ -264,7 +272,7 @@ function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,error
264
272
  start = p+1;
265
273
  p = source.indexOf(c,start)
266
274
  if(p>0){
267
- value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
275
+ value = source.slice(start, p);
268
276
  addAttribute(attrName, value, start-1);
269
277
  s = S_ATTR_END;
270
278
  }else{
@@ -272,10 +280,8 @@ function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,error
272
280
  throw new Error('attribute value no end \''+c+'\' match');
273
281
  }
274
282
  }else if(s == S_ATTR_NOQUOT_VALUE){
275
- value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
276
- //console.log(attrName,value,start,p)
283
+ value = source.slice(start, p);
277
284
  addAttribute(attrName, value, start);
278
- //console.dir(el)
279
285
  errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
280
286
  start = p+1;
281
287
  s = S_ATTR_END
@@ -329,7 +335,7 @@ function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,error
329
335
  }
330
336
  if(s == S_ATTR_NOQUOT_VALUE){
331
337
  errorHandler.warning('attribute "'+value+'" missed quot(")!');
332
- addAttribute(attrName, value.replace(/&#?\w+;/g,entityReplacer), start)
338
+ addAttribute(attrName, value, start)
333
339
  }else{
334
340
  if(!NAMESPACE.isHTML(currentNSMap['']) || !value.match(/^(?:disabled|checked|selected)$/i)){
335
341
  errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
@@ -357,7 +363,7 @@ function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,error
357
363
  s = S_ATTR_SPACE;
358
364
  break;
359
365
  case S_ATTR_NOQUOT_VALUE:
360
- var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
366
+ var value = source.slice(start, p);
361
367
  errorHandler.warning('attribute "'+value+'" missed quot(")!!');
362
368
  addAttribute(attrName, value, start)
363
369
  case S_ATTR_END:
@@ -429,7 +435,7 @@ function appendElement(el,domBuilder,currentNSMap){
429
435
  }
430
436
  //can not set prefix,because prefix !== ''
431
437
  a.localName = localName ;
432
- //prefix == null for no ns prefix attribute
438
+ //prefix == null for no ns prefix attribute
433
439
  if(nsPrefix !== false){//hack!!
434
440
  if(localNSMap == null){
435
441
  localNSMap = {}
@@ -439,7 +445,7 @@ function appendElement(el,domBuilder,currentNSMap){
439
445
  }
440
446
  currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
441
447
  a.uri = NAMESPACE.XMLNS
442
- domBuilder.startPrefixMapping(nsPrefix, value)
448
+ domBuilder.startPrefixMapping(nsPrefix, value)
443
449
  }
444
450
  }
445
451
  var i = el.length;
@@ -451,7 +457,7 @@ function appendElement(el,domBuilder,currentNSMap){
451
457
  a.uri = NAMESPACE.XML;
452
458
  }if(prefix !== 'xmlns'){
453
459
  a.uri = currentNSMap[prefix || '']
454
-
460
+
455
461
  //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
456
462
  }
457
463
  }
@@ -473,7 +479,7 @@ function appendElement(el,domBuilder,currentNSMap){
473
479
  domBuilder.endElement(ns,localName,tagName);
474
480
  if(localNSMap){
475
481
  for(prefix in localNSMap){
476
- domBuilder.endPrefixMapping(prefix)
482
+ domBuilder.endPrefixMapping(prefix)
477
483
  }
478
484
  }
479
485
  }else{
@@ -500,7 +506,7 @@ function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBui
500
506
  domBuilder.characters(text,0,text.length);
501
507
  return elEndStart;
502
508
  //}
503
-
509
+
504
510
  }
505
511
  }
506
512
  return elStartEnd+1;
@@ -517,7 +523,7 @@ function fixSelfClosed(source,elStartEnd,tagName,closeMap){
517
523
  closeMap[tagName] =pos
518
524
  }
519
525
  return pos<elStartEnd;
520
- //}
526
+ //}
521
527
  }
522
528
  function _copy(source,target){
523
529
  for(var n in source){target[n] = source[n]}
@@ -545,11 +551,11 @@ function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
545
551
  var end = source.indexOf(']]>',start+9);
546
552
  domBuilder.startCDATA();
547
553
  domBuilder.characters(source,start+9,end-start-9);
548
- domBuilder.endCDATA()
554
+ domBuilder.endCDATA()
549
555
  return end+3;
550
556
  }
551
557
  //<!DOCTYPE
552
- //startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
558
+ //startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
553
559
  var matchs = split(source,start);
554
560
  var len = matchs.length;
555
561
  if(len>1 && /!doctype/i.test(matchs[0][0])){
@@ -567,7 +573,7 @@ function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
567
573
  var lastMatch = matchs[len-1]
568
574
  domBuilder.startDTD(name, pubid, sysid);
569
575
  domBuilder.endDTD();
570
-
576
+
571
577
  return lastMatch.index+lastMatch[0].length
572
578
  }
573
579
  }
@@ -616,7 +622,7 @@ ElementAttributes.prototype = {
616
622
  getValue:function(i){return this[i].value}
617
623
  // ,getIndex:function(uri, localName)){
618
624
  // if(localName){
619
- //
625
+ //
620
626
  // }else{
621
627
  // var qName = uri
622
628
  // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmldom/xmldom",
3
- "version": "0.7.5",
3
+ "version": "0.8.2",
4
4
  "description": "A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.",
5
5
  "keywords": [
6
6
  "w3c",
@@ -23,35 +23,47 @@
23
23
  "CHANGELOG.md",
24
24
  "LICENSE",
25
25
  "readme.md",
26
+ "SECURITY.md",
26
27
  "index.d.ts",
27
28
  "lib"
28
29
  ],
29
30
  "scripts": {
30
31
  "lint": "eslint lib test",
32
+ "changelog": "auto-changelog --unreleased-only",
31
33
  "start": "nodemon --watch package.json --watch lib --watch test --exec 'npm --silent run test && npm --silent run lint'",
32
34
  "stryker": "stryker run",
33
35
  "stryker:dry-run": "stryker run -m '' --reporters progress",
34
- "test": "jest"
36
+ "test": "jest",
37
+ "version": "./changelog-has-version.sh",
38
+ "release": "np --no-yarn"
35
39
  },
36
40
  "engines": {
37
41
  "node": ">=10.0.0"
38
42
  },
39
43
  "dependencies": {},
40
44
  "devDependencies": {
41
- "@stryker-mutator/core": "^5.2.2",
42
- "eslint": "^7.32.0",
43
- "eslint-config-prettier": "^8.3.0",
44
- "eslint-plugin-es5": "^1.5.0",
45
- "eslint-plugin-prettier": "^3.4.1",
46
- "get-stream": "^6.0.1",
47
- "jest": "^27.0.6",
48
- "nodemon": "^2.0.12",
49
- "prettier": "^2.3.2",
50
- "xmltest": "^1.5.0",
51
- "yauzl": "^2.10.0"
45
+ "@stryker-mutator/core": "5.6.1",
46
+ "auto-changelog": "2.4.0",
47
+ "eslint": "8.12.0",
48
+ "eslint-config-prettier": "8.5.0",
49
+ "eslint-plugin-es5": "1.5.0",
50
+ "eslint-plugin-prettier": "4.0.0",
51
+ "get-stream": "6.0.1",
52
+ "jest": "27.5.1",
53
+ "nodemon": "2.0.15",
54
+ "np": "7.6.1",
55
+ "prettier": "2.6.2",
56
+ "xmltest": "1.5.0",
57
+ "yauzl": "2.10.0"
52
58
  },
53
59
  "bugs": {
54
60
  "url": "https://github.com/xmldom/xmldom/issues"
55
61
  },
56
- "license": "MIT"
62
+ "license": "MIT",
63
+ "auto-changelog": {
64
+ "prepend": true,
65
+ "remote": "upstream",
66
+ "tagPrefix": "",
67
+ "template": "./auto-changelog.hbs"
68
+ }
57
69
  }
package/readme.md CHANGED
@@ -3,8 +3,9 @@
3
3
  ***Since version 0.7.0 this package is published to npm as [`@xmldom/xmldom`](https://www.npmjs.com/package/@xmldom/xmldom) and no longer as [`xmldom`](https://www.npmjs.com/package/xmldom), because [we are no longer able to publish `xmldom`](https://github.com/xmldom/xmldom/issues/271).***
4
4
  *For better readability in the docs we will continue to talk about this library as "xmldom".*
5
5
 
6
- [![license](https://img.shields.io/npm/l/@xmldom/xmldom?color=blue&style=flat-square)](LICENSE)
6
+ [![license(MIT)](https://img.shields.io/npm/l/@xmldom/xmldom?color=blue&style=flat-square)](https://github.com/xmldom/xmldom/blob/master/LICENSE)
7
7
  [![npm](https://img.shields.io/npm/v/@xmldom/xmldom?style=flat-square)](https://www.npmjs.com/package/@xmldom/xmldom)
8
+ [![snyk.io package health](https://snyk.io/advisor/npm-package/@xmldom/xmldom/badge.svg)](https://snyk.io/advisor/npm-package/@xmldom/xmldom)
8
9
  [![bug issues](https://img.shields.io/github/issues/xmldom/xmldom/bug?color=red&style=flat-square)](https://github.com/xmldom/xmldom/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
9
10
  [![help-wanted issues](https://img.shields.io/github/issues/xmldom/xmldom/help-wanted?color=darkgreen&style=flat-square)](https://github.com/xmldom/xmldom/issues?q=is%3Aissue+is%3Aopen+label%3Ahelp-wanted)
10
11
  [![Mutation report](https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fxmldom%2Fxmldom%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/xmldom/xmldom/master)
@@ -40,28 +41,23 @@ This project was forked from it's [original source](https://github.com/jindw/xml
40
41
 
41
42
  ### Example:
42
43
 
44
+ [In NodeJS](examples/nodejs/src/index.js)
43
45
  ```javascript
44
- const { DOMParser } = require('@xmldom/xmldom')
45
-
46
- const doc = new DOMParser().parseFromString(
47
- '<xml xmlns="a" xmlns:c="./lite">\n' +
48
- '\t<child>test</child>\n' +
49
- '\t<child></child>\n' +
50
- '\t<child/>\n' +
51
- '</xml>',
52
- 'text/xml'
53
- )
54
- doc.documentElement.setAttribute('x', 'y')
55
- doc.documentElement.setAttributeNS('./lite', 'c:x', 'y2')
56
- console.info(doc)
57
-
58
- const nsAttr = doc.documentElement.getAttributeNS('./lite', 'x')
59
- console.info(nsAttr)
46
+ const { DOMParser, XMLSerializer } = require('@xmldom/xmldom')
47
+
48
+ const source = `<xml xmlns="a">
49
+ <child>test</child>
50
+ <child/>
51
+ </xml>`
52
+
53
+ const doc = new DOMParser().parseFromString(source, 'text/xml')
54
+
55
+ const serialized = new XMLSerializer().serializeToString(doc)
60
56
  ```
61
57
 
62
- Note: in Typescript and ES6 you can use the import approach, as follows:
58
+ Note: in Typescript ~and ES6~(see #316) you can use the `import` approach, as follows:
63
59
 
64
- ```javascript
60
+ ```typescript
65
61
  import { DOMParser } from '@xmldom/xmldom'
66
62
  ```
67
63
 
@@ -102,182 +98,204 @@ import { DOMParser } from '@xmldom/xmldom'
102
98
  ```
103
99
  ### DOM level2 method and attribute:
104
100
 
105
- * [Node](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247)
106
-
107
- attribute:
108
- nodeValue|prefix
109
- readonly attribute:
110
- nodeName|nodeType|parentNode|childNodes|firstChild|lastChild|previousSibling|nextSibling|attributes|ownerDocument|namespaceURI|localName
111
- method:
112
- insertBefore(newChild, refChild)
113
- replaceChild(newChild, oldChild)
114
- removeChild(oldChild)
115
- appendChild(newChild)
116
- hasChildNodes()
117
- cloneNode(deep)
118
- normalize()
119
- isSupported(feature, version)
120
- hasAttributes()
121
- * [DOMException](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html)
122
- The DOMException class has the following constants (and `value` of type `Number`):
101
+ * [Node](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247)
102
+
103
+ readonly class properties (aka `NodeType`),
104
+ these can be accessed from any `Node` instance `node`:
105
+ `if (node.nodeType === node.ELEMENT_NODE) {...`
106
+
107
+ 1. `ELEMENT_NODE` (`1`)
108
+ 2. `ATTRIBUTE_NODE` (`2`)
109
+ 3. `TEXT_NODE` (`3`)
110
+ 4. `CDATA_SECTION_NODE` (`4`)
111
+ 5. `ENTITY_REFERENCE_NODE` (`5`)
112
+ 6. `ENTITY_NODE` (`6`)
113
+ 7. `PROCESSING_INSTRUCTION_NODE` (`7`)
114
+ 8. `COMMENT_NODE` (`8`)
115
+ 9. `DOCUMENT_NODE` (`9`)
116
+ 10. `DOCUMENT_TYPE_NODE` (`10`)
117
+ 11. `DOCUMENT_FRAGMENT_NODE` (`11`)
118
+ 12. `NOTATION_NODE` (`12`)
119
+
120
+ attribute:
121
+ - `nodeValue` | `prefix`
123
122
 
124
- 1. `DOMException.INDEX_SIZE_ERR` (`1`)
125
- 1. `DOMException.DOMSTRING_SIZE_ERR` (`2`)
126
- 1. `DOMException.HIERARCHY_REQUEST_ERR` (`3`)
127
- 1. `DOMException.WRONG_DOCUMENT_ERR` (`4`)
128
- 1. `DOMException.INVALID_CHARACTER_ERR` (`5`)
129
- 1. `DOMException.NO_DATA_ALLOWED_ERR` (`6`)
130
- 1. `DOMException.NO_MODIFICATION_ALLOWED_ERR` (`7`)
131
- 1. `DOMException.NOT_FOUND_ERR` (`8`)
132
- 1. `DOMException.NOT_SUPPORTED_ERR` (`9`)
133
- 1. `DOMException.INUSE_ATTRIBUTE_ERR` (`10`)
134
- 1. `DOMException.INVALID_STATE_ERR` (`11`)
135
- 1. `DOMException.SYNTAX_ERR` (`12`)
136
- 1. `DOMException.INVALID_MODIFICATION_ERR` (`13`)
137
- 1. `DOMException.NAMESPACE_ERR` (`14`)
138
- 1. `DOMException.INVALID_ACCESS_ERR` (`15`)
123
+ readonly attribute:
124
+ - `nodeName` | `nodeType` | `parentNode` | `childNodes` | `firstChild` | `lastChild` | `previousSibling` | `nextSibling` | `attributes` | `ownerDocument` | `namespaceURI` | `localName`
125
+
126
+ method:
127
+ * `insertBefore(newChild, refChild)`
128
+ * `replaceChild(newChild, oldChild)`
129
+ * `removeChild(oldChild)`
130
+ * `appendChild(newChild)`
131
+ * `hasChildNodes()`
132
+ * `cloneNode(deep)`
133
+ * `normalize()`
134
+ * `isSupported(feature, version)`
135
+ * `hasAttributes()`
136
+ * [DOMException](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html)
137
+
138
+ extends the Error type thrown as part of DOM API.
139
+
140
+ readonly class properties:
141
+ - `INDEX_SIZE_ERR` (`1`)
142
+ - `DOMSTRING_SIZE_ERR` (`2`)
143
+ - `HIERARCHY_REQUEST_ERR` (`3`)
144
+ - `WRONG_DOCUMENT_ERR` (`4`)
145
+ - `INVALID_CHARACTER_ERR` (`5`)
146
+ - `NO_DATA_ALLOWED_ERR` (`6`)
147
+ - `NO_MODIFICATION_ALLOWED_ERR` (`7`)
148
+ - `NOT_FOUND_ERR` (`8`)
149
+ - `NOT_SUPPORTED_ERR` (`9`)
150
+ - `INUSE_ATTRIBUTE_ERR` (`10`)
151
+ - `INVALID_STATE_ERR` (`11`)
152
+ - `SYNTAX_ERR` (`12`)
153
+ - `INVALID_MODIFICATION_ERR` (`13`)
154
+ - `NAMESPACE_ERR` (`14`)
155
+ - `INVALID_ACCESS_ERR` (`15`)
139
156
 
140
- The DOMException object has the following properties:
141
- code
142
- This property is of type Number.
157
+ attributes:
158
+ - `code` with a value matching one of the above constants.
143
159
 
144
- * extends the Error type thrown as part of DOM API:
160
+ * [DOMImplementation](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-102161490)
145
161
 
146
- * [DOMImplementation](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-102161490)
147
-
148
- method:
149
- hasFeature(feature, version)
150
- createDocumentType(qualifiedName, publicId, systemId)
151
- createDocument(namespaceURI, qualifiedName, doctype)
162
+ method:
163
+ - `hasFeature(feature, version)`
164
+ - `createDocumentType(qualifiedName, publicId, systemId)`
165
+ - `createDocument(namespaceURI, qualifiedName, doctype)`
152
166
 
153
- * [Document](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#i-Document) : Node
167
+ * [Document](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#i-Document) : Node
154
168
 
155
- readonly attribute:
156
- doctype|implementation|documentElement
157
- method:
158
- createElement(tagName)
159
- createDocumentFragment()
160
- createTextNode(data)
161
- createComment(data)
162
- createCDATASection(data)
163
- createProcessingInstruction(target, data)
164
- createAttribute(name)
165
- createEntityReference(name)
166
- getElementsByTagName(tagname)
167
- importNode(importedNode, deep)
168
- createElementNS(namespaceURI, qualifiedName)
169
- createAttributeNS(namespaceURI, qualifiedName)
170
- getElementsByTagNameNS(namespaceURI, localName)
171
- getElementById(elementId)
172
-
173
- * [DocumentFragment](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-B63ED1A3) : Node
174
- * [Element](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-745549614) : Node
169
+ readonly attribute:
170
+ - `doctype` | `implementation` | `documentElement`
171
+
172
+ method:
173
+ - `createElement(tagName)`
174
+ - `createDocumentFragment()`
175
+ - `createTextNode(data)`
176
+ - `createComment(data)`
177
+ - `createCDATASection(data)`
178
+ - `createProcessingInstruction(target, data)`
179
+ - `createAttribute(name)`
180
+ - `createEntityReference(name)`
181
+ - `getElementsByTagName(tagname)`
182
+ - `importNode(importedNode, deep)`
183
+ - `createElementNS(namespaceURI, qualifiedName)`
184
+ - `createAttributeNS(namespaceURI, qualifiedName)`
185
+ - `getElementsByTagNameNS(namespaceURI, localName)`
186
+ - `getElementById(elementId)`
187
+
188
+ * [DocumentFragment](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-B63ED1A3) : Node
189
+ * [Element](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-745549614) : Node
175
190
 
176
- readonly attribute:
177
- tagName
178
- method:
179
- getAttribute(name)
180
- setAttribute(name, value)
181
- removeAttribute(name)
182
- getAttributeNode(name)
183
- setAttributeNode(newAttr)
184
- removeAttributeNode(oldAttr)
185
- getElementsByTagName(name)
186
- getAttributeNS(namespaceURI, localName)
187
- setAttributeNS(namespaceURI, qualifiedName, value)
188
- removeAttributeNS(namespaceURI, localName)
189
- getAttributeNodeNS(namespaceURI, localName)
190
- setAttributeNodeNS(newAttr)
191
- getElementsByTagNameNS(namespaceURI, localName)
192
- hasAttribute(name)
193
- hasAttributeNS(namespaceURI, localName)
194
-
195
- * [Attr](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-637646024) : Node
196
-
197
- attribute:
198
- value
199
- readonly attribute:
200
- name|specified|ownerElement
201
-
202
- * [NodeList](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177)
191
+ readonly attribute:
192
+ - `tagName`
193
+
194
+ method:
195
+ - `getAttribute(name)`
196
+ - `setAttribute(name, value)`
197
+ - `removeAttribute(name)`
198
+ - `getAttributeNode(name)`
199
+ - `setAttributeNode(newAttr)`
200
+ - `removeAttributeNode(oldAttr)`
201
+ - `getElementsByTagName(name)`
202
+ - `getAttributeNS(namespaceURI, localName)`
203
+ - `setAttributeNS(namespaceURI, qualifiedName, value)`
204
+ - `removeAttributeNS(namespaceURI, localName)`
205
+ - `getAttributeNodeNS(namespaceURI, localName)`
206
+ - `setAttributeNodeNS(newAttr)`
207
+ - `getElementsByTagNameNS(namespaceURI, localName)`
208
+ - `hasAttribute(name)`
209
+ - `hasAttributeNS(namespaceURI, localName)`
210
+
211
+ * [Attr](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-637646024) : Node
212
+
213
+ attribute:
214
+ - `value`
215
+
216
+ readonly attribute:
217
+ - `name` | `specified` | `ownerElement`
218
+
219
+ * [NodeList](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177)
203
220
 
204
- readonly attribute:
205
- length
206
- method:
207
- item(index)
221
+ readonly attribute:
222
+ - `length`
223
+
224
+ method:
225
+ - `item(index)`
208
226
 
209
- * [NamedNodeMap](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1780488922)
210
-
211
- readonly attribute:
212
- length
213
- method:
214
- getNamedItem(name)
215
- setNamedItem(arg)
216
- removeNamedItem(name)
217
- item(index)
218
- getNamedItemNS(namespaceURI, localName)
219
- setNamedItemNS(arg)
220
- removeNamedItemNS(namespaceURI, localName)
227
+ * [NamedNodeMap](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1780488922)
228
+
229
+ readonly attribute:
230
+ - `length`
231
+
232
+ method:
233
+ - `getNamedItem(name)`
234
+ - `setNamedItem(arg)`
235
+ - `removeNamedItem(name)`
236
+ - `item(index)`
237
+ - `getNamedItemNS(namespaceURI, localName)`
238
+ - `setNamedItemNS(arg)`
239
+ - `removeNamedItemNS(namespaceURI, localName)`
221
240
 
222
- * [CharacterData](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-FF21A306) : Node
241
+ * [CharacterData](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-FF21A306) : Node
223
242
 
224
- method:
225
- substringData(offset, count)
226
- appendData(arg)
227
- insertData(offset, arg)
228
- deleteData(offset, count)
229
- replaceData(offset, count, arg)
243
+ method:
244
+ - `substringData(offset, count)`
245
+ - `appendData(arg)`
246
+ - `insertData(offset, arg)`
247
+ - `deleteData(offset, count)`
248
+ - `replaceData(offset, count, arg)`
230
249
 
231
- * [Text](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1312295772) : CharacterData
232
-
233
- method:
234
- splitText(offset)
250
+ * [Text](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1312295772) : CharacterData
251
+
252
+ method:
253
+ - `splitText(offset)`
235
254
 
236
- * [CDATASection](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-667469212)
237
- * [Comment](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1728279322) : CharacterData
255
+ * [CDATASection](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-667469212)
256
+ * [Comment](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1728279322) : CharacterData
238
257
 
239
- * [DocumentType](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-412266927)
258
+ * [DocumentType](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-412266927)
240
259
 
241
- readonly attribute:
242
- name|entities|notations|publicId|systemId|internalSubset
260
+ readonly attribute:
261
+ - `name` | `entities` | `notations` | `publicId` | `systemId` | `internalSubset`
243
262
 
244
- * Notation : Node
263
+ * Notation : Node
245
264
 
246
- readonly attribute:
247
- publicId|systemId
265
+ readonly attribute:
266
+ - `publicId` | `systemId`
248
267
 
249
- * Entity : Node
268
+ * Entity : Node
250
269
 
251
- readonly attribute:
252
- publicId|systemId|notationName
270
+ readonly attribute:
271
+ - `publicId` | `systemId` | `notationName`
253
272
 
254
- * EntityReference : Node
255
- * ProcessingInstruction : Node
256
-
257
- attribute:
258
- data
259
- readonly attribute:
260
- target
273
+ * EntityReference : Node
274
+ * ProcessingInstruction : Node
275
+
276
+ attribute:
277
+ - `data`
278
+ readonly attribute:
279
+ - `target`
261
280
 
262
281
  ### DOM level 3 support:
263
282
 
264
- * [Node](http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent)
283
+ * [Node](http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent)
265
284
 
266
- attribute:
267
- textContent
268
- method:
269
- isDefaultNamespace(namespaceURI){
270
- lookupNamespaceURI(prefix)
285
+ attribute:
286
+ - `textContent`
287
+
288
+ method:
289
+ - `isDefaultNamespace(namespaceURI)`
290
+ - `lookupNamespaceURI(prefix)`
271
291
 
272
292
  ### DOM extension by xmldom
273
293
 
274
294
  * [Node] Source position extension;
275
295
 
276
- attribute:
277
- //Numbered starting from '1'
278
- lineNumber
279
- //Numbered starting from '1'
280
- columnNumber
296
+ attribute:
297
+ - `lineNumber` //number starting from `1`
298
+ - `columnNumber` //number starting from `1`
281
299
 
282
300
  ## Specs
283
301
 
@@ -335,4 +353,4 @@ xmldom has an own SAX parser implementation to do the actual parsing, which impl
335
353
  - `XMLReader`
336
354
  - `DOMHandler`
337
355
 
338
- There is an idea/proposal to make ti possible to replace it with something else in <https://github.com/xmldom/xmldom/issues/55>
356
+ There is an idea/proposal to make it possible to replace it with something else in <https://github.com/xmldom/xmldom/issues/55>