Commit a3a2252 for mammothjs
commit a3a22525e85db9f9b576fa3b3e4210778d9d7603
Author: Michael Williamson <mike@zwobble.org>
Date: Sat Dec 5 19:24:00 2026 +0000
Revert "Handle XML documents that are missing a root element"
This reverts commit ae06a2bacfb74c88340e900e8a29336418936e9e.
diff --git a/NEWS b/NEWS
index cb024ae..843d4de 100644
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,3 @@
-# 1.13.1
-
-* Handle XML documents that are missing a root element.
-
# 1.13.0
* Replace the use of bluebird with native promises.
diff --git a/lib/docx/office-xml-reader.js b/lib/docx/office-xml-reader.js
index 6d2c1e9..792cd7c 100644
--- a/lib/docx/office-xml-reader.js
+++ b/lib/docx/office-xml-reader.js
@@ -38,11 +38,7 @@ var xmlNamespaceMap = {
function read(xmlString) {
return xml.readString(xmlString, xmlNamespaceMap)
.then(function(document) {
- if (document === null) {
- return null;
- } else {
- return collapseAlternateContent(document)[0];
- }
+ return collapseAlternateContent(document)[0];
});
}
diff --git a/lib/xml/reader.js b/lib/xml/reader.js
index dcddb0b..2797323 100644
--- a/lib/xml/reader.js
+++ b/lib/xml/reader.js
@@ -18,9 +18,7 @@ function readString(xmlString, namespaceMap) {
return promises.reject(error);
}
- if (document.documentElement == null) {
- return promises.resolve(null);
- } else if (document.documentElement.tagName === "parsererror") {
+ if (document.documentElement.tagName === "parsererror") {
return promises.resolve(new Error(document.documentElement.textContent));
}
diff --git a/test/docx/office-xml-reader.tests.js b/test/docx/office-xml-reader.tests.js
index 6adb970..a017315 100644
--- a/test/docx/office-xml-reader.tests.js
+++ b/test/docx/office-xml-reader.tests.js
@@ -4,15 +4,6 @@ var xml = require("../../lib/xml");
var officeXmlReader = require("../../lib/docx/office-xml-reader");
var test = require("../test")(module);
-test("read", {
- "when document is missing root element then null is returned": function() {
- var xmlString = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
-
- return officeXmlReader.read(xmlString).then(function(element) {
- assert.strictEqual(element, null);
- });
- }
-});
test("mc:AlternateContent", {
"when mc:Fallback is present then mc:Fallback is read": function() {
diff --git a/test/xml/reader.tests.js b/test/xml/reader.tests.js
index 3515835..6b7d3a0 100644
--- a/test/xml/reader.tests.js
+++ b/test/xml/reader.tests.js
@@ -46,7 +46,7 @@ test('mapped namespaces URIs are translated using map', function() {
var namespaceMap = {
"word": "x"
};
-
+
return xmlreader.readString('<w:body xmlns:w="word"/>', namespaceMap).then(function(result) {
assert.deepEqual(result.name, "x:body");
});
@@ -83,11 +83,3 @@ test('error if XML is badly formed', function() {
return 1;
});
});
-
-test("when document is missing root element then null is returned", function() {
- var xmlString = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
-
- return xmlreader.readString(xmlString).then(function(element) {
- assert.strictEqual(element, null);
- });
-});