diff options
| author | Michael Williamson <mike@zwobble.org> | 2022-03-09 20:56:56 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2022-03-09 20:56:56 +0000 |
| commit | 52ec8fbfc6da3695d98e83e222232aaa3b1dcf43 (patch) | |
| tree | 6d4e59baa5caa9b8126b8429836eabc7748d593d | |
| parent | 76cb8e7a2fe33fa59966f8c9b9ae65bbe85f445a (diff) | |
Ignore w:u elements when w:val is missing
| -rw-r--r-- | NEWS | 4 | ||||
| -rw-r--r-- | lib/docx/body-reader.js | 2 | ||||
| -rw-r--r-- | test/docx/body-reader.tests.js | 6 |
3 files changed, 8 insertions, 4 deletions
@@ -1,3 +1,7 @@ +# 1.4.21 + +* Ignore w:u elements when w:val is missing. + # 1.4.20 * Emit warning instead of throwing exception when image file cannot be found for diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js index 4bd38a9..61b198b 100644 --- a/lib/docx/body-reader.js +++ b/lib/docx/body-reader.js @@ -83,7 +83,7 @@ function BodyReader(options) { function readUnderline(element) { if (element) { var value = element.attributes["w:val"]; - return value !== "false" && value !== "0" && value !== "none"; + return value !== undefined && value !== "false" && value !== "0" && value !== "none"; } else { return false; } diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js index 2e53200..f5c8b87 100644 --- a/test/docx/body-reader.tests.js +++ b/test/docx/body-reader.tests.js @@ -512,11 +512,11 @@ test("isUnderline is false if underline element is not present", function() { assert.deepEqual(run.isUnderline, false); }); -test("isUnderline is true if underline element is present without w:val attribute", function() { +test("isUnderline is false if underline element is present without w:val attribute", function() { var underlineXml = new XmlElement("w:u"); var runXml = runWithProperties([underlineXml]); var run = readXmlElementValue(runXml); - assert.equal(run.isUnderline, true); + assert.equal(run.isUnderline, false); }); test("isUnderline is false if underline element is present and w:val is false", function() { @@ -540,7 +540,7 @@ test("isUnderline is false if underline element is present and w:val is none", f assert.equal(run.isUnderline, false); }); -test("isUnderline is false if underline element is present and w:val is not none or falsy", function() { +test("isUnderline is true if underline element is present and w:val is not none or falsy", function() { var underlineXml = new XmlElement("w:u", {"w:val": "single"}); var runXml = runWithProperties([underlineXml]); var run = readXmlElementValue(runXml); |
