@xmldom/xmldom 0.7.2 → 0.7.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,32 @@ 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.7.3
8
+
9
+ [Commits](https://github.com/xmldom/xmldom/compare/0.7.2...0.7.3)
10
+
11
+ ### Fixes:
12
+
13
+ - Add doctype when parsing from string [`#277`](https://github.com/xmldom/xmldom/issues/277) / [`#301`](https://github.com/xmldom/xmldom/pull/301)
14
+ - Correct typo in error message [`#294`](https://github.com/xmldom/xmldom/pull/294)
15
+ Thank you [@rrthomas](https://github.com/rrthomas)
16
+
17
+ ### Refactor:
18
+
19
+ - Improve exports & require statements, new main package entry [`#233`](https://github.com/xmldom/xmldom/pull/233)
20
+
21
+ ### Docs:
22
+
23
+ - Fix Stryker badge [`#298`](https://github.com/xmldom/xmldom/pull/298)
24
+ - Fix link to help-wanted issues [`#299`](https://github.com/xmldom/xmldom/pull/299)
25
+
26
+ ### Chore:
27
+
28
+ - Execute stryker:dry-run on branches [`#302`](https://github.com/xmldom/xmldom/pull/302)
29
+ - Fix stryker config [`#300`](https://github.com/xmldom/xmldom/pull/300)
30
+ - Split test and lint scripts [`#297`](https://github.com/xmldom/xmldom/pull/297)
31
+ - Switch to stryker dashboard owned by org [`#292`](https://github.com/xmldom/xmldom/pull/292)
32
+
7
33
  ## 0.7.2
8
34
 
9
35
  [Commits](https://github.com/xmldom/xmldom/compare/0.7.1...0.7.2)
package/lib/dom-parser.js CHANGED
@@ -1,8 +1,15 @@
1
1
  var conventions = require("./conventions");
2
+ var dom = require('./dom')
2
3
  var entities = require('./entities');
4
+ var sax = require('./sax');
5
+
6
+ var DOMImplementation = dom.DOMImplementation;
3
7
 
4
8
  var NAMESPACE = conventions.NAMESPACE;
5
9
 
10
+ var ParseError = sax.ParseError;
11
+ var XMLReader = sax.XMLReader;
12
+
6
13
  function DOMParser(options){
7
14
  this.options = options ||{locator:{}};
8
15
  }
@@ -170,6 +177,7 @@ DOMHandler.prototype = {
170
177
  var dt = impl.createDocumentType(name, publicId, systemId);
171
178
  this.locator && position(this.locator,dt)
172
179
  appendElement(this, dt);
180
+ this.doc.doctype = dt;
173
181
  }
174
182
  },
175
183
  /**
@@ -246,12 +254,15 @@ function appendElement (hander,node) {
246
254
  }
247
255
  }//appendChild and setAttributeNS are preformance key
248
256
 
249
- //if(typeof require == 'function'){
250
- var sax = require('./sax');
251
- var XMLReader = sax.XMLReader;
252
- var ParseError = sax.ParseError;
253
- var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;
254
- exports.XMLSerializer = require('./dom').XMLSerializer ;
255
- exports.DOMParser = DOMParser;
256
257
  exports.__DOMHandler = DOMHandler;
257
- //}
258
+ 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
@@ -81,7 +81,7 @@ function _extends(Class,Super){
81
81
  }
82
82
  if(pt.constructor != Class){
83
83
  if(typeof Class != 'function'){
84
- console.error("unknow Class:"+Class)
84
+ console.error("unknown Class:"+Class)
85
85
  }
86
86
  pt.constructor = Class
87
87
  }
@@ -689,6 +689,12 @@ Document.prototype = {
689
689
  //implementation : null,
690
690
  nodeName : '#document',
691
691
  nodeType : DOCUMENT_NODE,
692
+ /**
693
+ * The DocumentType node of the document.
694
+ *
695
+ * @readonly
696
+ * @type DocumentType
697
+ */
692
698
  doctype : null,
693
699
  documentElement : null,
694
700
  _inc : 1,
package/lib/index.js ADDED
@@ -0,0 +1,4 @@
1
+ var dom = require('./dom')
2
+ exports.DOMImplementation = dom.DOMImplementation
3
+ exports.XMLSerializer = dom.XMLSerializer
4
+ exports.DOMParser = require('./dom-parser').DOMParser
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmldom/xmldom",
3
- "version": "0.7.2",
3
+ "version": "0.7.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",
@@ -17,7 +17,7 @@
17
17
  "type": "git",
18
18
  "url": "git://github.com/xmldom/xmldom.git"
19
19
  },
20
- "main": "lib/dom-parser.js",
20
+ "main": "lib/index.js",
21
21
  "types": "index.d.ts",
22
22
  "files": [
23
23
  "CHANGELOG.md",
@@ -27,13 +27,11 @@
27
27
  "lib"
28
28
  ],
29
29
  "scripts": {
30
- "lint": "npm-run-all lint:eslint",
31
- "lint:eslint": "eslint lib test",
32
- "start": "nodemon --watch package.json --watch lib --watch test --exec 'npm --silent run test'",
30
+ "lint": "eslint lib test",
31
+ "start": "nodemon --watch package.json --watch lib --watch test --exec 'npm --silent run test && npm --silent run lint'",
33
32
  "stryker": "stryker run",
34
- "test": "npm-run-all test:unit lint",
35
- "test:unit": "npm-run-all test:jest",
36
- "test:jest": "jest"
33
+ "stryker:dry-run": "stryker run -m '' --reporters progress",
34
+ "test": "jest"
37
35
  },
38
36
  "engines": {
39
37
  "node": ">=10.0.0"
@@ -44,11 +42,10 @@
44
42
  "eslint": "^7.32.0",
45
43
  "eslint-config-prettier": "^8.3.0",
46
44
  "eslint-plugin-es5": "^1.5.0",
47
- "eslint-plugin-prettier": "^3.4.0",
45
+ "eslint-plugin-prettier": "^3.4.1",
48
46
  "get-stream": "^6.0.1",
49
47
  "jest": "^27.0.6",
50
48
  "nodemon": "^2.0.12",
51
- "npm-run-all": "^4.1.5",
52
49
  "prettier": "^2.3.2",
53
50
  "xmltest": "^1.5.0",
54
51
  "yauzl": "^2.10.0"
package/readme.md CHANGED
@@ -1,85 +1,36 @@
1
1
  # @xmldom/xmldom
2
2
 
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
+ *For better readability in the docs we will continue to talk about this library as "xmldom".*
5
+
3
6
  [![license](https://img.shields.io/npm/l/@xmldom/xmldom?color=blue&style=flat-square)](LICENSE)
4
7
  [![npm](https://img.shields.io/npm/v/@xmldom/xmldom?style=flat-square)](https://www.npmjs.com/package/@xmldom/xmldom)
5
8
  [![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)
6
- [!["help wanted" issues](https://img.shields.io/github/issues/xmldom/xmldom/help%20wanted?color=darkgreen&style=flat-square)](https://github.com/xmldom/xmldom/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
7
- [![Mutation report](https://camo.githubusercontent.com/ee312c4ebce7784ce9f785757eba5d6e33e6d950/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d25324662726f647962697473253246786d6c646f6d2532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/brodybits/xmldom/master)
8
-
9
- **The currently active maintainers decided to publish this code as `@xmldom/xmldom` because [the npm library `xmldom` contains security issues but can currently not be published by us](https://github.com/xmldom/xmldom/issues/271).**
10
-
11
- *For better readability in the docs we will continue to talk about this library as "xmldom".*
12
-
13
- xmldom is a javascript [ponyfill](https://ponyfill.com/) for the following APIs supported in browsers:
14
- - convert an XML string into a DOM tree (`new DOMParser().parseFromString(xml, mimeType)` => `Document`)
15
- - create, access and modify a DOM tree (`new DOMImplementation().createDocument(...)` => `Document`, )
16
- - serialize a DOM tree back into an XML string (`new XMLSerializer().serializeToString(node)` => `string`)
17
-
18
- Note that this `xmldom` library is not required if your code targets a modern browser. But this library is recommended if your code needs to also work in other runtimes like NodeJS or Rhino.
19
-
20
- ## Specs
9
+ [![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
+ [![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)
21
11
 
22
- The implementation is based on several specifications:
23
12
 
24
- <!-- Should open in new tab and the links in the SVG should be clickable there! -->
25
- <a href="https://raw.githubusercontent.com/xmldom/xmldom/master/docs/specs.svg" target="_blank" rel="noopener noreferrer nofollow" >![Overview of related specifications and their relations](docs/specs.svg)</a>
13
+ xmldom is a javascript [ponyfill](https://ponyfill.com/) to provide the following APIs [that are present in modern browsers](https://caniuse.com/xml-serializer) to other runtimes:
14
+ - convert an XML string into a DOM tree
15
+ ```
16
+ new DOMParser().parseFromString(xml, mimeType) => Document
17
+ ```
18
+ - create, access and modify a DOM tree
19
+ ```
20
+ new DOMImplementation().createDocument(...) => Document
21
+ ```
22
+ - serialize a DOM tree back into an XML string
23
+ ```
24
+ new XMLSerializer().serializeToString(node) => string
25
+ ```
26
26
 
27
- ### DOM Parsing and Serialization
27
+ 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)).
28
28
 
29
- From the [W3C DOM Parsing and Serialization (WD 2016)](https://www.w3.org/TR/2016/WD-DOM-Parsing-20160517/) `xmldom` provides an implementation for the interfaces:
30
- - `DOMParser`
31
- - `XMLSerializer`
32
-
33
- Note that there are some known deviations between this implementation and the W3 specifications.
34
-
35
- Note: [The latest version of this spec](https://w3c.github.io/DOM-Parsing/) has the status "Editors Draft", since it is under active development. One major change is that [the definition of the `DOMParser` interface has been moved to the HTML spec](https://w3c.github.io/DOM-Parsing/#the-domparser-interface)
36
-
37
-
38
- ### DOM
39
-
40
- The original author claims that xmldom implements [DOM Level 2] in a "fully compatible" way and some parts of [DOM Level 3], but there are not enough tests to prove this. Both Specifications are now superseded by the [DOM Level 4 aka Living standard] wich has a much broader scope than xmldom.
41
-
42
- xmldom implements the following interfaces (most constructors are currently not exposed):
43
- - `Attr`
44
- - `CDATASection`
45
- - `CharacterData`
46
- - `Comment`
47
- - `Document`
48
- - `DocumentFragment`
49
- - `DocumentType`
50
- - `DOMException` (constructor exposed)
51
- - `DOMImplementation` (constructor exposed)
52
- - `Element`
53
- - `Entity`
54
- - `EntityReference`
55
- - `LiveNodeList`
56
- - `NamedNodeMap`
57
- - `Node` (constructor exposed)
58
- - `NodeList`
59
- - `Notation`
60
- - `ProcessingInstruction`
61
- - `Text`
62
-
63
- more details are available in the (incomplete) [API Reference](#api-reference) section.
64
-
65
- ### HTML
66
-
67
- xmldom does not have any goal of supporting the full spec, but it has some capability to parse, report and serialize things differently when "detecting HTML" (by checking the default namespace).
68
- There is an upcoming change to better align the implementation with the latest specs, related to <https://github.com/xmldom/xmldom/issues/203>.
69
-
70
- ### SAX, XML, XMLNS
71
-
72
- xmldom has an own SAX parser implementation to do the actual parsing, which implements some interfaces in alignment with the Java interfaces SAX defines:
73
- - `XMLReader`
74
- - `DOMHandler`
75
-
76
- There is an idea/proposal to make ti possible to replace it with something else in <https://github.com/xmldom/xmldom/issues/55>
29
+ When deciding how to fix bugs or implement features, `xmldom` tries to stay as close as possible to the various [related specifications/standards](#specs).
30
+ As indicated by the version starting with `0.`, this implementation is not feature complete and some implemented features differ from what the specifications describe.
31
+ **Issues and PRs for such differences are always welcome, even when they only provide a failing test case.**
77
32
 
78
- ## Forked
79
-
80
- **Original project location:** <https://github.com/jindw/xmldom>
81
-
82
- More details about the transition can be found in the [CHANGELOG](CHANGELOG.md#maintainer-changes) and in <https://github.com/xmldom/xmldom/issues/62>
33
+ This project was forked from it's [original source](https://github.com/jindw/xmldom) in 2019, more details about that transition can be found in the [CHANGELOG](CHANGELOG.md#maintainer-changes).
83
34
 
84
35
  ## Usage
85
36
 
@@ -121,7 +72,7 @@ import { DOMParser } from '@xmldom/xmldom'
121
72
  ```javascript
122
73
  parseFromString(xmlsource,mimeType)
123
74
  ```
124
- * **options extension** _by xmldom_(not BOM standard!!)
75
+ * **options extension** _by xmldom_ (not DOM standard!!)
125
76
 
126
77
  ```javascript
127
78
  //added the options argument
@@ -327,3 +278,61 @@ import { DOMParser } from '@xmldom/xmldom'
327
278
  lineNumber
328
279
  //Numbered starting from '1'
329
280
  columnNumber
281
+
282
+ ## Specs
283
+
284
+ The implementation is based on several specifications:
285
+
286
+ <!-- Should open in new tab and the links in the SVG should be clickable there! -->
287
+ <a href="https://raw.githubusercontent.com/xmldom/xmldom/master/docs/specs.svg" target="_blank" rel="noopener noreferrer nofollow" >![Overview of related specifications and their relations](docs/specs.svg)</a>
288
+
289
+ ### DOM Parsing and Serialization
290
+
291
+ From the [W3C DOM Parsing and Serialization (WD 2016)](https://www.w3.org/TR/2016/WD-DOM-Parsing-20160517/) `xmldom` provides an implementation for the interfaces:
292
+ - `DOMParser`
293
+ - `XMLSerializer`
294
+
295
+ Note that there are some known deviations between this implementation and the W3 specifications.
296
+
297
+ Note: [The latest version of this spec](https://w3c.github.io/DOM-Parsing/) has the status "Editors Draft", since it is under active development. One major change is that [the definition of the `DOMParser` interface has been moved to the HTML spec](https://w3c.github.io/DOM-Parsing/#the-domparser-interface)
298
+
299
+
300
+ ### DOM
301
+
302
+ The original author claims that xmldom implements [DOM Level 2] in a "fully compatible" way and some parts of [DOM Level 3], but there are not enough tests to prove this. Both Specifications are now superseded by the [DOM Level 4 aka Living standard] wich has a much broader scope than xmldom.
303
+
304
+ xmldom implements the following interfaces (most constructors are currently not exposed):
305
+ - `Attr`
306
+ - `CDATASection`
307
+ - `CharacterData`
308
+ - `Comment`
309
+ - `Document`
310
+ - `DocumentFragment`
311
+ - `DocumentType`
312
+ - `DOMException` (constructor exposed)
313
+ - `DOMImplementation` (constructor exposed)
314
+ - `Element`
315
+ - `Entity`
316
+ - `EntityReference`
317
+ - `LiveNodeList`
318
+ - `NamedNodeMap`
319
+ - `Node` (constructor exposed)
320
+ - `NodeList`
321
+ - `Notation`
322
+ - `ProcessingInstruction`
323
+ - `Text`
324
+
325
+ more details are available in the (incomplete) [API Reference](#api-reference) section.
326
+
327
+ ### HTML
328
+
329
+ xmldom does not have any goal of supporting the full spec, but it has some capability to parse, report and serialize things differently when "detecting HTML" (by checking the default namespace).
330
+ There is an upcoming change to better align the implementation with the latest specs, related to <https://github.com/xmldom/xmldom/issues/203>.
331
+
332
+ ### SAX, XML, XMLNS
333
+
334
+ xmldom has an own SAX parser implementation to do the actual parsing, which implements some interfaces in alignment with the Java interfaces SAX defines:
335
+ - `XMLReader`
336
+ - `DOMHandler`
337
+
338
+ There is an idea/proposal to make ti possible to replace it with something else in <https://github.com/xmldom/xmldom/issues/55>