]> Lady’s Gitweb - Lemon/blobdiff - window/mod.js
[window] Polyfill top‐level D·O·M interfaces
[Lemon] / window / mod.js
index 9ddbf4bd6055ddbedfd50140a1dc8c946b9de367..82be590858b07bd660ac3708f0ae49a08551bde6 100644 (file)
@@ -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 <https://mozilla.org/MPL/2.0/>.
 
-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", {
This page took 0.030732 seconds and 4 git commands to generate.