@adobe/acc-js-sdk 1.1.27 → 1.1.28
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/docs/changeLog.html +8 -0
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/src/domUtil.js +13 -4
- package/test/domUtil.test.js +17 -0
package/docs/changeLog.html
CHANGED
|
@@ -3,6 +3,14 @@ layout: page
|
|
|
3
3
|
title: Change Log
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
+
<section class="changelog"><h1>Version 1.1.28</h1>
|
|
7
|
+
<h2>2023/06/09</h2>
|
|
8
|
+
<li>
|
|
9
|
+
Consider elements with multiple text children as if they had one single text child
|
|
10
|
+
</li>
|
|
11
|
+
</section>
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
<section class="changelog"><h1>Version 1.1.27</h1>
|
|
7
15
|
<h2>2023/05/10</h2>
|
|
8
16
|
<li>
|
package/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/acc-js-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.28",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@adobe/acc-js-sdk",
|
|
9
|
-
"version": "1.1.
|
|
9
|
+
"version": "1.1.28",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"axios": "^1.2.1",
|
package/package.json
CHANGED
package/src/domUtil.js
CHANGED
|
@@ -380,13 +380,22 @@ class DomUtil {
|
|
|
380
380
|
return doc;
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
+
// Get the text of a node. Will return the text if the xml node contains
|
|
384
|
+
// only text and cdata nodes. Otherwise will return null
|
|
383
385
|
static _getTextIfTextNode(xml) {
|
|
384
|
-
|
|
386
|
+
let child = xml.firstChild;
|
|
385
387
|
if (!child) return null; // no children
|
|
386
388
|
if (xml.hasAttributes()) return null; // no attributes
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
389
|
+
let text = "";
|
|
390
|
+
while (child) {
|
|
391
|
+
// if child node is not text or cdata, it means we have a mix
|
|
392
|
+
// of text children and non-text children => we do not consider
|
|
393
|
+
// the xml node to be a text-only node
|
|
394
|
+
if (child.nodeType !== 3 && child.nodeType !== 4)
|
|
395
|
+
return null;
|
|
396
|
+
text = text + child.nodeValue;
|
|
397
|
+
child = child.nextSibling;
|
|
398
|
+
}
|
|
390
399
|
return text;
|
|
391
400
|
}
|
|
392
401
|
|
package/test/domUtil.test.js
CHANGED
|
@@ -958,4 +958,21 @@ describe('DomUtil', function() {
|
|
|
958
958
|
expect(new XPathElement(".").isParent()).toBe(false);
|
|
959
959
|
})
|
|
960
960
|
});
|
|
961
|
+
|
|
962
|
+
it("Should handle content made of CDATA text", () => {
|
|
963
|
+
const xml = DomUtil.parse(`<delivery>
|
|
964
|
+
<source><![CDATA[<head></head>]]></source>
|
|
965
|
+
</delivery>`);
|
|
966
|
+
const json = DomUtil.toJSON(xml, "SimpleJson");
|
|
967
|
+
expect(json.$source).toBe("<head></head>")
|
|
968
|
+
});
|
|
969
|
+
it("Should handle content made of multiple CDATA text", () => {
|
|
970
|
+
const xml = DomUtil.parse(`<delivery>
|
|
971
|
+
<source><![CDATA[<head>]]><![CDATA[</head>]]></source>
|
|
972
|
+
</delivery>`);
|
|
973
|
+
const json = DomUtil.toJSON(xml, "SimpleJson");
|
|
974
|
+
expect(json.$source).toBe("<head></head>")
|
|
975
|
+
});
|
|
961
976
|
});
|
|
977
|
+
|
|
978
|
+
|