UNPKG

jsdom

Version:

A JavaScript implementation of many web standards

1,470 lines (1,282 loc) 136 kB
"use strict"; const conversions = require("webidl-conversions"); const utils = require("./utils.js"); const ElementCreationOptions = require("./ElementCreationOptions.js"); const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; const Node = require("./Node.js"); const NodeFilter = require("./NodeFilter.js"); const HTMLElement = require("./HTMLElement.js"); const EventHandlerNonNull = require("./EventHandlerNonNull.js"); const OnErrorEventHandlerNonNull = require("./OnErrorEventHandlerNonNull.js"); const implSymbol = utils.implSymbol; const ctorRegistrySymbol = utils.ctorRegistrySymbol; const interfaceName = "Document"; exports.is = value => { return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; }; exports.isImpl = value => { return utils.isObject(value) && value instanceof Impl.implementation; }; exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { if (exports.is(value)) { return utils.implForWrapper(value); } throw new globalObject.TypeError(`${context} is not of type 'Document'.`); }; function makeWrapper(globalObject, newTarget) { let proto; if (newTarget !== undefined) { proto = newTarget.prototype; } if (!utils.isObject(proto)) { proto = globalObject[ctorRegistrySymbol]["Document"].prototype; } return Object.create(proto); } exports.create = (globalObject, constructorArgs, privateData) => { const wrapper = makeWrapper(globalObject); return exports.setup(wrapper, globalObject, constructorArgs, privateData); }; exports.createImpl = (globalObject, constructorArgs, privateData) => { const wrapper = exports.create(globalObject, constructorArgs, privateData); return utils.implForWrapper(wrapper); }; function getUnforgeables(globalObject) { let unforgeables = unforgeablesMap.get(globalObject); if (unforgeables === undefined) { unforgeables = Object.create(null); utils.define(unforgeables, { get location() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'get location' called on an object that is not a valid instance of Document." ); } return utils.tryWrapperForImpl(esValue[implSymbol]["location"]); }, set location(V) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'set location' called on an object that is not a valid instance of Document." ); } const Q = esValue["location"]; if (!utils.isObject(Q)) { throw new globalObject.TypeError("Property 'location' is not an object"); } Reflect.set(Q, "href", V); } }); Object.defineProperties(unforgeables, { location: { configurable: false } }); unforgeablesMap.set(globalObject, unforgeables); } return unforgeables; } exports._internalSetup = (wrapper, globalObject) => { Node._internalSetup(wrapper, globalObject); utils.define(wrapper, getUnforgeables(globalObject)); }; exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { privateData.wrapper = wrapper; exports._internalSetup(wrapper, globalObject); Object.defineProperty(wrapper, implSymbol, { value: new Impl.implementation(globalObject, constructorArgs, privateData), configurable: true }); wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); } return wrapper; }; exports.new = (globalObject, newTarget) => { const wrapper = makeWrapper(globalObject, newTarget); exports._internalSetup(wrapper, globalObject); Object.defineProperty(wrapper, implSymbol, { value: Object.create(Impl.implementation.prototype), configurable: true }); wrapper[implSymbol][utils.wrapperSymbol] = wrapper; if (Impl.init) { Impl.init(wrapper[implSymbol]); } return wrapper[implSymbol]; }; const unforgeablesMap = new WeakMap(); const exposed = new Set(["Window"]); exports.install = (globalObject, globalNames) => { if (!globalNames.some(globalName => exposed.has(globalName))) { return; } const ctorRegistry = utils.initCtorRegistry(globalObject); class Document extends globalObject.Node { constructor() { return exports.setup(Object.create(new.target.prototype), globalObject, undefined); } getElementsByTagName(qualifiedName) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'getElementsByTagName' called on an object that is not a valid instance of Document." ); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'getElementsByTagName' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'getElementsByTagName' on 'Document': parameter 1", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].getElementsByTagName(...args)); } getElementsByTagNameNS(namespace, localName) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'getElementsByTagNameNS' called on an object that is not a valid instance of Document." ); } if (arguments.length < 2) { throw new globalObject.TypeError( `Failed to execute 'getElementsByTagNameNS' on 'Document': 2 arguments required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; if (curArg === null || curArg === undefined) { curArg = null; } else { curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'getElementsByTagNameNS' on 'Document': parameter 1", globals: globalObject }); } args.push(curArg); } { let curArg = arguments[1]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'getElementsByTagNameNS' on 'Document': parameter 2", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].getElementsByTagNameNS(...args)); } getElementsByClassName(classNames) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'getElementsByClassName' called on an object that is not a valid instance of Document." ); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'getElementsByClassName' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'getElementsByClassName' on 'Document': parameter 1", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].getElementsByClassName(...args)); } createElement(localName) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'createElement' called on an object that is not a valid instance of Document." ); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'createElement' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createElement' on 'Document': parameter 1", globals: globalObject }); args.push(curArg); } { let curArg = arguments[1]; if (curArg !== undefined) { if (curArg === null || curArg === undefined) { curArg = ElementCreationOptions.convert(globalObject, curArg, { context: "Failed to execute 'createElement' on 'Document': parameter 2" }); } else if (utils.isObject(curArg)) { curArg = ElementCreationOptions.convert(globalObject, curArg, { context: "Failed to execute 'createElement' on 'Document': parameter 2" + " dictionary" }); } else { curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createElement' on 'Document': parameter 2", globals: globalObject }); } } args.push(curArg); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return utils.tryWrapperForImpl(esValue[implSymbol].createElement(...args)); } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } createElementNS(namespace, qualifiedName) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'createElementNS' called on an object that is not a valid instance of Document." ); } if (arguments.length < 2) { throw new globalObject.TypeError( `Failed to execute 'createElementNS' on 'Document': 2 arguments required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; if (curArg === null || curArg === undefined) { curArg = null; } else { curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createElementNS' on 'Document': parameter 1", globals: globalObject }); } args.push(curArg); } { let curArg = arguments[1]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createElementNS' on 'Document': parameter 2", globals: globalObject }); args.push(curArg); } { let curArg = arguments[2]; if (curArg !== undefined) { if (curArg === null || curArg === undefined) { curArg = ElementCreationOptions.convert(globalObject, curArg, { context: "Failed to execute 'createElementNS' on 'Document': parameter 3" }); } else if (utils.isObject(curArg)) { curArg = ElementCreationOptions.convert(globalObject, curArg, { context: "Failed to execute 'createElementNS' on 'Document': parameter 3" + " dictionary" }); } else { curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createElementNS' on 'Document': parameter 3", globals: globalObject }); } } args.push(curArg); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return utils.tryWrapperForImpl(esValue[implSymbol].createElementNS(...args)); } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } createDocumentFragment() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'createDocumentFragment' called on an object that is not a valid instance of Document." ); } return utils.tryWrapperForImpl(esValue[implSymbol].createDocumentFragment()); } createTextNode(data) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'createTextNode' called on an object that is not a valid instance of Document." ); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'createTextNode' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createTextNode' on 'Document': parameter 1", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].createTextNode(...args)); } createCDATASection(data) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'createCDATASection' called on an object that is not a valid instance of Document." ); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'createCDATASection' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createCDATASection' on 'Document': parameter 1", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].createCDATASection(...args)); } createComment(data) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'createComment' called on an object that is not a valid instance of Document." ); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'createComment' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createComment' on 'Document': parameter 1", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].createComment(...args)); } createProcessingInstruction(target, data) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'createProcessingInstruction' called on an object that is not a valid instance of Document." ); } if (arguments.length < 2) { throw new globalObject.TypeError( `Failed to execute 'createProcessingInstruction' on 'Document': 2 arguments required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createProcessingInstruction' on 'Document': parameter 1", globals: globalObject }); args.push(curArg); } { let curArg = arguments[1]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createProcessingInstruction' on 'Document': parameter 2", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].createProcessingInstruction(...args)); } importNode(node) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'importNode' called on an object that is not a valid instance of Document."); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'importNode' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = Node.convert(globalObject, curArg, { context: "Failed to execute 'importNode' on 'Document': parameter 1" }); args.push(curArg); } { let curArg = arguments[1]; if (curArg !== undefined) { curArg = conversions["boolean"](curArg, { context: "Failed to execute 'importNode' on 'Document': parameter 2", globals: globalObject }); } else { curArg = false; } args.push(curArg); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return utils.tryWrapperForImpl(esValue[implSymbol].importNode(...args)); } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } adoptNode(node) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'adoptNode' called on an object that is not a valid instance of Document."); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'adoptNode' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = Node.convert(globalObject, curArg, { context: "Failed to execute 'adoptNode' on 'Document': parameter 1" }); args.push(curArg); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return utils.tryWrapperForImpl(esValue[implSymbol].adoptNode(...args)); } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } createAttribute(localName) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'createAttribute' called on an object that is not a valid instance of Document." ); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'createAttribute' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createAttribute' on 'Document': parameter 1", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].createAttribute(...args)); } createAttributeNS(namespace, qualifiedName) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'createAttributeNS' called on an object that is not a valid instance of Document." ); } if (arguments.length < 2) { throw new globalObject.TypeError( `Failed to execute 'createAttributeNS' on 'Document': 2 arguments required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; if (curArg === null || curArg === undefined) { curArg = null; } else { curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createAttributeNS' on 'Document': parameter 1", globals: globalObject }); } args.push(curArg); } { let curArg = arguments[1]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createAttributeNS' on 'Document': parameter 2", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].createAttributeNS(...args)); } createEvent(interface_) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'createEvent' called on an object that is not a valid instance of Document."); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'createEvent' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'createEvent' on 'Document': parameter 1", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].createEvent(...args)); } createRange() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'createRange' called on an object that is not a valid instance of Document."); } return utils.tryWrapperForImpl(esValue[implSymbol].createRange()); } createNodeIterator(root) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'createNodeIterator' called on an object that is not a valid instance of Document." ); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'createNodeIterator' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = Node.convert(globalObject, curArg, { context: "Failed to execute 'createNodeIterator' on 'Document': parameter 1" }); args.push(curArg); } { let curArg = arguments[1]; if (curArg !== undefined) { curArg = conversions["unsigned long"](curArg, { context: "Failed to execute 'createNodeIterator' on 'Document': parameter 2", globals: globalObject }); } else { curArg = 0xffffffff; } args.push(curArg); } { let curArg = arguments[2]; if (curArg !== undefined) { if (curArg === null || curArg === undefined) { curArg = null; } else { curArg = NodeFilter.convert(globalObject, curArg, { context: "Failed to execute 'createNodeIterator' on 'Document': parameter 3" }); } } else { curArg = null; } args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].createNodeIterator(...args)); } createTreeWalker(root) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'createTreeWalker' called on an object that is not a valid instance of Document." ); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'createTreeWalker' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = Node.convert(globalObject, curArg, { context: "Failed to execute 'createTreeWalker' on 'Document': parameter 1" }); args.push(curArg); } { let curArg = arguments[1]; if (curArg !== undefined) { curArg = conversions["unsigned long"](curArg, { context: "Failed to execute 'createTreeWalker' on 'Document': parameter 2", globals: globalObject }); } else { curArg = 0xffffffff; } args.push(curArg); } { let curArg = arguments[2]; if (curArg !== undefined) { if (curArg === null || curArg === undefined) { curArg = null; } else { curArg = NodeFilter.convert(globalObject, curArg, { context: "Failed to execute 'createTreeWalker' on 'Document': parameter 3" }); } } else { curArg = null; } args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].createTreeWalker(...args)); } getElementsByName(elementName) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'getElementsByName' called on an object that is not a valid instance of Document." ); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'getElementsByName' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'getElementsByName' on 'Document': parameter 1", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].getElementsByName(...args)); } open() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'open' called on an object that is not a valid instance of Document."); } const args = []; { let curArg = arguments[0]; if (curArg !== undefined) { curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'open' on 'Document': parameter 1", globals: globalObject }); } else { curArg = "text/html"; } args.push(curArg); } { let curArg = arguments[1]; if (curArg !== undefined) { curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'open' on 'Document': parameter 2", globals: globalObject }); } else { curArg = ""; } args.push(curArg); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return utils.tryWrapperForImpl(esValue[implSymbol].open(...args)); } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } close() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'close' called on an object that is not a valid instance of Document."); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return esValue[implSymbol].close(); } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } write() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'write' called on an object that is not a valid instance of Document."); } const args = []; for (let i = 0; i < arguments.length; i++) { let curArg = arguments[i]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'write' on 'Document': parameter " + (i + 1), globals: globalObject }); args.push(curArg); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return esValue[implSymbol].write(...args); } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } writeln() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'writeln' called on an object that is not a valid instance of Document."); } const args = []; for (let i = 0; i < arguments.length; i++) { let curArg = arguments[i]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'writeln' on 'Document': parameter " + (i + 1), globals: globalObject }); args.push(curArg); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return esValue[implSymbol].writeln(...args); } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } hasFocus() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'hasFocus' called on an object that is not a valid instance of Document."); } return esValue[implSymbol].hasFocus(); } clear() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'clear' called on an object that is not a valid instance of Document."); } return esValue[implSymbol].clear(); } captureEvents() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'captureEvents' called on an object that is not a valid instance of Document." ); } return esValue[implSymbol].captureEvents(); } releaseEvents() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'releaseEvents' called on an object that is not a valid instance of Document." ); } return esValue[implSymbol].releaseEvents(); } getSelection() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'getSelection' called on an object that is not a valid instance of Document." ); } return utils.tryWrapperForImpl(esValue[implSymbol].getSelection()); } getElementById(elementId) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'getElementById' called on an object that is not a valid instance of Document." ); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'getElementById' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'getElementById' on 'Document': parameter 1", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].getElementById(...args)); } prepend() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'prepend' called on an object that is not a valid instance of Document."); } const args = []; for (let i = 0; i < arguments.length; i++) { let curArg = arguments[i]; if (Node.is(curArg)) { curArg = utils.implForWrapper(curArg); } else { curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'prepend' on 'Document': parameter " + (i + 1), globals: globalObject }); } args.push(curArg); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return esValue[implSymbol].prepend(...args); } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } append() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'append' called on an object that is not a valid instance of Document."); } const args = []; for (let i = 0; i < arguments.length; i++) { let curArg = arguments[i]; if (Node.is(curArg)) { curArg = utils.implForWrapper(curArg); } else { curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'append' on 'Document': parameter " + (i + 1), globals: globalObject }); } args.push(curArg); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return esValue[implSymbol].append(...args); } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } replaceChildren() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'replaceChildren' called on an object that is not a valid instance of Document." ); } const args = []; for (let i = 0; i < arguments.length; i++) { let curArg = arguments[i]; if (Node.is(curArg)) { curArg = utils.implForWrapper(curArg); } else { curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'replaceChildren' on 'Document': parameter " + (i + 1), globals: globalObject }); } args.push(curArg); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return esValue[implSymbol].replaceChildren(...args); } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } querySelector(selectors) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'querySelector' called on an object that is not a valid instance of Document." ); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'querySelector' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'querySelector' on 'Document': parameter 1", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].querySelector(...args)); } querySelectorAll(selectors) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'querySelectorAll' called on an object that is not a valid instance of Document." ); } if (arguments.length < 1) { throw new globalObject.TypeError( `Failed to execute 'querySelectorAll' on 'Document': 1 argument required, but only ${arguments.length} present.` ); } const args = []; { let curArg = arguments[0]; curArg = conversions["DOMString"](curArg, { context: "Failed to execute 'querySelectorAll' on 'Document': parameter 1", globals: globalObject }); args.push(curArg); } return utils.tryWrapperForImpl(esValue[implSymbol].querySelectorAll(...args)); } get implementation() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'get implementation' called on an object that is not a valid instance of Document." ); } return utils.getSameObject(this, "implementation", () => { return utils.tryWrapperForImpl(esValue[implSymbol]["implementation"]); }); } get URL() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get URL' called on an object that is not a valid instance of Document."); } return esValue[implSymbol]["URL"]; } get documentURI() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'get documentURI' called on an object that is not a valid instance of Document." ); } return esValue[implSymbol]["documentURI"]; } get compatMode() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'get compatMode' called on an object that is not a valid instance of Document." ); } return esValue[implSymbol]["compatMode"]; } get characterSet() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'get characterSet' called on an object that is not a valid instance of Document." ); } return esValue[implSymbol]["characterSet"]; } get charset() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get charset' called on an object that is not a valid instance of Document."); } return esValue[implSymbol]["charset"]; } get inputEncoding() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'get inputEncoding' called on an object that is not a valid instance of Document." ); } return esValue[implSymbol]["inputEncoding"]; } get contentType() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'get contentType' called on an object that is not a valid instance of Document." ); } return esValue[implSymbol]["contentType"]; } get doctype() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get doctype' called on an object that is not a valid instance of Document."); } return utils.tryWrapperForImpl(esValue[implSymbol]["doctype"]); } get documentElement() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'get documentElement' called on an object that is not a valid instance of Document." ); } return utils.tryWrapperForImpl(esValue[implSymbol]["documentElement"]); } get referrer() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'get referrer' called on an object that is not a valid instance of Document." ); } return esValue[implSymbol]["referrer"]; } get cookie() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get cookie' called on an object that is not a valid instance of Document."); } return esValue[implSymbol]["cookie"]; } set cookie(V) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'set cookie' called on an object that is not a valid instance of Document."); } V = conversions["USVString"](V, { context: "Failed to set the 'cookie' property on 'Document': The provided value", globals: globalObject }); esValue[implSymbol]["cookie"] = V; } get lastModified() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'get lastModified' called on an object that is not a valid instance of Document." ); } return esValue[implSymbol]["lastModified"]; } get readyState() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'get readyState' called on an object that is not a valid instance of Document." ); } return utils.tryWrapperForImpl(esValue[implSymbol]["readyState"]); } get title() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get title' called on an object that is not a valid instance of Document."); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return esValue[implSymbol]["title"]; } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } set title(V) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'set title' called on an object that is not a valid instance of Document."); } V = conversions["DOMString"](V, { context: "Failed to set the 'title' property on 'Document': The provided value", globals: globalObject }); ceReactionsPreSteps_helpers_custom_elements(globalObject); try { esValue[implSymbol]["title"] = V; } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } get dir() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get dir' called on an object that is not a valid instance of Document."); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return esValue[implSymbol]["dir"]; } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } set dir(V) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'set dir' called on an object that is not a valid instance of Document."); } V = conversions["DOMString"](V, { context: "Failed to set the 'dir' property on 'Document': The provided value", globals: globalObject }); ceReactionsPreSteps_helpers_custom_elements(globalObject); try { esValue[implSymbol]["dir"] = V; } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } get body() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get body' called on an object that is not a valid instance of Document."); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { return utils.tryWrapperForImpl(esValue[implSymbol]["body"]); } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } set body(V) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'set body' called on an object that is not a valid instance of Document."); } if (V === null || V === undefined) { V = null; } else { V = HTMLElement.convert(globalObject, V, { context: "Failed to set the 'body' property on 'Document': The provided value" }); } ceReactionsPreSteps_helpers_custom_elements(globalObject); try { esValue[implSymbol]["body"] = V; } finally { ceReactionsPostSteps_helpers_custom_elements(globalObject); } } get head() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get head' called on an object that is not a valid instance of Document."); } return utils.tryWrapperForImpl(esValue[implSymbol]["head"]); } get images() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get images' called on an object that is not a valid instance of Document."); } return utils.getSameObject(this, "images", () => { return utils.tryWrapperForImpl(esValue[implSymbol]["images"]); }); } get embeds() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get embeds' called on an object that is not a valid instance of Document."); } return utils.getSameObject(this, "embeds", () => { return utils.tryWrapperForImpl(esValue[implSymbol]["embeds"]); }); } get plugins() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get plugins' called on an object that is not a valid instance of Document."); } return utils.getSameObject(this, "plugins", () => { return utils.tryWrapperForImpl(esValue[implSymbol]["plugins"]); }); } get links() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get links' called on an object that is not a valid instance of Document."); } return utils.getSameObject(this, "links", () => { return utils.tryWrapperForImpl(esValue[implSymbol]["links"]); }); } get forms() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get forms' called on an object that is not a valid instance of Document."); } return utils.getSameObject(this, "forms", () => { return utils.tryWrapperForImpl(esValue[implSymbol]["forms"]); }); } get scripts() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError("'get scripts' called on an object that is not a valid instance of Document."); } return utils.getSameObject(this, "scripts", () => { return utils.tryWrapperForImpl(esValue[implSymbol]["scripts"]); }); } get currentScript() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'get currentScript' called on an object that is not a valid instance of Document." ); } return utils.tryWrapperForImpl(esValue[implSymbol]["currentScript"]); } get defaultView() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { throw new globalObject.TypeError( "'get defaultView' called on an object that is not a valid instance of Document." ); } return utils.tryWrapperForImpl(esValue[implSymbol]["defaultView"]); } get onreadystatechange() { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { return; } return utils.tryWrapperForImpl(esValue[implSymbol]["onreadystatechange"]); } set onreadystatechange(V) { const esValue = this !== null && this !== undefined ? this : globalObject; if (!exports.is(esValue)) { return; } if (!utils.isObject(V)) { V = null; } else { V = EventHandlerNonNull.convert(globalObject, V, { context: "Failed to set the 'onreadystatechange' property on 'Document': The provided value" }); } esValue[implSymbol]["onreadystatechange"] = V;