@xmldom/xmldom 0.9.7 → 0.9.9
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 +66 -0
- package/index.d.ts +75 -5
- package/lib/dom-parser.js +10 -6
- package/lib/dom.js +59 -2
- package/lib/index.js +1 -0
- package/lib/sax.js +9 -9
- package/package.json +11 -12
- package/readme.md +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,72 @@ 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.9.9](https://github.com/xmldom/xmldom/compare/0.9.8...0.9.9)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- implement `ParentNode.children` getter [`#960`](https://github.com/xmldom/xmldom/pull/960) / [`#410`](https://github.com/xmldom/xmldom/issues/410)
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Security: `createCDATASection` now throws `InvalidCharacterError` when `data` contains `"]]>"`, as required by the [WHATWG DOM spec](https://dom.spec.whatwg.org/#dom-document-createcdatasection). [`GHSA-wh4c-j3r5-mjhp`](https://github.com/xmldom/xmldom/security/advisories/GHSA-wh4c-j3r5-mjhp)
|
|
16
|
+
- Security: `XMLSerializer` now splits CDATASection nodes whose data contains `"]]>"` into adjacent CDATA sections at serialization time, preventing XML injection via mutation methods (`appendData`, `replaceData`, `.data =`, `.textContent =`). [`GHSA-wh4c-j3r5-mjhp`](https://github.com/xmldom/xmldom/security/advisories/GHSA-wh4c-j3r5-mjhp)
|
|
17
|
+
- correctly traverse ancestor chain in `Node.contains` [`#931`](https://github.com/xmldom/xmldom/pull/931)
|
|
18
|
+
|
|
19
|
+
Code that passes a string containing `"]]>"` to `createCDATASection` and relied on the previously unsafe behavior will now receive `InvalidCharacterError`. Use a mutation method such as `appendData` if you intentionally need `"]]>"` in a CDATASection node's data.
|
|
20
|
+
|
|
21
|
+
### Chore
|
|
22
|
+
|
|
23
|
+
- updated dependencies
|
|
24
|
+
|
|
25
|
+
Thank you,
|
|
26
|
+
[@stevenobiajulu](https://github.com/stevenobiajulu),
|
|
27
|
+
[@yoshi389111](https://github.com/yoshi389111),
|
|
28
|
+
[@thesmartshadow](https://github.com/thesmartshadow),
|
|
29
|
+
for your contributions
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## [0.8.12](https://github.com/xmldom/xmldom/compare/0.8.11...0.8.12)
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- preserve trailing whitespace in ProcessingInstruction data [`#962`](https://github.com/xmldom/xmldom/pull/962) / [`#42`](https://github.com/xmldom/xmldom/issues/42)
|
|
37
|
+
- Security: `createCDATASection` now throws `InvalidCharacterError` when `data` contains `"]]>"`, as required by the [WHATWG DOM spec](https://dom.spec.whatwg.org/#dom-document-createcdatasection). [`GHSA-wh4c-j3r5-mjhp`](https://github.com/xmldom/xmldom/security/advisories/GHSA-wh4c-j3r5-mjhp)
|
|
38
|
+
- Security: `XMLSerializer` now splits CDATASection nodes whose data contains `"]]>"` into adjacent CDATA sections at serialization time, preventing XML injection via mutation methods (`appendData`, `replaceData`, `.data =`, `.textContent =`). [`GHSA-wh4c-j3r5-mjhp`](https://github.com/xmldom/xmldom/security/advisories/GHSA-wh4c-j3r5-mjhp)
|
|
39
|
+
|
|
40
|
+
Code that passes a string containing `"]]>"` to `createCDATASection` and relied on the previously unsafe behavior will now receive `InvalidCharacterError`. Use a mutation method such as `appendData` if you intentionally need `"]]>"` in a CDATASection node's data.
|
|
41
|
+
|
|
42
|
+
Thank you,
|
|
43
|
+
[@thesmartshadow](https://github.com/thesmartshadow),
|
|
44
|
+
[@stevenobiajulu](https://github.com/stevenobiajulu),
|
|
45
|
+
for your contributions
|
|
46
|
+
|
|
47
|
+
## [0.8.11](https://github.com/xmldom/xmldom/compare/0.8.10...0.8.11)
|
|
48
|
+
|
|
49
|
+
### Fixed
|
|
50
|
+
|
|
51
|
+
- update `ownerDocument` when moving nodes between documents [`#933`](https://github.com/xmldom/xmldom/pull/933) / [`#932`](https://github.com/xmldom/xmldom/issues/932)
|
|
52
|
+
|
|
53
|
+
Thank you, [@shunkica](https://github.com/shunkica), for your contributions
|
|
54
|
+
|
|
55
|
+
## [0.9.8](https://github.com/xmldom/xmldom/compare/0.9.8...0.9.7)
|
|
56
|
+
|
|
57
|
+
### Fixed
|
|
58
|
+
|
|
59
|
+
- fix: replace \u2029 as part of normalizeLineEndings [`#839`](https://github.com/xmldom/xmldom/pull/839) / [`#838`](https://github.com/xmldom/xmldom/issues/838)
|
|
60
|
+
- perf: speed up line detection [`#847`](https://github.com/xmldom/xmldom/pull/847) / [`#838`](https://github.com/xmldom/xmldom/issues/838)
|
|
61
|
+
|
|
62
|
+
### Chore
|
|
63
|
+
|
|
64
|
+
- updated dependencies
|
|
65
|
+
- drop jazzer and rxjs devDependencies [`#845`](https://github.com/xmldom/xmldom/pull/845)
|
|
66
|
+
|
|
67
|
+
Thank you,
|
|
68
|
+
[@kboshold](https://github.com/kboshold),
|
|
69
|
+
[@Ponynjaa](https://github.com/Ponynjaa),
|
|
70
|
+
for your contributions.
|
|
71
|
+
|
|
72
|
+
|
|
7
73
|
## [0.9.7](https://github.com/xmldom/xmldom/compare/0.9.6...0.9.7)
|
|
8
74
|
|
|
9
75
|
### Added
|
package/index.d.ts
CHANGED
|
@@ -827,6 +827,15 @@ declare module '@xmldom/xmldom' {
|
|
|
827
827
|
*/
|
|
828
828
|
readonly tagName: string;
|
|
829
829
|
|
|
830
|
+
/**
|
|
831
|
+
* Returns a live collection of the direct child elements of this element.
|
|
832
|
+
*
|
|
833
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Element/children)
|
|
834
|
+
*
|
|
835
|
+
* @see https://dom.spec.whatwg.org/#dom-parentnode-children
|
|
836
|
+
*/
|
|
837
|
+
readonly children: LiveNodeList<Element>;
|
|
838
|
+
|
|
830
839
|
/**
|
|
831
840
|
* Returns element's first attribute whose qualified name is qualifiedName, and null if there
|
|
832
841
|
* is no such attribute otherwise.
|
|
@@ -1085,6 +1094,16 @@ declare module '@xmldom/xmldom' {
|
|
|
1085
1094
|
*/
|
|
1086
1095
|
interface DocumentFragment extends Node {
|
|
1087
1096
|
readonly ownerDocument: Document;
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* Returns a live collection of the direct child elements of this document fragment.
|
|
1100
|
+
*
|
|
1101
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/DocumentFragment/children)
|
|
1102
|
+
*
|
|
1103
|
+
* @see https://dom.spec.whatwg.org/#dom-parentnode-children
|
|
1104
|
+
*/
|
|
1105
|
+
readonly children: LiveNodeList<Element>;
|
|
1106
|
+
|
|
1088
1107
|
getElementById(elementId: string): Element | null;
|
|
1089
1108
|
}
|
|
1090
1109
|
var DocumentFragment: InstanceOf<DocumentFragment>;
|
|
@@ -1152,6 +1171,15 @@ declare module '@xmldom/xmldom' {
|
|
|
1152
1171
|
*/
|
|
1153
1172
|
readonly documentElement: Element | null;
|
|
1154
1173
|
|
|
1174
|
+
/**
|
|
1175
|
+
* Returns a live collection of the direct child elements of this document.
|
|
1176
|
+
*
|
|
1177
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Document/children)
|
|
1178
|
+
*
|
|
1179
|
+
* @see https://dom.spec.whatwg.org/#dom-parentnode-children
|
|
1180
|
+
*/
|
|
1181
|
+
readonly children: LiveNodeList<Element>;
|
|
1182
|
+
|
|
1155
1183
|
/**
|
|
1156
1184
|
* Creates an attribute object with a specified name.
|
|
1157
1185
|
*
|
|
@@ -1163,9 +1191,15 @@ declare module '@xmldom/xmldom' {
|
|
|
1163
1191
|
createAttributeNS(namespace: string | null, qualifiedName: string): Attr;
|
|
1164
1192
|
|
|
1165
1193
|
/**
|
|
1166
|
-
* Returns a CDATASection node whose data is data
|
|
1194
|
+
* Returns a new CDATASection node whose data is `data`.
|
|
1167
1195
|
*
|
|
1168
|
-
*
|
|
1196
|
+
* __This implementation differs from the specification:__ - calling this method on an HTML
|
|
1197
|
+
* document does not throw `NotSupportedError`.
|
|
1198
|
+
*
|
|
1199
|
+
* @throws {DOMException}
|
|
1200
|
+
* With code `INVALID_CHARACTER_ERR` if `data` contains `"]]>"`.
|
|
1201
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createCDATASection
|
|
1202
|
+
* @see https://dom.spec.whatwg.org/#dom-document-createcdatasection
|
|
1169
1203
|
*/
|
|
1170
1204
|
createCDATASection(data: string): CDATASection;
|
|
1171
1205
|
|
|
@@ -1430,6 +1464,16 @@ declare module '@xmldom/xmldom' {
|
|
|
1430
1464
|
}
|
|
1431
1465
|
|
|
1432
1466
|
class XMLSerializer {
|
|
1467
|
+
/**
|
|
1468
|
+
* Returns the result of serializing `node` to XML.
|
|
1469
|
+
*
|
|
1470
|
+
* __This implementation differs from the specification:__ - CDATASection nodes whose data
|
|
1471
|
+
* contains `]]>` are serialized by splitting the section at each `]]>` occurrence (following
|
|
1472
|
+
* W3C DOM Level 3 Core `split-cdata-sections`
|
|
1473
|
+
* default behaviour). A configurable option is not yet implemented.
|
|
1474
|
+
*
|
|
1475
|
+
* @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
|
|
1476
|
+
*/
|
|
1433
1477
|
serializeToString(node: Node, nodeFilter?: (node: Node) => boolean): string;
|
|
1434
1478
|
}
|
|
1435
1479
|
// END ./lib/dom.js
|
|
@@ -1527,12 +1571,15 @@ declare module '@xmldom/xmldom' {
|
|
|
1527
1571
|
readonly locator?: boolean;
|
|
1528
1572
|
|
|
1529
1573
|
/**
|
|
1530
|
-
* used to replace line endings before parsing, defaults to `normalizeLineEndings`,
|
|
1531
|
-
* which normalizes line endings according to <https://www.w3.org/TR/xml11/#sec-line-ends
|
|
1574
|
+
* used to replace line endings before parsing, defaults to exported `normalizeLineEndings`,
|
|
1575
|
+
* which normalizes line endings according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
|
|
1576
|
+
* including some Unicode "newline" characters.
|
|
1577
|
+
*
|
|
1578
|
+
* @see {@link normalizeLineEndings}
|
|
1532
1579
|
*/
|
|
1533
1580
|
readonly normalizeLineEndings?: (source: string) => string;
|
|
1534
1581
|
/**
|
|
1535
|
-
* A function
|
|
1582
|
+
* A function invoked for every error that occurs during parsing.
|
|
1536
1583
|
*
|
|
1537
1584
|
* If it is not provided, all errors are reported to `console.error`
|
|
1538
1585
|
* and only `fatalError`s are thrown as a `ParseError`,
|
|
@@ -1572,6 +1619,29 @@ declare module '@xmldom/xmldom' {
|
|
|
1572
1619
|
): void;
|
|
1573
1620
|
}
|
|
1574
1621
|
|
|
1622
|
+
/**
|
|
1623
|
+
* Normalizes line ending according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
|
|
1624
|
+
* including some Unicode "newline" characters:
|
|
1625
|
+
*
|
|
1626
|
+
* > XML parsed entities are often stored in computer files which,
|
|
1627
|
+
* > for editing convenience, are organized into lines.
|
|
1628
|
+
* > These lines are typically separated by some combination
|
|
1629
|
+
* > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).
|
|
1630
|
+
* >
|
|
1631
|
+
* > To simplify the tasks of applications, the XML processor must behave
|
|
1632
|
+
* > as if it normalized all line breaks in external parsed entities (including the document entity)
|
|
1633
|
+
* > on input, before parsing, by translating the following to a single #xA character:
|
|
1634
|
+
* >
|
|
1635
|
+
* > 1. the two-character sequence #xD #xA,
|
|
1636
|
+
* > 2. the two-character sequence #xD #x85,
|
|
1637
|
+
* > 3. the single character #x85,
|
|
1638
|
+
* > 4. the single character #x2028,
|
|
1639
|
+
* > 5. the single character #x2029,
|
|
1640
|
+
* > 6. any #xD character that is not immediately followed by #xA or #x85.
|
|
1641
|
+
*
|
|
1642
|
+
* @prettierignore
|
|
1643
|
+
*/
|
|
1644
|
+
function normalizeLineEndings(input: string): string;
|
|
1575
1645
|
/**
|
|
1576
1646
|
* A method that prevents any further parsing when an `error`
|
|
1577
1647
|
* with level `error` is reported during parsing.
|
package/lib/dom-parser.js
CHANGED
|
@@ -18,7 +18,8 @@ var ParseError = errors.ParseError;
|
|
|
18
18
|
var XMLReader = sax.XMLReader;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Normalizes line ending according to <https://www.w3.org/TR/xml11/#sec-line-ends
|
|
21
|
+
* Normalizes line ending according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
|
|
22
|
+
* including some Unicode "newline" characters:
|
|
22
23
|
*
|
|
23
24
|
* > XML parsed entities are often stored in computer files which,
|
|
24
25
|
* > for editing convenience, are organized into lines.
|
|
@@ -27,20 +28,21 @@ var XMLReader = sax.XMLReader;
|
|
|
27
28
|
* >
|
|
28
29
|
* > To simplify the tasks of applications, the XML processor must behave
|
|
29
30
|
* > as if it normalized all line breaks in external parsed entities (including the document entity)
|
|
30
|
-
* > on input, before parsing, by translating
|
|
31
|
+
* > on input, before parsing, by translating the following to a single #xA character:
|
|
31
32
|
* >
|
|
32
33
|
* > 1. the two-character sequence #xD #xA,
|
|
33
34
|
* > 2. the two-character sequence #xD #x85,
|
|
34
35
|
* > 3. the single character #x85,
|
|
35
36
|
* > 4. the single character #x2028,
|
|
36
|
-
* > 5.
|
|
37
|
+
* > 5. the single character #x2029,
|
|
38
|
+
* > 6. any #xD character that is not immediately followed by #xA or #x85.
|
|
37
39
|
*
|
|
38
40
|
* @param {string} input
|
|
39
41
|
* @returns {string}
|
|
40
42
|
* @prettierignore
|
|
41
43
|
*/
|
|
42
44
|
function normalizeLineEndings(input) {
|
|
43
|
-
return input.replace(/\r[\n\u0085]/g, '\n').replace(/[\r\u0085\u2028]/g, '\n');
|
|
45
|
+
return input.replace(/\r[\n\u0085]/g, '\n').replace(/[\r\u0085\u2028\u2029]/g, '\n');
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
/**
|
|
@@ -63,7 +65,7 @@ function normalizeLineEndings(input) {
|
|
|
63
65
|
* DEPRECATED! use `onError` instead.
|
|
64
66
|
* @property {function(level:ErrorLevel, message:string, context: DOMHandler):void}
|
|
65
67
|
* [onError]
|
|
66
|
-
* A function
|
|
68
|
+
* A function invoked for every error that occurs during parsing.
|
|
67
69
|
*
|
|
68
70
|
* If it is not provided, all errors are reported to `console.error`
|
|
69
71
|
* and only `fatalError`s are thrown as a `ParseError`,
|
|
@@ -78,7 +80,9 @@ function normalizeLineEndings(input) {
|
|
|
78
80
|
* attribute describing their location in the XML string.
|
|
79
81
|
* Default is true.
|
|
80
82
|
* @property {(string) => string} [normalizeLineEndings]
|
|
81
|
-
* used to replace line endings before parsing, defaults to `normalizeLineEndings
|
|
83
|
+
* used to replace line endings before parsing, defaults to exported `normalizeLineEndings`,
|
|
84
|
+
* which normalizes line endings according to <https://www.w3.org/TR/xml11/#sec-line-ends>,
|
|
85
|
+
* including some Unicode "newline" characters.
|
|
82
86
|
* @property {Object} [xmlns]
|
|
83
87
|
* The XML namespaces that should be assumed when parsing.
|
|
84
88
|
* The default namespace can be provided by the key that is the empty string.
|
package/lib/dom.js
CHANGED
|
@@ -1082,7 +1082,7 @@ Node.prototype = {
|
|
|
1082
1082
|
var parent = other;
|
|
1083
1083
|
do {
|
|
1084
1084
|
if (this === parent) return true;
|
|
1085
|
-
parent =
|
|
1085
|
+
parent = parent.parentNode;
|
|
1086
1086
|
} while (parent);
|
|
1087
1087
|
return false;
|
|
1088
1088
|
},
|
|
@@ -2210,10 +2210,22 @@ Document.prototype = {
|
|
|
2210
2210
|
return node;
|
|
2211
2211
|
},
|
|
2212
2212
|
/**
|
|
2213
|
+
* Returns a new CDATASection node whose data is `data`.
|
|
2214
|
+
*
|
|
2215
|
+
* __This implementation differs from the specification:__ - calling this method on an HTML
|
|
2216
|
+
* document does not throw `NotSupportedError`.
|
|
2217
|
+
*
|
|
2213
2218
|
* @param {string} data
|
|
2214
2219
|
* @returns {CDATASection}
|
|
2220
|
+
* @throws {DOMException}
|
|
2221
|
+
* With code `INVALID_CHARACTER_ERR` if `data` contains `"]]>"`.
|
|
2222
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createCDATASection
|
|
2223
|
+
* @see https://dom.spec.whatwg.org/#dom-document-createcdatasection
|
|
2215
2224
|
*/
|
|
2216
2225
|
createCDATASection: function (data) {
|
|
2226
|
+
if (data.indexOf(']]>') !== -1) {
|
|
2227
|
+
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 'data contains "]]>"');
|
|
2228
|
+
}
|
|
2217
2229
|
var node = new CDATASection(PDC);
|
|
2218
2230
|
node.ownerDocument = this;
|
|
2219
2231
|
node.childNodes = new NodeList();
|
|
@@ -2693,6 +2705,19 @@ function ProcessingInstruction(symbol) {
|
|
|
2693
2705
|
ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
|
|
2694
2706
|
_extends(ProcessingInstruction, CharacterData);
|
|
2695
2707
|
function XMLSerializer() {}
|
|
2708
|
+
/**
|
|
2709
|
+
* Returns the result of serializing `node` to XML.
|
|
2710
|
+
*
|
|
2711
|
+
* __This implementation differs from the specification:__ - CDATASection nodes whose data
|
|
2712
|
+
* contains `]]>` are serialized by splitting the section at each `]]>` occurrence (following
|
|
2713
|
+
* W3C DOM Level 3 Core `split-cdata-sections`
|
|
2714
|
+
* default behaviour). A configurable option is not yet implemented.
|
|
2715
|
+
*
|
|
2716
|
+
* @param {Node} node
|
|
2717
|
+
* @param {function} [nodeFilter]
|
|
2718
|
+
* @returns {string}
|
|
2719
|
+
* @see https://html.spec.whatwg.org/#dom-xmlserializer-serializetostring
|
|
2720
|
+
*/
|
|
2696
2721
|
XMLSerializer.prototype.serializeToString = function (node, nodeFilter) {
|
|
2697
2722
|
return nodeSerializeToString.call(node, nodeFilter);
|
|
2698
2723
|
};
|
|
@@ -2917,7 +2942,7 @@ function serializeToString(node, buf, nodeFilter, visibleNamespaces) {
|
|
|
2917
2942
|
*/
|
|
2918
2943
|
return buf.push(node.data.replace(/[<&>]/g, _xmlEncoder));
|
|
2919
2944
|
case CDATA_SECTION_NODE:
|
|
2920
|
-
return buf.push(g.CDATA_START, node.data, g.CDATA_END);
|
|
2945
|
+
return buf.push(g.CDATA_START, node.data.replace(/]]>/g, ']]]]><![CDATA[>'), g.CDATA_END);
|
|
2921
2946
|
case COMMENT_NODE:
|
|
2922
2947
|
return buf.push(g.COMMENT_START, node.data, g.COMMENT_END);
|
|
2923
2948
|
case DOCUMENT_TYPE_NODE:
|
|
@@ -3051,6 +3076,22 @@ function cloneNode(doc, node, deep) {
|
|
|
3051
3076
|
function __set__(object, key, value) {
|
|
3052
3077
|
object[key] = value;
|
|
3053
3078
|
}
|
|
3079
|
+
|
|
3080
|
+
// Returns a new array of direct Element children.
|
|
3081
|
+
// Passed to LiveNodeList to implement ParentNode.children.
|
|
3082
|
+
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
|
3083
|
+
function childrenRefresh(node) {
|
|
3084
|
+
var ls = [];
|
|
3085
|
+
var child = node.firstChild;
|
|
3086
|
+
while (child) {
|
|
3087
|
+
if (child.nodeType === ELEMENT_NODE) {
|
|
3088
|
+
ls.push(child);
|
|
3089
|
+
}
|
|
3090
|
+
child = child.nextSibling;
|
|
3091
|
+
}
|
|
3092
|
+
return ls;
|
|
3093
|
+
}
|
|
3094
|
+
|
|
3054
3095
|
//do dynamic
|
|
3055
3096
|
try {
|
|
3056
3097
|
if (Object.defineProperty) {
|
|
@@ -3104,6 +3145,22 @@ try {
|
|
|
3104
3145
|
}
|
|
3105
3146
|
}
|
|
3106
3147
|
|
|
3148
|
+
Object.defineProperty(Element.prototype, 'children', {
|
|
3149
|
+
get: function () {
|
|
3150
|
+
return new LiveNodeList(this, childrenRefresh);
|
|
3151
|
+
},
|
|
3152
|
+
});
|
|
3153
|
+
Object.defineProperty(Document.prototype, 'children', {
|
|
3154
|
+
get: function () {
|
|
3155
|
+
return new LiveNodeList(this, childrenRefresh);
|
|
3156
|
+
},
|
|
3157
|
+
});
|
|
3158
|
+
Object.defineProperty(DocumentFragment.prototype, 'children', {
|
|
3159
|
+
get: function () {
|
|
3160
|
+
return new LiveNodeList(this, childrenRefresh);
|
|
3161
|
+
},
|
|
3162
|
+
});
|
|
3163
|
+
|
|
3107
3164
|
__set__ = function (object, key, value) {
|
|
3108
3165
|
//console.log(value)
|
|
3109
3166
|
object['$$' + key] = value;
|
package/lib/index.js
CHANGED
|
@@ -36,5 +36,6 @@ exports.XMLSerializer = dom.XMLSerializer;
|
|
|
36
36
|
|
|
37
37
|
var domParser = require('./dom-parser');
|
|
38
38
|
exports.DOMParser = domParser.DOMParser;
|
|
39
|
+
exports.normalizeLineEndings = domParser.normalizeLineEndings;
|
|
39
40
|
exports.onErrorStopParsing = domParser.onErrorStopParsing;
|
|
40
41
|
exports.onWarningStopParsing = domParser.onWarningStopParsing;
|
package/lib/sax.js
CHANGED
|
@@ -81,7 +81,7 @@ function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
|
|
|
81
81
|
if (hasOwn(entityMap, k)) {
|
|
82
82
|
return entityMap[k];
|
|
83
83
|
} else if (k.charAt(0) === '#') {
|
|
84
|
-
return fixedFromCharCode(parseInt(k.
|
|
84
|
+
return fixedFromCharCode(parseInt(k.substring(1).replace('x', '0x')));
|
|
85
85
|
} else {
|
|
86
86
|
errorHandler.error('entity not found:' + a);
|
|
87
87
|
return a;
|
|
@@ -98,20 +98,20 @@ function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
var lineStart = 0;
|
|
102
|
+
var lineEnd = 0;
|
|
103
|
+
var linePattern = /\r\n?|\n|$/g;
|
|
104
|
+
var locator = domBuilder.locator;
|
|
105
|
+
|
|
101
106
|
function position(p, m) {
|
|
102
107
|
while (p >= lineEnd && (m = linePattern.exec(source))) {
|
|
103
|
-
lineStart =
|
|
104
|
-
lineEnd =
|
|
108
|
+
lineStart = lineEnd;
|
|
109
|
+
lineEnd = m.index + m[0].length;
|
|
105
110
|
locator.lineNumber++;
|
|
106
111
|
}
|
|
107
112
|
locator.columnNumber = p - lineStart + 1;
|
|
108
113
|
}
|
|
109
114
|
|
|
110
|
-
var lineStart = 0;
|
|
111
|
-
var lineEnd = 0;
|
|
112
|
-
var linePattern = /.*(?:\r\n?|\n)|.*$/g;
|
|
113
|
-
var locator = domBuilder.locator;
|
|
114
|
-
|
|
115
115
|
var parseStack = [{ currentNSMap: defaultNSMapCopy }];
|
|
116
116
|
var unclosedTags = [];
|
|
117
117
|
var start = 0;
|
|
@@ -124,7 +124,7 @@ function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
|
|
|
124
124
|
}
|
|
125
125
|
if (!source.substring(start).match(/^\s*$/)) {
|
|
126
126
|
var doc = domBuilder.doc;
|
|
127
|
-
var text = doc.createTextNode(source.
|
|
127
|
+
var text = doc.createTextNode(source.substring(start));
|
|
128
128
|
if (doc.documentElement) {
|
|
129
129
|
return errorHandler.error('Extra content at the end of the document');
|
|
130
130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmldom/xmldom",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.9",
|
|
4
4
|
"description": "A pure JavaScript W3C standard-based (XML DOM Level 2 Core) DOMParser and XMLSerializer module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"w3c",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"scripts": {
|
|
31
31
|
"lint": "eslint examples lib test",
|
|
32
32
|
"format": "prettier --write examples lib test index.d.ts",
|
|
33
|
+
"format:check": "prettier --check examples lib test index.d.ts",
|
|
33
34
|
"changelog": "auto-changelog --unreleased-only",
|
|
34
35
|
"start": "nodemon --watch package.json --watch lib --watch test --exec 'npm --silent run test && npm --silent run lint'",
|
|
35
36
|
"test": "jest",
|
|
@@ -43,24 +44,21 @@
|
|
|
43
44
|
"node": ">=14.6"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@homer0/prettier-plugin-jsdoc": "
|
|
47
|
-
"@jazzer.js/core": "2.1.0",
|
|
48
|
-
"@jazzer.js/jest-runner": "2.1.0",
|
|
47
|
+
"@homer0/prettier-plugin-jsdoc": "10.0.0",
|
|
49
48
|
"auto-changelog": "2.5.0",
|
|
50
49
|
"eslint": "8.57.1",
|
|
51
|
-
"eslint-config-prettier": "10.
|
|
50
|
+
"eslint-config-prettier": "10.1.8",
|
|
52
51
|
"eslint-plugin-anti-trojan-source": "1.1.1",
|
|
53
52
|
"eslint-plugin-es5": "1.5.0",
|
|
54
|
-
"eslint-plugin-n": "17.
|
|
55
|
-
"eslint-plugin-prettier": "5.
|
|
53
|
+
"eslint-plugin-n": "17.21.3",
|
|
54
|
+
"eslint-plugin-prettier": "5.5.4",
|
|
56
55
|
"get-stream": "6.0.1",
|
|
57
56
|
"jest": "29.7.0",
|
|
58
|
-
"nodemon": "3.1.
|
|
57
|
+
"nodemon": "3.1.10",
|
|
59
58
|
"np": "8.0.4",
|
|
60
|
-
"prettier": "3.
|
|
61
|
-
"rxjs": "7.8.1",
|
|
59
|
+
"prettier": "3.6.2",
|
|
62
60
|
"xmltest": "2.0.3",
|
|
63
|
-
"yauzl": "3.2.
|
|
61
|
+
"yauzl": "3.2.1"
|
|
64
62
|
},
|
|
65
63
|
"bugs": {
|
|
66
64
|
"url": "https://github.com/xmldom/xmldom/issues"
|
|
@@ -71,5 +69,6 @@
|
|
|
71
69
|
"remote": "origin",
|
|
72
70
|
"tagPrefix": "",
|
|
73
71
|
"template": "./auto-changelog.hbs"
|
|
74
|
-
}
|
|
72
|
+
},
|
|
73
|
+
"packageManager": "npm@11.6.3+sha512.4085a763162e0e3acd19a4e9d23ad3aa0978e501ccf947dd7233c12a689ae0bb0190763c4ef12366990056b34eec438903ffed38fde4fbd722a17c2a7407ee92"
|
|
75
74
|
}
|
package/readme.md
CHANGED
|
@@ -289,6 +289,13 @@ import { DOMParser } from '@xmldom/xmldom'
|
|
|
289
289
|
- `isDefaultNamespace(namespaceURI)`
|
|
290
290
|
- `lookupNamespaceURI(prefix)`
|
|
291
291
|
|
|
292
|
+
### DOM Living Standard support:
|
|
293
|
+
|
|
294
|
+
* [ParentNode](https://dom.spec.whatwg.org/#interface-parentnode) mixin (on `Document`, `DocumentFragment`, `Element`)
|
|
295
|
+
|
|
296
|
+
readonly attribute:
|
|
297
|
+
- `children`
|
|
298
|
+
|
|
292
299
|
### DOM extension by xmldom
|
|
293
300
|
|
|
294
301
|
* [Node] Source position extension;
|