xml-toolkit 1.0.42 → 1.0.43
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/lib/AttributesMap.js +5 -29
- package/lib/NamespacesMap.js +20 -1
- package/lib/XMLPrinter.js +1 -1
- package/package.json +1 -1
package/lib/AttributesMap.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const CH_COLON = ':'.charCodeAt (0)
|
|
2
|
-
|
|
3
1
|
const AttributesMap = class extends Map {
|
|
4
2
|
|
|
5
3
|
constructor (entityResolver = null, nsMap = null) {
|
|
@@ -36,38 +34,16 @@ const AttributesMap = class extends Map {
|
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
}
|
|
39
|
-
|
|
37
|
+
|
|
40
38
|
set (k, v) {
|
|
41
39
|
|
|
42
|
-
const {_nsMap} = this
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (k.length === 5) {
|
|
47
|
-
|
|
48
|
-
_nsMap.set ('', v)
|
|
49
|
-
|
|
50
|
-
return this
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (k.charCodeAt (5) === CH_COLON) {
|
|
55
|
-
|
|
56
|
-
_nsMap.set (k.slice (6), v)
|
|
57
|
-
|
|
58
|
-
return this
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const {entityResolver} = this
|
|
40
|
+
const {_nsMap, entityResolver} = this
|
|
41
|
+
|
|
42
|
+
if (_nsMap !== null && k.startsWith ('xmlns') && _nsMap.processAttribute (k, v)) return this
|
|
67
43
|
|
|
68
44
|
return super.set (k,
|
|
69
45
|
|
|
70
|
-
v === '' ? null :
|
|
46
|
+
v === '' ? null :
|
|
71
47
|
|
|
72
48
|
entityResolver === null ? v :
|
|
73
49
|
|
package/lib/NamespacesMap.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const CH_COLON = ':'.charCodeAt (0)
|
|
2
|
+
|
|
1
3
|
const XMLNamespace = 'http://www.w3.org/XML/1998/namespace'
|
|
2
4
|
const XMLNamespacePrefix = 'xml'
|
|
3
5
|
|
|
@@ -24,9 +26,26 @@ const NamespacesMap = class extends Map {
|
|
|
24
26
|
|
|
25
27
|
super (parent.namespacesMap)
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
processAttribute (key, value) {
|
|
34
|
+
|
|
35
|
+
if (key.length === 5) {
|
|
36
|
+
|
|
37
|
+
this.set ('', this.default = value)
|
|
28
38
|
|
|
29
39
|
}
|
|
40
|
+
else {
|
|
41
|
+
|
|
42
|
+
if (key.charCodeAt (5) !== CH_COLON) return false
|
|
43
|
+
|
|
44
|
+
this.set (key.slice (6), value)
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return true
|
|
30
49
|
|
|
31
50
|
}
|
|
32
51
|
|
package/lib/XMLPrinter.js
CHANGED
|
@@ -198,7 +198,7 @@ const XMLPrinter = class {
|
|
|
198
198
|
|
|
199
199
|
this.openElement (node.name)
|
|
200
200
|
|
|
201
|
-
const {namespacesMap} = node; if (namespacesMap != null && namespacesMap.
|
|
201
|
+
const {namespacesMap} = node; if (namespacesMap != null && namespacesMap.default) this.writeAttribute ('xmlns', namespacesMap.default)
|
|
202
202
|
|
|
203
203
|
if (this.stack.length === 1) {
|
|
204
204
|
|