@xmldom/xmldom 0.8.10 → 0.9.0-beta.10
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 +238 -0
- package/SECURITY.md +8 -8
- package/index.d.ts +390 -40
- package/lib/.eslintrc.yml +1 -0
- package/lib/conventions.js +280 -59
- package/lib/dom-parser.js +435 -181
- package/lib/dom.js +1311 -840
- package/lib/entities.js +14 -9
- package/lib/grammar.js +516 -0
- package/lib/index.js +20 -4
- package/lib/sax.js +676 -468
- package/package.json +14 -12
- package/readme.md +31 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmldom/xmldom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0-beta.10",
|
|
4
4
|
"description": "A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"w3c",
|
|
@@ -28,33 +28,35 @@
|
|
|
28
28
|
"lib"
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
|
-
"lint": "eslint lib test",
|
|
32
|
-
"format": "prettier --write test",
|
|
31
|
+
"lint": "eslint examples lib test",
|
|
32
|
+
"format": "prettier --write examples lib test",
|
|
33
33
|
"changelog": "auto-changelog --unreleased-only",
|
|
34
34
|
"start": "nodemon --watch package.json --watch lib --watch test --exec 'npm --silent run test && npm --silent run lint'",
|
|
35
|
-
"stryker": "stryker run",
|
|
36
|
-
"stryker:dry-run": "stryker run -m '' --reporters progress",
|
|
37
35
|
"test": "jest",
|
|
36
|
+
"test:types": "cd examples/typescript-node-es6 && ./pretest.sh 3 && ./pretest.sh 4 && ./pretest.sh 5 && node dist/index.js",
|
|
38
37
|
"testrelease": "npm test && eslint lib",
|
|
39
38
|
"version": "./changelog-has-version.sh",
|
|
40
|
-
"release": "np --no-yarn --test-script testrelease
|
|
39
|
+
"release": "np --no-yarn --test-script testrelease"
|
|
41
40
|
},
|
|
42
41
|
"engines": {
|
|
43
42
|
"node": ">=10.0.0"
|
|
44
43
|
},
|
|
45
44
|
"dependencies": {},
|
|
46
45
|
"devDependencies": {
|
|
47
|
-
"@
|
|
46
|
+
"@homer0/prettier-plugin-jsdoc": "6.0.5",
|
|
48
47
|
"auto-changelog": "2.4.0",
|
|
49
|
-
"eslint": "8.
|
|
50
|
-
"eslint-config-prettier": "8.
|
|
48
|
+
"eslint": "8.44.0",
|
|
49
|
+
"eslint-config-prettier": "8.8.0",
|
|
50
|
+
"eslint-plugin-anti-trojan-source": "1.1.1",
|
|
51
51
|
"eslint-plugin-es5": "1.5.0",
|
|
52
|
+
"eslint-plugin-node": "11.1.0",
|
|
52
53
|
"eslint-plugin-prettier": "4.2.1",
|
|
53
54
|
"get-stream": "6.0.1",
|
|
54
55
|
"jest": "27.5.1",
|
|
55
|
-
"nodemon": "
|
|
56
|
-
"np": "7.
|
|
57
|
-
"prettier": "2.
|
|
56
|
+
"nodemon": "3.0.1",
|
|
57
|
+
"np": "7.7.0",
|
|
58
|
+
"prettier": "2.8.8",
|
|
59
|
+
"rxjs": "7.8.1",
|
|
58
60
|
"xmltest": "1.5.0",
|
|
59
61
|
"yauzl": "2.10.0"
|
|
60
62
|
},
|
package/readme.md
CHANGED
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
*For better readability in the docs we will continue to talk about this library as "xmldom".*
|
|
5
5
|
|
|
6
6
|
[](https://github.com/xmldom/xmldom/blob/master/LICENSE)
|
|
7
|
-
[](https://socket.dev/npm/package/@xmldom/xmldom)
|
|
8
8
|
[](https://snyk.io/advisor/npm-package/@xmldom/xmldom)
|
|
9
|
+
|
|
10
|
+
[](https://www.npmjs.com/package/@xmldom/xmldom)
|
|
11
|
+
[](https://www.npmjs.com/package/@xmldom/xmldom?activeTab=versions)
|
|
12
|
+
[](https://www.npmjs.com/package/@xmldom/xmldom?activeTab=versions)
|
|
13
|
+
|
|
9
14
|
[](https://github.com/xmldom/xmldom/issues?q=is%3Aissue+is%3Aopen+label%3Abug)
|
|
10
15
|
[](https://github.com/xmldom/xmldom/issues?q=is%3Aissue+is%3Aopen+label%3Ahelp-wanted)
|
|
11
|
-
[](https://dashboard.stryker-mutator.io/reports/github.com/xmldom/xmldom/master)
|
|
12
|
-
|
|
13
16
|
|
|
14
17
|
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:
|
|
15
18
|
- convert an XML string into a DOM tree
|
|
@@ -55,7 +58,7 @@ const doc = new DOMParser().parseFromString(source, 'text/xml')
|
|
|
55
58
|
const serialized = new XMLSerializer().serializeToString(doc)
|
|
56
59
|
```
|
|
57
60
|
|
|
58
|
-
Note: in Typescript
|
|
61
|
+
Note: in Typescript ~~and ES6~~ (see [#316](https://github.com/xmldom/xmldom/issues/316)) you can use the `import` approach, as follows:
|
|
59
62
|
|
|
60
63
|
```typescript
|
|
61
64
|
import { DOMParser } from '@xmldom/xmldom'
|
|
@@ -63,33 +66,18 @@ import { DOMParser } from '@xmldom/xmldom'
|
|
|
63
66
|
|
|
64
67
|
## API Reference
|
|
65
68
|
|
|
66
|
-
|
|
69
|
+
* [DOMParser](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser):
|
|
67
70
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
```javascript
|
|
72
|
+
parseFromString(xmlsource, mimeType)
|
|
73
|
+
```
|
|
74
|
+
* **options extension** _by xmldom_ (not DOM standard!!)
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
new DOMParser({
|
|
79
|
-
/**
|
|
80
|
-
* locator is always need for error position info
|
|
81
|
-
*/
|
|
82
|
-
locator:{},
|
|
83
|
-
/**
|
|
84
|
-
* you can override the errorHandler for xml parser
|
|
85
|
-
* @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
|
|
86
|
-
*/
|
|
87
|
-
errorHandler:{warning:function(w){console.warn(w)},error:callback,fatalError:callback}
|
|
88
|
-
//only callback model
|
|
89
|
-
//errorHandler:function(level,msg){console.log(level,msg)}
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
```
|
|
76
|
+
```javascript
|
|
77
|
+
// the options argument can be used to modify behavior
|
|
78
|
+
// for more details check the documentation on the code or type definition
|
|
79
|
+
new DOMParser(options)
|
|
80
|
+
```
|
|
93
81
|
|
|
94
82
|
* [XMLSerializer](https://developer.mozilla.org/en-US/docs/Web/API/XMLSerializer)
|
|
95
83
|
|
|
@@ -160,7 +148,7 @@ import { DOMParser } from '@xmldom/xmldom'
|
|
|
160
148
|
* [DOMImplementation](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-102161490)
|
|
161
149
|
|
|
162
150
|
method:
|
|
163
|
-
- `hasFeature(feature, version)`
|
|
151
|
+
- `hasFeature(feature, version)` (deprecated)
|
|
164
152
|
- `createDocumentType(qualifiedName, publicId, systemId)`
|
|
165
153
|
- `createDocument(namespaceURI, qualifiedName, doctype)`
|
|
166
154
|
|
|
@@ -318,24 +306,26 @@ Note: [The latest version of this spec](https://w3c.github.io/DOM-Parsing/) has
|
|
|
318
306
|
### DOM
|
|
319
307
|
|
|
320
308
|
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.
|
|
309
|
+
In the past there have been multiple (even breaking) changes to align xmldom with the living standard,
|
|
310
|
+
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).
|
|
321
311
|
|
|
322
|
-
xmldom implements the following interfaces (
|
|
323
|
-
- `Attr`
|
|
312
|
+
xmldom implements the following interfaces (only the ones marked with `*` are currently exposed):
|
|
313
|
+
- `Attr` *
|
|
324
314
|
- `CDATASection`
|
|
325
315
|
- `CharacterData`
|
|
326
316
|
- `Comment`
|
|
327
|
-
- `Document`
|
|
317
|
+
- `Document` *
|
|
328
318
|
- `DocumentFragment`
|
|
329
|
-
- `DocumentType`
|
|
330
|
-
- `DOMException`
|
|
331
|
-
- `DOMImplementation`
|
|
332
|
-
- `Element`
|
|
319
|
+
- `DocumentType` *
|
|
320
|
+
- `DOMException` *
|
|
321
|
+
- `DOMImplementation` *
|
|
322
|
+
- `Element` *
|
|
333
323
|
- `Entity`
|
|
334
324
|
- `EntityReference`
|
|
335
325
|
- `LiveNodeList`
|
|
336
|
-
- `NamedNodeMap`
|
|
337
|
-
- `Node`
|
|
338
|
-
- `NodeList`
|
|
326
|
+
- `NamedNodeMap` *
|
|
327
|
+
- `Node` *
|
|
328
|
+
- `NodeList` *
|
|
339
329
|
- `Notation`
|
|
340
330
|
- `ProcessingInstruction`
|
|
341
331
|
- `Text`
|
|
@@ -344,8 +334,7 @@ more details are available in the (incomplete) [API Reference](#api-reference) s
|
|
|
344
334
|
|
|
345
335
|
### HTML
|
|
346
336
|
|
|
347
|
-
xmldom does not have any goal of supporting the full spec, but it has some capability to parse, report and serialize things differently when
|
|
348
|
-
There is an upcoming change to better align the implementation with the latest specs, related to <https://github.com/xmldom/xmldom/issues/203>.
|
|
337
|
+
xmldom does not have any goal of supporting the full spec, but it has some capability to parse, report and serialize things differently when it is told to parse HTML (by passing the HTML namespace).
|
|
349
338
|
|
|
350
339
|
### SAX, XML, XMLNS
|
|
351
340
|
|