|
|
@@ -54,28 +54,24 @@ this.serializer = this.serializer || (() => {
|
|
|
|
|
|
return {
|
|
|
process(doc, compressHTML) {
|
|
|
- return getDoctype(doc) + (compressHTML ? serialize(doc.documentElement) : 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);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- function getDoctype(doc) {
|
|
|
- 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 + "]";
|
|
|
- return docTypeString + "> ";
|
|
|
- }
|
|
|
- return "";
|
|
|
- }
|
|
|
-
|
|
|
function serialize(node) {
|
|
|
if (node.nodeType == Node.TEXT_NODE) {
|
|
|
return serializeTextNode(node);
|