@adobe/acc-js-sdk
Advanced tools
Comparing version 1.1.27 to 1.1.28
{ | ||
"name": "@adobe/acc-js-sdk", | ||
"version": "1.1.27", | ||
"version": "1.1.28", | ||
"description": "ACC Javascript SDK", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -383,9 +383,18 @@ /* | ||
// Get the text of a node. Will return the text if the xml node contains | ||
// only text and cdata nodes. Otherwise will return null | ||
static _getTextIfTextNode(xml) { | ||
const child = xml.firstChild; | ||
let child = xml.firstChild; | ||
if (!child) return null; // no children | ||
if (xml.hasAttributes()) return null; // no attributes | ||
if (child.nextSibling) return null; // more than 1 child | ||
if (child.nodeType !== 3 && child.nodeType !== 4) return null; | ||
const text = child.nodeValue; | ||
let text = ""; | ||
while (child) { | ||
// if child node is not text or cdata, it means we have a mix | ||
// of text children and non-text children => we do not consider | ||
// the xml node to be a text-only node | ||
if (child.nodeType !== 3 && child.nodeType !== 4) | ||
return null; | ||
text = text + child.nodeValue; | ||
child = child.nextSibling; | ||
} | ||
return text; | ||
@@ -392,0 +401,0 @@ } |
@@ -961,2 +961,19 @@ /* | ||
}); | ||
it("Should handle content made of CDATA text", () => { | ||
const xml = DomUtil.parse(`<delivery> | ||
<source><![CDATA[<head></head>]]></source> | ||
</delivery>`); | ||
const json = DomUtil.toJSON(xml, "SimpleJson"); | ||
expect(json.$source).toBe("<head></head>") | ||
}); | ||
it("Should handle content made of multiple CDATA text", () => { | ||
const xml = DomUtil.parse(`<delivery> | ||
<source><![CDATA[<head>]]><![CDATA[</head>]]></source> | ||
</delivery>`); | ||
const json = DomUtil.toJSON(xml, "SimpleJson"); | ||
expect(json.$source).toBe("<head></head>") | ||
}); | ||
}); | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1783744
29499