1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-05 21:10:09 +02:00

update modules

This commit is contained in:
s2
2020-07-20 16:16:07 +02:00
parent 783511ce12
commit 2b23424b86
785 changed files with 91905 additions and 56057 deletions

View File

@@ -5,10 +5,14 @@ const { parseIntoDocument } = require("../../browser/parser");
const Document = require("../generated/Document");
exports.implementation = class DOMParserImpl {
constructor(globalObject) {
this._globalObject = globalObject;
}
parseFromString(string, contentType) {
switch (String(contentType)) {
case "text/html": {
return createScriptingDisabledDocument("html", contentType, string);
return this.createScriptingDisabledDocument("html", contentType, string);
}
case "text/xml":
@@ -16,9 +20,9 @@ exports.implementation = class DOMParserImpl {
case "application/xhtml+xml":
case "image/svg+xml": {
try {
return createScriptingDisabledDocument("xml", contentType, string);
return this.createScriptingDisabledDocument("xml", contentType, string);
} catch (error) {
const document = createScriptingDisabledDocument("xml", contentType);
const document = this.createScriptingDisabledDocument("xml", contentType);
const element = document.createElementNS("http://www.mozilla.org/newlayout/xml/parsererror.xml", "parsererror");
element.textContent = error.message;
@@ -32,23 +36,23 @@ exports.implementation = class DOMParserImpl {
throw new TypeError("Invalid contentType");
}
}
};
function createScriptingDisabledDocument(parsingMode, contentType, string) {
const document = Document.createImpl([], {
options: {
parsingMode,
encoding: "UTF-8",
contentType,
readyState: "complete",
scriptingDisabled: true
// TODO: somehow set URL to active document's URL
createScriptingDisabledDocument(parsingMode, contentType, string) {
const document = Document.createImpl(this._globalObject, [], {
options: {
parsingMode,
encoding: "UTF-8",
contentType,
readyState: "complete",
scriptingDisabled: true
// TODO: somehow set URL to active document's URL
}
});
if (string !== undefined) {
parseIntoDocument(string, document);
}
});
if (string !== undefined) {
parseIntoDocument(string, document);
return document;
}
return document;
}
};