summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2017-02-19 18:58:10 +0000
committerMichael Williamson <mike@zwobble.org>2017-02-19 18:58:10 +0000
commit40e958c90486dae503111ae82b9966d706d0e8fd (patch)
tree777504341dd9c6d30b56623dbcaa54d27d34bd05
parentea988e3f229fc25638b8661171721c4a8ca683e3 (diff)
Fix handling of nested complex fields
-rw-r--r--lib/docx/body-reader.js2
-rw-r--r--test/docx/body-reader.tests.js28
2 files changed, 17 insertions, 13 deletions
diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js
index a19ecdb..80715ca 100644
--- a/lib/docx/body-reader.js
+++ b/lib/docx/body-reader.js
@@ -168,7 +168,7 @@ function BodyReader(options) {
if (href !== null) {
complexFields.push({type: "hyperlink", href: href});
} else {
- complexFields.push(null);
+ complexFields.push({type: "unknown"});
}
}
return emptyResult();
diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js
index fc34381..f4ee5d9 100644
--- a/test/docx/body-reader.tests.js
+++ b/test/docx/body-reader.tests.js
@@ -274,28 +274,32 @@ test("complex fields", (function() {
]);
var paragraphXml = new XmlElement("w:p", {}, [
beginXml,
+ hyperlinkInstrText,
+ separateXml,
beginXml,
authorInstrText,
- endXml,
- hyperlinkInstrText,
separateXml,
+ endXml,
hyperlinkRunXml,
endXml
]);
var paragraph = readXmlElementValue(paragraphXml);
+ var isEmptyHyperlinkedRun = isRun({
+ children: contains(
+ isHyperlink({
+ href: uri,
+ children: []
+ })
+ )
+ });
+
assertThat(paragraph.children, contains(
isEmptyRun,
- isEmptyRun,
- isEmptyRun,
- isRun({
- children: contains(
- isHyperlink({
- href: uri,
- children: []
- })
- )
- }),
+ isEmptyHyperlinkedRun,
+ isEmptyHyperlinkedRun,
+ isEmptyHyperlinkedRun,
+ isEmptyHyperlinkedRun,
isRun({
children: contains(
isHyperlink({