@xmldom/xmldom 0.8.1 → 0.8.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 +31 -8
- package/lib/conventions.js +26 -0
- package/lib/dom.js +18 -13
- package/lib/sax.js +16 -6
- package/package.json +7 -7
- package/readme.md +183 -166
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,29 @@ 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.3](https://github.com/xmldom/xmldom/compare/0.8.3...0.8.2)
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- Avoid iterating over prototype properties [`#437`](https://github.com/xmldom/xmldom/pull/437) / [`#436`](https://github.com/xmldom/xmldom/issues/436)
|
|
11
|
+
|
|
12
|
+
Thank you, [@Supraja9726](https://github.com/Supraja9726) for your contributions
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [0.8.2](https://github.com/xmldom/xmldom/compare/0.8.1...0.8.2)
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- fix(dom): Serialize `>` as specified (#395) [`#58`](https://github.com/xmldom/xmldom/issues/58)
|
|
19
|
+
|
|
20
|
+
### Other
|
|
21
|
+
- docs: Add `nodeType` values to public interface description [`#396`](https://github.com/xmldom/xmldom/pull/396)
|
|
22
|
+
- test: Add executable examples for node and typescript [`#317`](https://github.com/xmldom/xmldom/pull/317)
|
|
23
|
+
- fix(dom): Serialize `>` as specified [`#395`](https://github.com/xmldom/xmldom/pull/395)
|
|
24
|
+
- chore: Add minimal `Object.assign` ponyfill [`#379`](https://github.com/xmldom/xmldom/pull/379)
|
|
25
|
+
- docs: Refine release documentation [`#378`](https://github.com/xmldom/xmldom/pull/378)
|
|
26
|
+
- chore: update various dev dependencies
|
|
27
|
+
|
|
28
|
+
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
|
|
29
|
+
|
|
7
30
|
## [0.8.1](https://github.com/xmldom/xmldom/compare/0.8.0...0.8.1)
|
|
8
31
|
|
|
9
32
|
### Fixes
|
|
@@ -44,7 +67,7 @@ Thank you [@marrus-sh](https://github.com/marrus-sh), [@victorandree](https://gi
|
|
|
44
67
|
### Fixes:
|
|
45
68
|
|
|
46
69
|
- Preserve default namespace when serializing [`#319`](https://github.com/xmldom/xmldom/issues/319) / [`#321`](https://github.com/xmldom/xmldom/pull/321)
|
|
47
|
-
Thank you [@lupestro](https://github.com/lupestro)
|
|
70
|
+
Thank you, [@lupestro](https://github.com/lupestro)
|
|
48
71
|
|
|
49
72
|
## 0.7.4
|
|
50
73
|
|
|
@@ -53,7 +76,7 @@ Thank you [@marrus-sh](https://github.com/marrus-sh), [@victorandree](https://gi
|
|
|
53
76
|
### Fixes:
|
|
54
77
|
|
|
55
78
|
- Restore ability to parse `__prototype__` attributes [`#315`](https://github.com/xmldom/xmldom/pull/315)
|
|
56
|
-
Thank you [@dsimpsonOMF](https://github.com/dsimpsonOMF)
|
|
79
|
+
Thank you, [@dsimpsonOMF](https://github.com/dsimpsonOMF)
|
|
57
80
|
|
|
58
81
|
## 0.7.3
|
|
59
82
|
|
|
@@ -63,7 +86,7 @@ Thank you [@marrus-sh](https://github.com/marrus-sh), [@victorandree](https://gi
|
|
|
63
86
|
|
|
64
87
|
- Add doctype when parsing from string [`#277`](https://github.com/xmldom/xmldom/issues/277) / [`#301`](https://github.com/xmldom/xmldom/pull/301)
|
|
65
88
|
- Correct typo in error message [`#294`](https://github.com/xmldom/xmldom/pull/294)
|
|
66
|
-
Thank you [@rrthomas](https://github.com/rrthomas)
|
|
89
|
+
Thank you, [@rrthomas](https://github.com/rrthomas)
|
|
67
90
|
|
|
68
91
|
### Refactor:
|
|
69
92
|
|
|
@@ -88,7 +111,7 @@ Thank you [@marrus-sh](https://github.com/marrus-sh), [@victorandree](https://gi
|
|
|
88
111
|
### Fixes:
|
|
89
112
|
|
|
90
113
|
- Types: Add index.d.ts to packaged files [`#288`](https://github.com/xmldom/xmldom/pull/288)
|
|
91
|
-
Thank you [@forty](https://github.com/forty)
|
|
114
|
+
Thank you, [@forty](https://github.com/forty)
|
|
92
115
|
|
|
93
116
|
## 0.7.1
|
|
94
117
|
|
|
@@ -97,7 +120,7 @@ Thank you [@marrus-sh](https://github.com/marrus-sh), [@victorandree](https://gi
|
|
|
97
120
|
### Fixes:
|
|
98
121
|
|
|
99
122
|
- Types: Copy types from DefinitelyTyped [`#283`](https://github.com/xmldom/xmldom/pull/283)
|
|
100
|
-
Thank you [@kachkaev](https://github.com/kachkaev)
|
|
123
|
+
Thank you, [@kachkaev](https://github.com/kachkaev)
|
|
101
124
|
|
|
102
125
|
### Chore:
|
|
103
126
|
- package.json: remove author, maintainers, etc. [`#279`](https://github.com/xmldom/xmldom/pull/279)
|
|
@@ -114,7 +137,7 @@ For more details look at [`#278`](https://github.com/xmldom/xmldom/pull/278#issu
|
|
|
114
137
|
### Fixes:
|
|
115
138
|
|
|
116
139
|
- Security: Misinterpretation of malicious XML input [`CVE-2021-32796`](https://github.com/xmldom/xmldom/security/advisories/GHSA-5fg8-2547-mr8q)
|
|
117
|
-
- Implement `Document.getElementsByClassName` as specified [`#213`](https://github.com/xmldom/xmldom/pull/213), thank you [@ChALkeR](https://github.com/ChALkeR)
|
|
140
|
+
- Implement `Document.getElementsByClassName` as specified [`#213`](https://github.com/xmldom/xmldom/pull/213), thank you, [@ChALkeR](https://github.com/ChALkeR)
|
|
118
141
|
- Inherit namespace prefix from parent when required [`#268`](https://github.com/xmldom/xmldom/pull/268)
|
|
119
142
|
- Handle whitespace in closing tags [`#267`](https://github.com/xmldom/xmldom/pull/267)
|
|
120
143
|
- Update `DOMImplementation` according to recent specs [`#210`](https://github.com/xmldom/xmldom/pull/210)
|
|
@@ -122,7 +145,7 @@ For more details look at [`#278`](https://github.com/xmldom/xmldom/pull/278#issu
|
|
|
122
145
|
- No longer serializes any namespaces with an empty URI [`#244`](https://github.com/xmldom/xmldom/pull/244)
|
|
123
146
|
(related to [`#168`](https://github.com/xmldom/xmldom/pull/168) released in 0.6.0)
|
|
124
147
|
BREAKING CHANGE: Only if you rely on ["unsetting" a namespace prefix](https://github.com/xmldom/xmldom/pull/168#issuecomment-886984994) by setting it to an empty string
|
|
125
|
-
- Set `localName` as part of `Document.createElement` [`#229`](https://github.com/xmldom/xmldom/pull/229), thank you [@rrthomas](https://github.com/rrthomas)
|
|
148
|
+
- Set `localName` as part of `Document.createElement` [`#229`](https://github.com/xmldom/xmldom/pull/229), thank you, [@rrthomas](https://github.com/rrthomas)
|
|
126
149
|
|
|
127
150
|
### CI
|
|
128
151
|
|
|
@@ -141,7 +164,7 @@ For more details look at [`#278`](https://github.com/xmldom/xmldom/pull/278#issu
|
|
|
141
164
|
|
|
142
165
|
- Stop serializing empty namespace values like `xmlns:ds=""` [`#168`](https://github.com/xmldom/xmldom/pull/168)
|
|
143
166
|
BREAKING CHANGE: If your code expected empty namespaces attributes to be serialized.
|
|
144
|
-
Thank you [@pdecat](https://github.com/pdecat) and [@FranckDepoortere](https://github.com/FranckDepoortere)
|
|
167
|
+
Thank you, [@pdecat](https://github.com/pdecat) and [@FranckDepoortere](https://github.com/FranckDepoortere)
|
|
145
168
|
- Escape `<` to `<` when serializing attribute values [`#198`](https://github.com/xmldom/xmldom/issues/198) / [`#199`](https://github.com/xmldom/xmldom/pull/199)
|
|
146
169
|
|
|
147
170
|
## 0.5.0
|
package/lib/conventions.js
CHANGED
|
@@ -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.js
CHANGED
|
@@ -62,7 +62,9 @@ function arrayIncludes (list) {
|
|
|
62
62
|
|
|
63
63
|
function copy(src,dest){
|
|
64
64
|
for(var p in src){
|
|
65
|
-
|
|
65
|
+
if (Object.prototype.hasOwnProperty.call(src, p)) {
|
|
66
|
+
dest[p] = src[p];
|
|
67
|
+
}
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
|
|
@@ -509,9 +511,9 @@ Node.prototype = {
|
|
|
509
511
|
//console.dir(map)
|
|
510
512
|
if(map){
|
|
511
513
|
for(var n in map){
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
514
|
+
if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
|
|
515
|
+
return n;
|
|
516
|
+
}
|
|
515
517
|
}
|
|
516
518
|
}
|
|
517
519
|
el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
|
|
@@ -525,7 +527,7 @@ Node.prototype = {
|
|
|
525
527
|
var map = el._nsMap;
|
|
526
528
|
//console.dir(map)
|
|
527
529
|
if(map){
|
|
528
|
-
if(prefix
|
|
530
|
+
if(Object.prototype.hasOwnProperty.call(map, prefix)){
|
|
529
531
|
return map[prefix] ;
|
|
530
532
|
}
|
|
531
533
|
}
|
|
@@ -1187,9 +1189,10 @@ function needNamespaceDefine(node, isHTML, visibleNamespaces) {
|
|
|
1187
1189
|
* are serialized as their entity references, so they will be preserved.
|
|
1188
1190
|
* (In contrast to whitespace literals in the input which are normalized to spaces)
|
|
1189
1191
|
* @see https://www.w3.org/TR/xml11/#AVNormalize
|
|
1192
|
+
* @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes
|
|
1190
1193
|
*/
|
|
1191
1194
|
function addSerializedAttribute(buf, qualifiedName, value) {
|
|
1192
|
-
buf.push(' ', qualifiedName, '="', value.replace(/[
|
|
1195
|
+
buf.push(' ', qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"')
|
|
1193
1196
|
}
|
|
1194
1197
|
|
|
1195
1198
|
function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
|
@@ -1334,10 +1337,10 @@ function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
|
|
|
1334
1337
|
* and does not include the CDATA-section-close delimiter, `]]>`.
|
|
1335
1338
|
*
|
|
1336
1339
|
* @see https://www.w3.org/TR/xml/#NT-CharData
|
|
1340
|
+
* @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
|
|
1337
1341
|
*/
|
|
1338
1342
|
return buf.push(node.data
|
|
1339
|
-
.replace(/[
|
|
1340
|
-
.replace(/]]>/g, ']]>')
|
|
1343
|
+
.replace(/[<&>]/g,_xmlEncoder)
|
|
1341
1344
|
);
|
|
1342
1345
|
case CDATA_SECTION_NODE:
|
|
1343
1346
|
return buf.push( '<![CDATA[',node.data,']]>');
|
|
@@ -1423,11 +1426,13 @@ function importNode(doc,node,deep){
|
|
|
1423
1426
|
// attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
|
|
1424
1427
|
function cloneNode(doc,node,deep){
|
|
1425
1428
|
var node2 = new node.constructor();
|
|
1426
|
-
for(var n in node){
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
if(v !=
|
|
1430
|
-
node2[n]
|
|
1429
|
+
for (var n in node) {
|
|
1430
|
+
if (Object.prototype.hasOwnProperty.call(node, n)) {
|
|
1431
|
+
var v = node[n];
|
|
1432
|
+
if (typeof v != "object") {
|
|
1433
|
+
if (v != node2[n]) {
|
|
1434
|
+
node2[n] = v;
|
|
1435
|
+
}
|
|
1431
1436
|
}
|
|
1432
1437
|
}
|
|
1433
1438
|
}
|
package/lib/sax.js
CHANGED
|
@@ -135,8 +135,10 @@ function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
|
|
|
135
135
|
if(endIgnoreCaseMach){
|
|
136
136
|
domBuilder.endElement(config.uri,config.localName,tagName);
|
|
137
137
|
if(localNSMap){
|
|
138
|
-
for(var prefix in localNSMap){
|
|
139
|
-
|
|
138
|
+
for (var prefix in localNSMap) {
|
|
139
|
+
if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
|
|
140
|
+
domBuilder.endPrefixMapping(prefix);
|
|
141
|
+
}
|
|
140
142
|
}
|
|
141
143
|
}
|
|
142
144
|
if(!endMatch){
|
|
@@ -478,8 +480,10 @@ function appendElement(el,domBuilder,currentNSMap){
|
|
|
478
480
|
if(el.closed){
|
|
479
481
|
domBuilder.endElement(ns,localName,tagName);
|
|
480
482
|
if(localNSMap){
|
|
481
|
-
for(prefix in localNSMap){
|
|
482
|
-
|
|
483
|
+
for (prefix in localNSMap) {
|
|
484
|
+
if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
|
|
485
|
+
domBuilder.endPrefixMapping(prefix);
|
|
486
|
+
}
|
|
483
487
|
}
|
|
484
488
|
}
|
|
485
489
|
}else{
|
|
@@ -525,9 +529,15 @@ function fixSelfClosed(source,elStartEnd,tagName,closeMap){
|
|
|
525
529
|
return pos<elStartEnd;
|
|
526
530
|
//}
|
|
527
531
|
}
|
|
528
|
-
|
|
529
|
-
|
|
532
|
+
|
|
533
|
+
function _copy (source, target) {
|
|
534
|
+
for (var n in source) {
|
|
535
|
+
if (Object.prototype.hasOwnProperty.call(source, n)) {
|
|
536
|
+
target[n] = source[n];
|
|
537
|
+
}
|
|
538
|
+
}
|
|
530
539
|
}
|
|
540
|
+
|
|
531
541
|
function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
|
|
532
542
|
var next= source.charAt(start+2)
|
|
533
543
|
switch(next){
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmldom/xmldom",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.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",
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@stryker-mutator/core": "5.6.1",
|
|
46
46
|
"auto-changelog": "2.4.0",
|
|
47
|
-
"eslint": "8.
|
|
48
|
-
"eslint-config-prettier": "8.
|
|
47
|
+
"eslint": "8.25.0",
|
|
48
|
+
"eslint-config-prettier": "8.5.0",
|
|
49
49
|
"eslint-plugin-es5": "1.5.0",
|
|
50
|
-
"eslint-plugin-prettier": "4.
|
|
50
|
+
"eslint-plugin-prettier": "4.2.1",
|
|
51
51
|
"get-stream": "6.0.1",
|
|
52
52
|
"jest": "27.5.1",
|
|
53
|
-
"nodemon": "2.0.
|
|
54
|
-
"np": "7.6.
|
|
55
|
-
"prettier": "2.
|
|
53
|
+
"nodemon": "2.0.20",
|
|
54
|
+
"np": "7.6.2",
|
|
55
|
+
"prettier": "2.7.1",
|
|
56
56
|
"xmltest": "1.5.0",
|
|
57
57
|
"yauzl": "2.10.0"
|
|
58
58
|
},
|
package/readme.md
CHANGED
|
@@ -41,28 +41,23 @@ This project was forked from it's [original source](https://github.com/jindw/xml
|
|
|
41
41
|
|
|
42
42
|
### Example:
|
|
43
43
|
|
|
44
|
+
[In NodeJS](examples/nodejs/src/index.js)
|
|
44
45
|
```javascript
|
|
45
|
-
const { DOMParser } = require('@xmldom/xmldom')
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
)
|
|
55
|
-
doc.documentElement.setAttribute('x', 'y')
|
|
56
|
-
doc.documentElement.setAttributeNS('./lite', 'c:x', 'y2')
|
|
57
|
-
console.info(doc)
|
|
58
|
-
|
|
59
|
-
const nsAttr = doc.documentElement.getAttributeNS('./lite', 'x')
|
|
60
|
-
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)
|
|
61
56
|
```
|
|
62
57
|
|
|
63
|
-
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:
|
|
64
59
|
|
|
65
|
-
```
|
|
60
|
+
```typescript
|
|
66
61
|
import { DOMParser } from '@xmldom/xmldom'
|
|
67
62
|
```
|
|
68
63
|
|
|
@@ -103,182 +98,204 @@ import { DOMParser } from '@xmldom/xmldom'
|
|
|
103
98
|
```
|
|
104
99
|
### DOM level2 method and attribute:
|
|
105
100
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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`
|
|
124
122
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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`)
|
|
140
156
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
This property is of type Number.
|
|
157
|
+
attributes:
|
|
158
|
+
- `code` with a value matching one of the above constants.
|
|
144
159
|
|
|
145
|
-
|
|
160
|
+
* [DOMImplementation](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-102161490)
|
|
146
161
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
createDocumentType(qualifiedName, publicId, systemId)
|
|
152
|
-
createDocument(namespaceURI, qualifiedName, doctype)
|
|
162
|
+
method:
|
|
163
|
+
- `hasFeature(feature, version)`
|
|
164
|
+
- `createDocumentType(qualifiedName, publicId, systemId)`
|
|
165
|
+
- `createDocument(namespaceURI, qualifiedName, doctype)`
|
|
153
166
|
|
|
154
|
-
|
|
167
|
+
* [Document](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#i-Document) : Node
|
|
155
168
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
|
176
190
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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)
|
|
204
220
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
221
|
+
readonly attribute:
|
|
222
|
+
- `length`
|
|
223
|
+
|
|
224
|
+
method:
|
|
225
|
+
- `item(index)`
|
|
209
226
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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)`
|
|
222
240
|
|
|
223
|
-
|
|
241
|
+
* [CharacterData](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-FF21A306) : Node
|
|
224
242
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
243
|
+
method:
|
|
244
|
+
- `substringData(offset, count)`
|
|
245
|
+
- `appendData(arg)`
|
|
246
|
+
- `insertData(offset, arg)`
|
|
247
|
+
- `deleteData(offset, count)`
|
|
248
|
+
- `replaceData(offset, count, arg)`
|
|
231
249
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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)`
|
|
236
254
|
|
|
237
|
-
|
|
238
|
-
|
|
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
|
|
239
257
|
|
|
240
|
-
|
|
258
|
+
* [DocumentType](http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-412266927)
|
|
241
259
|
|
|
242
|
-
|
|
243
|
-
|
|
260
|
+
readonly attribute:
|
|
261
|
+
- `name` | `entities` | `notations` | `publicId` | `systemId` | `internalSubset`
|
|
244
262
|
|
|
245
|
-
|
|
263
|
+
* Notation : Node
|
|
246
264
|
|
|
247
|
-
|
|
248
|
-
|
|
265
|
+
readonly attribute:
|
|
266
|
+
- `publicId` | `systemId`
|
|
249
267
|
|
|
250
|
-
|
|
268
|
+
* Entity : Node
|
|
251
269
|
|
|
252
|
-
|
|
253
|
-
|
|
270
|
+
readonly attribute:
|
|
271
|
+
- `publicId` | `systemId` | `notationName`
|
|
254
272
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
273
|
+
* EntityReference : Node
|
|
274
|
+
* ProcessingInstruction : Node
|
|
275
|
+
|
|
276
|
+
attribute:
|
|
277
|
+
- `data`
|
|
278
|
+
readonly attribute:
|
|
279
|
+
- `target`
|
|
262
280
|
|
|
263
281
|
### DOM level 3 support:
|
|
264
282
|
|
|
265
|
-
|
|
283
|
+
* [Node](http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-textContent)
|
|
266
284
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
285
|
+
attribute:
|
|
286
|
+
- `textContent`
|
|
287
|
+
|
|
288
|
+
method:
|
|
289
|
+
- `isDefaultNamespace(namespaceURI)`
|
|
290
|
+
- `lookupNamespaceURI(prefix)`
|
|
272
291
|
|
|
273
292
|
### DOM extension by xmldom
|
|
274
293
|
|
|
275
294
|
* [Node] Source position extension;
|
|
276
295
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
//Numbered starting from '1'
|
|
281
|
-
columnNumber
|
|
296
|
+
attribute:
|
|
297
|
+
- `lineNumber` //number starting from `1`
|
|
298
|
+
- `columnNumber` //number starting from `1`
|
|
282
299
|
|
|
283
300
|
## Specs
|
|
284
301
|
|
|
@@ -336,4 +353,4 @@ xmldom has an own SAX parser implementation to do the actual parsing, which impl
|
|
|
336
353
|
- `XMLReader`
|
|
337
354
|
- `DOMHandler`
|
|
338
355
|
|
|
339
|
-
There is an idea/proposal to make
|
|
356
|
+
There is an idea/proposal to make it possible to replace it with something else in <https://github.com/xmldom/xmldom/issues/55>
|