// 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(
);
}
-{ // Polyfill `element.append`.
+{ // Polyfill Element::append.
Object.getPrototypeOf(
globalThis.document.documentElement,
).append = function (...children) {
};
}
-{ // Apply patches to `Node.nodeType` and `Node.normalize`.
+{ // Apply patches to Node::nodeType and Node::normalize.
const nodePrototype = Object.getPrototypeOf(
Object.getPrototypeOf(document.createDocumentFragment()),
);
nodePrototype,
"nodeType",
)?.get ?? (() => {
- const originalNodeTypeValue = nodePrototype.nodeType;
+ const { nodeType: originalNodeTypeValue } = nodePrototype;
return () => originalNodeTypeValue;
})();
Object.defineProperty(nodePrototype, "nodeType", {