Ver Fonte

added parseXMLContent

Gildas há 7 anos atrás
pai
commit
3c24ddcd71

+ 7 - 0
cli/back-ends/jsdom.js

@@ -136,6 +136,7 @@ function getSingleFileClass(win) {
 	const domUtil = {
 		getResourceContent,
 		parseDocContent,
+		parseXMLContent,
 		parseSVGContent,
 		isValidFontUrl,
 		digestText,
@@ -150,6 +151,12 @@ function parseDocContent(content) {
 	})).window.document;
 }
 
+function parseXMLContent(content) {
+	return (new JSDOM(content, {
+		contentType: "text/xml"
+	})).window.document;
+}
+
 function parseSVGContent(content) {
 	return (new JSDOM(content, {
 		contentType: "image/svg+xml"

+ 5 - 0
lib/single-file/single-file-browser.js

@@ -55,6 +55,7 @@ this.SingleFileBrowser = this.SingleFileBrowser || (() => {
 	const domUtil = {
 		getResourceContent,
 		parseDocContent,
+		parseXMLContent,
 		parseSVGContent,
 		isValidFontUrl,
 		digestText,
@@ -117,6 +118,10 @@ this.SingleFileBrowser = this.SingleFileBrowser || (() => {
 		return (new DOMParser()).parseFromString(content, "text/html");
 	}
 
+	function parseXMLContent(content) {
+		return (new DOMParser()).parseFromString(content, "text/xml");
+	}
+
 	function parseSVGContent(content) {
 		return (new DOMParser()).parseFromString(content, "image/svg+xml");
 	}

+ 3 - 0
lib/single-file/util/doc-util.js

@@ -72,6 +72,9 @@ this.docUtil = this.docUtil || (() => {
 					}
 					return doc;
 				},
+				parseXMLContent(content) {
+					return domUtil.parseXMLContent(content);
+				},
 				parseSVGContent(content) {
 					return domUtil.parseSVGContent(content);
 				},