X-Git-Url: https://git.ladys.computer/Lemon/blobdiff_plain/ed2ecda68f968aeb57482df5917a5dff54787759..HEAD:/window/mod.js diff --git a/window/mod.js b/window/mod.js index 9ddbf4b..82be590 100644 --- a/window/mod.js +++ b/window/mod.js @@ -7,7 +7,20 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at . -import { DOMImplementation, xhtmlNamespace } from "./deps.js"; +import { + DOMImplementation, + DOMParser, + xhtmlNamespace, + XMLSerializer, +} from "./deps.js"; + +{ // Polyfill global interfaces. + Object.assign(globalThis, { + DOMImplementation, + DOMParser, + XMLSerializer, + }); +} { // Polyfill document. globalThis.document = new DOMImplementation().createDocument( @@ -24,7 +37,7 @@ import { DOMImplementation, xhtmlNamespace } from "./deps.js"; ); } -{ // Polyfill `element.append`. +{ // Polyfill Element::append. Object.getPrototypeOf( globalThis.document.documentElement, ).append = function (...children) { @@ -38,7 +51,7 @@ import { DOMImplementation, xhtmlNamespace } from "./deps.js"; }; } -{ // Apply patches to `Node.nodeType` and `Node.normalize`. +{ // Apply patches to Node::nodeType and Node::normalize. const nodePrototype = Object.getPrototypeOf( Object.getPrototypeOf(document.createDocumentFragment()), ); @@ -46,7 +59,7 @@ import { DOMImplementation, xhtmlNamespace } from "./deps.js"; nodePrototype, "nodeType", )?.get ?? (() => { - const originalNodeTypeValue = nodePrototype.nodeType; + const { nodeType: originalNodeTypeValue } = nodePrototype; return () => originalNodeTypeValue; })(); Object.defineProperty(nodePrototype, "nodeType", {