Parcourir la source

use original doctype when compressing content

Gildas il y a 7 ans
Parent
commit
6e29cf3033
1 fichiers modifiés avec 14 ajouts et 18 suppressions
  1. 14 18
      lib/single-file/html-serializer.js

+ 14 - 18
lib/single-file/html-serializer.js

@@ -54,25 +54,21 @@ this.serializer = this.serializer || (() => {
 
 	return {
 		process(doc, compressHTML) {
-			if (compressHTML) {
-				return "<!DOCTYPE html> " + serialize(doc.documentElement);
-			} else {
-				const docType = doc.doctype;
-				let docTypeString = "";
-				if (docType) {
-					docTypeString = "<!DOCTYPE " + docType.nodeName;
-					if (docType.publicId) {
-						docTypeString += " PUBLIC \"" + docType.publicId + "\"";
-						if (docType.systemId)
-							docTypeString += " \"" + docType.systemId + "\"";
-					} else if (docType.systemId)
-						docTypeString += " SYSTEM \"" + docType.systemId + "\"";
-					if (docType.internalSubset)
-						docTypeString += " [" + docType.internalSubset + "]";
-					docTypeString += "> ";
-				}
-				return docTypeString + doc.documentElement.outerHTML;
+			const docType = doc.doctype;
+			let docTypeString = "";
+			if (docType) {
+				docTypeString = "<!DOCTYPE " + docType.nodeName;
+				if (docType.publicId) {
+					docTypeString += " PUBLIC \"" + docType.publicId + "\"";
+					if (docType.systemId)
+						docTypeString += " \"" + docType.systemId + "\"";
+				} else if (docType.systemId)
+					docTypeString += " SYSTEM \"" + docType.systemId + "\"";
+				if (docType.internalSubset)
+					docTypeString += " [" + docType.internalSubset + "]";
+				docTypeString += "> ";
 			}
+			return docTypeString + (compressHTML ? serialize(doc.documentElement) : doc.documentElement.outerHTML);
 		}
 	};