diff options
| -rw-r--r-- | NEWS | 5 | ||||
| -rw-r--r-- | lib/docx/body-reader.js | 2 | ||||
| -rw-r--r-- | test/docx/body-reader.tests.js | 13 |
3 files changed, 19 insertions, 1 deletions
@@ -1,3 +1,8 @@ +# 1.2.1 + +* Use alt text title as alt text for images when the alt text description is + missing entirely. + # 1.2.0 * Throw more informative error when word/document.xml cannot be found. diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js index 519a50b..732a8d2 100644 --- a/lib/docx/body-reader.js +++ b/lib/docx/body-reader.js @@ -322,7 +322,7 @@ function BodyReader(options) { } function isBlank(value) { - return /^\s*$/.test(value); + return value == null || /^\s*$/.test(value); } function findBlipImageFile(blip) { diff --git a/test/docx/body-reader.tests.js b/test/docx/body-reader.tests.js index 21ed961..878d279 100644 --- a/test/docx/body-reader.tests.js +++ b/test/docx/body-reader.tests.js @@ -469,6 +469,19 @@ test("can read inline pictures", function() { })))); }); +test("alt text title is used if alt text description is missing", function() { + var drawing = createInlineImage({ + blip: createEmbeddedBlip(IMAGE_RELATIONSHIP_ID), + title: "It's a hat" + }); + + var result = readEmbeddedImage(drawing); + + return promiseThat(result, isSuccess(contains(isImage({ + altText: "It's a hat" + })))); +}); + test("alt text title is used if alt text description is blank", function() { var drawing = createInlineImage({ blip: createEmbeddedBlip(IMAGE_RELATIONSHIP_ID), |
