diff options
| -rw-r--r-- | NEWS | 4 | ||||
| -rw-r--r-- | lib/docx/numbering-xml.js | 4 | ||||
| -rw-r--r-- | test/docx/numbering-xml.tests.js | 13 |
3 files changed, 20 insertions, 1 deletions
@@ -1,3 +1,7 @@ +# 1.4.17 + +* Handle w:num with invalid w:abstractNumId + # 1.4.16 * Convert symbols in supported fonts to corresponding Unicode characters. diff --git a/lib/docx/numbering-xml.js b/lib/docx/numbering-xml.js index 64c4210..832e414 100644 --- a/lib/docx/numbering-xml.js +++ b/lib/docx/numbering-xml.js @@ -20,7 +20,9 @@ function Numbering(nums, abstractNums, styles) { var num = nums[numId]; if (num) { var abstractNum = abstractNums[num.abstractNumId]; - if (abstractNum.numStyleLink == null) { + if (!abstractNum) { + return null; + } else if (abstractNum.numStyleLink == null) { return abstractNums[num.abstractNumId].levels[level]; } else { var style = styles.findNumberingStyleById(abstractNum.numStyleLink); diff --git a/test/docx/numbering-xml.tests.js b/test/docx/numbering-xml.tests.js index 1eefd37..1a20ab0 100644 --- a/test/docx/numbering-xml.tests.js +++ b/test/docx/numbering-xml.tests.js @@ -33,6 +33,19 @@ test('w:num element inherits levels from w:abstractNum', function() { }); +test('w:num element referencing non-existent w:abstractNumId is ignored', function() { + var numbering = readNumberingXml( + new XmlElement("w:numbering", {}, [ + new XmlElement("w:num", {"w:numId": "47"}, [ + new XmlElement("w:abstractNumId", {"w:val": "42"}) + ]) + ]), + {styles: stylesReader.defaultStyles} + ); + duck.assertThat(numbering.findLevel("47", "0"), duck.equalTo(null)); +}); + + test('when w:abstractNum has w:numStyleLink then style is used to find w:num', function() { var numbering = readNumberingXml( new XmlElement("w:numbering", {}, [ |
