]> Lady’s Gitweb - Lemon/commitdiff
[window] Polyfill top‐level D·O·M interfaces current 0.2.2
authorLady <redacted>
Sun, 7 Aug 2022 20:29:55 +0000 (13:29 -0700)
committerLady <redacted>
Sat, 29 Apr 2023 03:37:04 +0000 (20:37 -0700)
window/deps.js
window/mod.js

index f78b74cd5990e1741a802423639a62c6e9b6cb2a..b7de3f438f0e9bf8e826d8527a70d9424121bdb1 100644 (file)
@@ -9,5 +9,7 @@
 
 export {
   DOMImplementation,
+  DOMParser,
+  XMLSerializer,
 } from "https://esm.sh/@xmldom/xmldom@0.8.2";
 export { xhtmlNamespace } from "../names.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.022165 seconds and 4 git commands to generate.