فهرست منبع

use html5 doctype when compressing content

Gildas 7 سال پیش
والد
کامیت
c38c6e4bb3
1فایلهای تغییر یافته به همراه18 افزوده شده و 14 حذف شده
  1. 18 14
      lib/single-file/html-serializer.js

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

@@ -54,21 +54,25 @@ this.serializer = this.serializer || (() => {
 
 	return {
 		process(doc, compressHTML) {
-			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 += "> ";
+			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;
 			}
-			return docTypeString + (compressHTML ? serialize(doc.documentElement) : doc.documentElement.outerHTML);
 		}
 	};