diff --git a/.gitattributes b/.gitattributes index 0a44b0109b334ba37af4d8e8b7790dcedfaf4d23..7a3828c3a93e18d14ed85265b02362e60eec039b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -52,3 +52,5 @@ node_modules/bcrypt/prebuilds/win32-arm64/bcrypt.node filter=lfs diff=lfs merge= node_modules/bcrypt/prebuilds/win32-x64/bcrypt.node filter=lfs diff=lfs merge=lfs -text node_modules/better-sqlite3/build/Release/better_sqlite3.node filter=lfs diff=lfs merge=lfs -text node_modules/esbuild/bin/esbuild filter=lfs diff=lfs merge=lfs -text +node_modules/lightningcss-linux-x64-gnu/lightningcss.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text +node_modules/lightningcss-linux-x64-musl/lightningcss.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text diff --git a/node_modules/jsdom/lib/jsdom/living/generated/OnErrorEventHandlerNonNull.js b/node_modules/jsdom/lib/jsdom/living/generated/OnErrorEventHandlerNonNull.js new file mode 100644 index 0000000000000000000000000000000000000000..11e6408146cda52518f9f46b7c4b67a42737ba37 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/OnErrorEventHandlerNonNull.js @@ -0,0 +1,56 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + function invokeTheCallbackFunction(...args) { + const thisArg = utils.tryWrapperForImpl(this); + let callResult; + + if (typeof value === "function") { + for (let i = 0; i < Math.min(args.length, 5); i++) { + args[i] = utils.tryWrapperForImpl(args[i]); + } + + if (args.length < 1) { + for (let i = args.length; i < 1; i++) { + args[i] = undefined; + } + } else if (args.length > 5) { + args.length = 5; + } + + callResult = Reflect.apply(value, thisArg, args); + } + + callResult = conversions["any"](callResult, { context: context, globals: globalObject }); + + return callResult; + } + + invokeTheCallbackFunction.construct = (...args) => { + for (let i = 0; i < Math.min(args.length, 5); i++) { + args[i] = utils.tryWrapperForImpl(args[i]); + } + + if (args.length < 1) { + for (let i = args.length; i < 1; i++) { + args[i] = undefined; + } + } else if (args.length > 5) { + args.length = 5; + } + + let callResult = Reflect.construct(value, args); + + callResult = conversions["any"](callResult, { context: context, globals: globalObject }); + + return callResult; + }; + + invokeTheCallbackFunction[utils.wrapperSymbol] = value; + invokeTheCallbackFunction.objectReference = value; + + return invokeTheCallbackFunction; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PageTransitionEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/PageTransitionEvent.js new file mode 100644 index 0000000000000000000000000000000000000000..4e8d69cf911bc019bb25d56daae2cdb4ef4fe3a8 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PageTransitionEvent.js @@ -0,0 +1,144 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const PageTransitionEventInit = require("./PageTransitionEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "PageTransitionEvent"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'PageTransitionEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["PageTransitionEvent"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class PageTransitionEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'PageTransitionEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'PageTransitionEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = PageTransitionEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'PageTransitionEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get persisted() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get persisted' called on an object that is not a valid instance of PageTransitionEvent." + ); + } + + return esValue[implSymbol]["persisted"]; + } + } + Object.defineProperties(PageTransitionEvent.prototype, { + persisted: { enumerable: true }, + [Symbol.toStringTag]: { value: "PageTransitionEvent", configurable: true } + }); + ctorRegistry[interfaceName] = PageTransitionEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: PageTransitionEvent + }); +}; + +const Impl = require("../events/PageTransitionEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PageTransitionEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/PageTransitionEventInit.js new file mode 100644 index 0000000000000000000000000000000000000000..008ee187ac83cf3a0f21861dccf2d97b04cc4937 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PageTransitionEventInit.js @@ -0,0 +1,35 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "persisted"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'persisted' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Performance.js b/node_modules/jsdom/lib/jsdom/living/generated/Performance.js new file mode 100644 index 0000000000000000000000000000000000000000..285f6fcf7e03075fb7fb352a8f66e87d7674b815 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Performance.js @@ -0,0 +1,142 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const EventTarget = require("./EventTarget.js"); + +const interfaceName = "Performance"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'Performance'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Performance"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + EventTarget._internalSetup(wrapper, 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 exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Performance extends globalObject.EventTarget { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + now() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'now' called on an object that is not a valid instance of Performance."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].now()); + } + + toJSON() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'toJSON' called on an object that is not a valid instance of Performance."); + } + + return esValue[implSymbol].toJSON(); + } + + get timeOrigin() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get timeOrigin' called on an object that is not a valid instance of Performance." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["timeOrigin"]); + } + } + Object.defineProperties(Performance.prototype, { + now: { enumerable: true }, + toJSON: { enumerable: true }, + timeOrigin: { enumerable: true }, + [Symbol.toStringTag]: { value: "Performance", configurable: true } + }); + ctorRegistry[interfaceName] = Performance; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Performance + }); +}; + +const Impl = require("../hr-time/Performance-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Plugin.js b/node_modules/jsdom/lib/jsdom/living/generated/Plugin.js new file mode 100644 index 0000000000000000000000000000000000000000..bb799c15afabdac247338fdbd0aec82dc8745933 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Plugin.js @@ -0,0 +1,359 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Plugin"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'Plugin'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Plugin"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +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); +}; + +exports._internalSetup = (wrapper, 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 = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Plugin { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'item' called on an object that is not a valid instance of Plugin."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'item' on 'Plugin': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'item' on 'Plugin': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].item(...args); + } + + namedItem(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'namedItem' called on an object that is not a valid instance of Plugin."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'namedItem' on 'Plugin': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'namedItem' on 'Plugin': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].namedItem(...args); + } + + get name() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get name' called on an object that is not a valid instance of Plugin."); + } + + return esValue[implSymbol]["name"]; + } + + get description() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get description' called on an object that is not a valid instance of Plugin." + ); + } + + return esValue[implSymbol]["description"]; + } + + get filename() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get filename' called on an object that is not a valid instance of Plugin."); + } + + return esValue[implSymbol]["filename"]; + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get length' called on an object that is not a valid instance of Plugin."); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(Plugin.prototype, { + item: { enumerable: true }, + namedItem: { enumerable: true }, + name: { enumerable: true }, + description: { enumerable: true }, + filename: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "Plugin", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = Plugin; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Plugin + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + + if (target[implSymbol][utils.supportsPropertyIndex](index)) { + const indexedValue = target[implSymbol].item(index); + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + + if (target[implSymbol][utils.supportsPropertyIndex](index)) { + const indexedValue = target[implSymbol].item(index); + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + return utils.ordinarySetWithOwnDescriptor(target, P, V, receiver, ownDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !target[implSymbol][utils.supportsPropertyIndex](index); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../navigator/Plugin-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PluginArray.js b/node_modules/jsdom/lib/jsdom/living/generated/PluginArray.js new file mode 100644 index 0000000000000000000000000000000000000000..5a5e13e7ad3640df9b59dc38a979d02087045a43 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PluginArray.js @@ -0,0 +1,336 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "PluginArray"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'PluginArray'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["PluginArray"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +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); +}; + +exports._internalSetup = (wrapper, 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 = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class PluginArray { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + refresh() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'refresh' called on an object that is not a valid instance of PluginArray."); + } + + return esValue[implSymbol].refresh(); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'item' called on an object that is not a valid instance of PluginArray."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'item' on 'PluginArray': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'item' on 'PluginArray': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].item(...args); + } + + namedItem(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'namedItem' called on an object that is not a valid instance of PluginArray." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'namedItem' on 'PluginArray': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'namedItem' on 'PluginArray': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].namedItem(...args); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of PluginArray." + ); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(PluginArray.prototype, { + refresh: { enumerable: true }, + item: { enumerable: true }, + namedItem: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "PluginArray", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = PluginArray; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: PluginArray + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + return utils.ordinarySetWithOwnDescriptor(target, P, V, receiver, ownDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../navigator/PluginArray-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PointerEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/PointerEvent.js new file mode 100644 index 0000000000000000000000000000000000000000..c5fa7c09db4fac3fd2ff59a29bec752ef14b4b5b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PointerEvent.js @@ -0,0 +1,324 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const PointerEventInit = require("./PointerEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const MouseEvent = require("./MouseEvent.js"); + +const interfaceName = "PointerEvent"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'PointerEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["PointerEvent"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + MouseEvent._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class PointerEvent extends globalObject.MouseEvent { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'PointerEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'PointerEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = PointerEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'PointerEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + getCoalescedEvents() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getCoalescedEvents' called on an object that is not a valid instance of PointerEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].getCoalescedEvents()); + } + + getPredictedEvents() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getPredictedEvents' called on an object that is not a valid instance of PointerEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].getPredictedEvents()); + } + + get pointerId() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get pointerId' called on an object that is not a valid instance of PointerEvent." + ); + } + + return esValue[implSymbol]["pointerId"]; + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get width' called on an object that is not a valid instance of PointerEvent." + ); + } + + return esValue[implSymbol]["width"]; + } + + get height() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get height' called on an object that is not a valid instance of PointerEvent." + ); + } + + return esValue[implSymbol]["height"]; + } + + get pressure() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get pressure' called on an object that is not a valid instance of PointerEvent." + ); + } + + return esValue[implSymbol]["pressure"]; + } + + get tangentialPressure() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get tangentialPressure' called on an object that is not a valid instance of PointerEvent." + ); + } + + return esValue[implSymbol]["tangentialPressure"]; + } + + get tiltX() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get tiltX' called on an object that is not a valid instance of PointerEvent." + ); + } + + return esValue[implSymbol]["tiltX"]; + } + + get tiltY() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get tiltY' called on an object that is not a valid instance of PointerEvent." + ); + } + + return esValue[implSymbol]["tiltY"]; + } + + get twist() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get twist' called on an object that is not a valid instance of PointerEvent." + ); + } + + return esValue[implSymbol]["twist"]; + } + + get altitudeAngle() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get altitudeAngle' called on an object that is not a valid instance of PointerEvent." + ); + } + + return esValue[implSymbol]["altitudeAngle"]; + } + + get azimuthAngle() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get azimuthAngle' called on an object that is not a valid instance of PointerEvent." + ); + } + + return esValue[implSymbol]["azimuthAngle"]; + } + + get pointerType() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get pointerType' called on an object that is not a valid instance of PointerEvent." + ); + } + + return esValue[implSymbol]["pointerType"]; + } + + get isPrimary() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get isPrimary' called on an object that is not a valid instance of PointerEvent." + ); + } + + return esValue[implSymbol]["isPrimary"]; + } + + get persistentDeviceId() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get persistentDeviceId' called on an object that is not a valid instance of PointerEvent." + ); + } + + return esValue[implSymbol]["persistentDeviceId"]; + } + } + Object.defineProperties(PointerEvent.prototype, { + getCoalescedEvents: { enumerable: true }, + getPredictedEvents: { enumerable: true }, + pointerId: { enumerable: true }, + width: { enumerable: true }, + height: { enumerable: true }, + pressure: { enumerable: true }, + tangentialPressure: { enumerable: true }, + tiltX: { enumerable: true }, + tiltY: { enumerable: true }, + twist: { enumerable: true }, + altitudeAngle: { enumerable: true }, + azimuthAngle: { enumerable: true }, + pointerType: { enumerable: true }, + isPrimary: { enumerable: true }, + persistentDeviceId: { enumerable: true }, + [Symbol.toStringTag]: { value: "PointerEvent", configurable: true } + }); + ctorRegistry[interfaceName] = PointerEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: PointerEvent + }); +}; + +const Impl = require("../events/PointerEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PointerEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/PointerEventInit.js new file mode 100644 index 0000000000000000000000000000000000000000..3e499b99f41d568648a158727c390d06317bfa5e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PointerEventInit.js @@ -0,0 +1,241 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const PointerEvent = require("./PointerEvent.js"); +const MouseEventInit = require("./MouseEventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + MouseEventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "altitudeAngle"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["double"](value, { + context: context + " has member 'altitudeAngle' that", + globals: globalObject + }); + + ret[key] = value; + } + } + + { + const key = "azimuthAngle"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["double"](value, { + context: context + " has member 'azimuthAngle' that", + globals: globalObject + }); + + ret[key] = value; + } + } + + { + const key = "coalescedEvents"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (!utils.isObject(value)) { + throw new globalObject.TypeError( + context + " has member 'coalescedEvents' that" + " is not an iterable object." + ); + } else { + const V = []; + const tmp = value; + for (let nextItem of tmp) { + nextItem = PointerEvent.convert(globalObject, nextItem, { + context: context + " has member 'coalescedEvents' that" + "'s element" + }); + + V.push(nextItem); + } + value = V; + } + + ret[key] = value; + } else { + ret[key] = []; + } + } + + { + const key = "height"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["double"](value, { context: context + " has member 'height' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 1; + } + } + + { + const key = "isPrimary"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'isPrimary' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "persistentDeviceId"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["long"](value, { + context: context + " has member 'persistentDeviceId' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "pointerId"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["long"](value, { context: context + " has member 'pointerId' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "pointerType"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["DOMString"](value, { + context: context + " has member 'pointerType' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } + + { + const key = "predictedEvents"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (!utils.isObject(value)) { + throw new globalObject.TypeError( + context + " has member 'predictedEvents' that" + " is not an iterable object." + ); + } else { + const V = []; + const tmp = value; + for (let nextItem of tmp) { + nextItem = PointerEvent.convert(globalObject, nextItem, { + context: context + " has member 'predictedEvents' that" + "'s element" + }); + + V.push(nextItem); + } + value = V; + } + + ret[key] = value; + } else { + ret[key] = []; + } + } + + { + const key = "pressure"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["float"](value, { context: context + " has member 'pressure' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "tangentialPressure"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["float"](value, { + context: context + " has member 'tangentialPressure' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "tiltX"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["long"](value, { context: context + " has member 'tiltX' that", globals: globalObject }); + + ret[key] = value; + } + } + + { + const key = "tiltY"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["long"](value, { context: context + " has member 'tiltY' that", globals: globalObject }); + + ret[key] = value; + } + } + + { + const key = "twist"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["long"](value, { context: context + " has member 'twist' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "width"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["double"](value, { context: context + " has member 'width' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 1; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PopStateEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/PopStateEvent.js new file mode 100644 index 0000000000000000000000000000000000000000..1bf940fb89e1f72e84f24cfab038473ef3427af3 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PopStateEvent.js @@ -0,0 +1,144 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const PopStateEventInit = require("./PopStateEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "PopStateEvent"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'PopStateEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["PopStateEvent"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class PopStateEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'PopStateEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'PopStateEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = PopStateEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'PopStateEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get state() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get state' called on an object that is not a valid instance of PopStateEvent." + ); + } + + return esValue[implSymbol]["state"]; + } + } + Object.defineProperties(PopStateEvent.prototype, { + state: { enumerable: true }, + [Symbol.toStringTag]: { value: "PopStateEvent", configurable: true } + }); + ctorRegistry[interfaceName] = PopStateEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: PopStateEvent + }); +}; + +const Impl = require("../events/PopStateEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PopStateEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/PopStateEventInit.js new file mode 100644 index 0000000000000000000000000000000000000000..79ecec85472f255890ae56f343d3f5ac257e562b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PopStateEventInit.js @@ -0,0 +1,32 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "state"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["any"](value, { context: context + " has member 'state' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = null; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ProcessingInstruction.js b/node_modules/jsdom/lib/jsdom/living/generated/ProcessingInstruction.js new file mode 100644 index 0000000000000000000000000000000000000000..d62d98c0ff6f9085e606d2d0a524c4a2295395bd --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ProcessingInstruction.js @@ -0,0 +1,122 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const CharacterData = require("./CharacterData.js"); + +const interfaceName = "ProcessingInstruction"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'ProcessingInstruction'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["ProcessingInstruction"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + CharacterData._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class ProcessingInstruction extends globalObject.CharacterData { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get target() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get target' called on an object that is not a valid instance of ProcessingInstruction." + ); + } + + return esValue[implSymbol]["target"]; + } + } + Object.defineProperties(ProcessingInstruction.prototype, { + target: { enumerable: true }, + [Symbol.toStringTag]: { value: "ProcessingInstruction", configurable: true } + }); + ctorRegistry[interfaceName] = ProcessingInstruction; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: ProcessingInstruction + }); +}; + +const Impl = require("../nodes/ProcessingInstruction-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ProgressEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/ProgressEvent.js new file mode 100644 index 0000000000000000000000000000000000000000..5a31ed54c8bd45baca293e9ba638d75a00cc72f9 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ProgressEvent.js @@ -0,0 +1,170 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ProgressEventInit = require("./ProgressEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "ProgressEvent"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'ProgressEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["ProgressEvent"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, 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 exposed = new Set(["Window", "DedicatedWorker", "SharedWorker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class ProgressEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'ProgressEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'ProgressEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = ProgressEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'ProgressEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get lengthComputable() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get lengthComputable' called on an object that is not a valid instance of ProgressEvent." + ); + } + + return esValue[implSymbol]["lengthComputable"]; + } + + get loaded() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get loaded' called on an object that is not a valid instance of ProgressEvent." + ); + } + + return esValue[implSymbol]["loaded"]; + } + + get total() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get total' called on an object that is not a valid instance of ProgressEvent." + ); + } + + return esValue[implSymbol]["total"]; + } + } + Object.defineProperties(ProgressEvent.prototype, { + lengthComputable: { enumerable: true }, + loaded: { enumerable: true }, + total: { enumerable: true }, + [Symbol.toStringTag]: { value: "ProgressEvent", configurable: true } + }); + ctorRegistry[interfaceName] = ProgressEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: ProgressEvent + }); +}; + +const Impl = require("../events/ProgressEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ProgressEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/ProgressEventInit.js new file mode 100644 index 0000000000000000000000000000000000000000..2738568c1cf3907bcdf052bf5c45a8a246764348 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ProgressEventInit.js @@ -0,0 +1,65 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "lengthComputable"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { + context: context + " has member 'lengthComputable' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "loaded"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long long"](value, { + context: context + " has member 'loaded' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "total"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long long"](value, { + context: context + " has member 'total' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PromiseRejectionEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/PromiseRejectionEvent.js new file mode 100644 index 0000000000000000000000000000000000000000..4242932e74cf4063a31b7dd8db1ffb39d65b53b3 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PromiseRejectionEvent.js @@ -0,0 +1,157 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const PromiseRejectionEventInit = require("./PromiseRejectionEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "PromiseRejectionEvent"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'PromiseRejectionEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["PromiseRejectionEvent"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class PromiseRejectionEvent extends globalObject.Event { + constructor(type, eventInitDict) { + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to construct 'PromiseRejectionEvent': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'PromiseRejectionEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = PromiseRejectionEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'PromiseRejectionEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get promise() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get promise' called on an object that is not a valid instance of PromiseRejectionEvent." + ); + } + + return esValue[implSymbol]["promise"]; + } + + get reason() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get reason' called on an object that is not a valid instance of PromiseRejectionEvent." + ); + } + + return esValue[implSymbol]["reason"]; + } + } + Object.defineProperties(PromiseRejectionEvent.prototype, { + promise: { enumerable: true }, + reason: { enumerable: true }, + [Symbol.toStringTag]: { value: "PromiseRejectionEvent", configurable: true } + }); + ctorRegistry[interfaceName] = PromiseRejectionEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: PromiseRejectionEvent + }); +}; + +const Impl = require("../events/PromiseRejectionEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/PromiseRejectionEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/PromiseRejectionEventInit.js new file mode 100644 index 0000000000000000000000000000000000000000..eea4d8de2d65beb5cca10b543795093000e978a6 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/PromiseRejectionEventInit.js @@ -0,0 +1,42 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "promise"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["object"](value, { context: context + " has member 'promise' that", globals: globalObject }); + + ret[key] = value; + } else { + throw new globalObject.TypeError("promise is required in 'PromiseRejectionEventInit'"); + } + } + + { + const key = "reason"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["any"](value, { context: context + " has member 'reason' that", globals: globalObject }); + + ret[key] = value; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/RadioNodeList.js b/node_modules/jsdom/lib/jsdom/living/generated/RadioNodeList.js new file mode 100644 index 0000000000000000000000000000000000000000..b1e3a151fec99666c03dfbf4a42e56d1a72fb7d5 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/RadioNodeList.js @@ -0,0 +1,296 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const NodeList = require("./NodeList.js"); + +const interfaceName = "RadioNodeList"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'RadioNodeList'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["RadioNodeList"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + NodeList._internalSetup(wrapper, 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 = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class RadioNodeList extends globalObject.NodeList { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get value' called on an object that is not a valid instance of RadioNodeList." + ); + } + + return esValue[implSymbol]["value"]; + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set value' called on an object that is not a valid instance of RadioNodeList." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'value' property on 'RadioNodeList': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["value"] = V; + } + } + Object.defineProperties(RadioNodeList.prototype, { + value: { enumerable: true }, + [Symbol.toStringTag]: { value: "RadioNodeList", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = RadioNodeList; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: RadioNodeList + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + return utils.ordinarySetWithOwnDescriptor(target, P, V, receiver, ownDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../nodes/RadioNodeList-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Range.js b/node_modules/jsdom/lib/jsdom/living/generated/Range.js new file mode 100644 index 0000000000000000000000000000000000000000..be62e100ab89dc3dcf626fd120aaca27c3553f69 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Range.js @@ -0,0 +1,641 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Node = require("./Node.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const AbstractRange = require("./AbstractRange.js"); + +const interfaceName = "Range"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'Range'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Range"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + AbstractRange._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Range extends globalObject.AbstractRange { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + setStart(node, offset) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setStart' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'setStart' on 'Range': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setStart' on 'Range': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setStart' on 'Range': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setStart(...args); + } + + setEnd(node, offset) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setEnd' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'setEnd' on 'Range': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { context: "Failed to execute 'setEnd' on 'Range': parameter 1" }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setEnd' on 'Range': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setEnd(...args); + } + + setStartBefore(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setStartBefore' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setStartBefore' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setStartBefore' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].setStartBefore(...args); + } + + setStartAfter(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setStartAfter' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setStartAfter' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setStartAfter' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].setStartAfter(...args); + } + + setEndBefore(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setEndBefore' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setEndBefore' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setEndBefore' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].setEndBefore(...args); + } + + setEndAfter(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setEndAfter' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setEndAfter' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setEndAfter' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].setEndAfter(...args); + } + + collapse() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'collapse' called on an object that is not a valid instance of Range."); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'collapse' on 'Range': parameter 1", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + return esValue[implSymbol].collapse(...args); + } + + selectNode(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'selectNode' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'selectNode' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'selectNode' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].selectNode(...args); + } + + selectNodeContents(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'selectNodeContents' called on an object that is not a valid instance of Range." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'selectNodeContents' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'selectNodeContents' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].selectNodeContents(...args); + } + + compareBoundaryPoints(how, sourceRange) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'compareBoundaryPoints' called on an object that is not a valid instance of Range." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'compareBoundaryPoints' on 'Range': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned short"](curArg, { + context: "Failed to execute 'compareBoundaryPoints' on 'Range': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = exports.convert(globalObject, curArg, { + context: "Failed to execute 'compareBoundaryPoints' on 'Range': parameter 2" + }); + args.push(curArg); + } + return esValue[implSymbol].compareBoundaryPoints(...args); + } + + deleteContents() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'deleteContents' called on an object that is not a valid instance of Range."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].deleteContents(); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + extractContents() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'extractContents' called on an object that is not a valid instance of Range." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].extractContents()); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + cloneContents() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'cloneContents' called on an object that is not a valid instance of Range."); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].cloneContents()); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + insertNode(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'insertNode' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'insertNode' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'insertNode' on 'Range': parameter 1" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].insertNode(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + surroundContents(newParent) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'surroundContents' called on an object that is not a valid instance of Range." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'surroundContents' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'surroundContents' on 'Range': parameter 1" + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].surroundContents(...args); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + cloneRange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'cloneRange' called on an object that is not a valid instance of Range."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].cloneRange()); + } + + detach() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'detach' called on an object that is not a valid instance of Range."); + } + + return esValue[implSymbol].detach(); + } + + isPointInRange(node, offset) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'isPointInRange' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'isPointInRange' on 'Range': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'isPointInRange' on 'Range': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'isPointInRange' on 'Range': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].isPointInRange(...args); + } + + comparePoint(node, offset) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'comparePoint' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'comparePoint' on 'Range': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'comparePoint' on 'Range': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'comparePoint' on 'Range': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].comparePoint(...args); + } + + intersectsNode(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'intersectsNode' called on an object that is not a valid instance of Range."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'intersectsNode' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'intersectsNode' on 'Range': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].intersectsNode(...args); + } + + toString() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'toString' called on an object that is not a valid instance of Range."); + } + + return esValue[implSymbol].toString(); + } + + createContextualFragment(fragment) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createContextualFragment' called on an object that is not a valid instance of Range." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'createContextualFragment' on 'Range': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'createContextualFragment' on 'Range': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return utils.tryWrapperForImpl(esValue[implSymbol].createContextualFragment(...args)); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get commonAncestorContainer() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get commonAncestorContainer' called on an object that is not a valid instance of Range." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["commonAncestorContainer"]); + } + } + Object.defineProperties(Range.prototype, { + setStart: { enumerable: true }, + setEnd: { enumerable: true }, + setStartBefore: { enumerable: true }, + setStartAfter: { enumerable: true }, + setEndBefore: { enumerable: true }, + setEndAfter: { enumerable: true }, + collapse: { enumerable: true }, + selectNode: { enumerable: true }, + selectNodeContents: { enumerable: true }, + compareBoundaryPoints: { enumerable: true }, + deleteContents: { enumerable: true }, + extractContents: { enumerable: true }, + cloneContents: { enumerable: true }, + insertNode: { enumerable: true }, + surroundContents: { enumerable: true }, + cloneRange: { enumerable: true }, + detach: { enumerable: true }, + isPointInRange: { enumerable: true }, + comparePoint: { enumerable: true }, + intersectsNode: { enumerable: true }, + toString: { enumerable: true }, + createContextualFragment: { enumerable: true }, + commonAncestorContainer: { enumerable: true }, + [Symbol.toStringTag]: { value: "Range", configurable: true }, + START_TO_START: { value: 0, enumerable: true }, + START_TO_END: { value: 1, enumerable: true }, + END_TO_END: { value: 2, enumerable: true }, + END_TO_START: { value: 3, enumerable: true } + }); + Object.defineProperties(Range, { + START_TO_START: { value: 0, enumerable: true }, + START_TO_END: { value: 1, enumerable: true }, + END_TO_END: { value: 2, enumerable: true }, + END_TO_START: { value: 3, enumerable: true } + }); + ctorRegistry[interfaceName] = Range; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Range + }); +}; + +const Impl = require("../range/Range-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGAnimatedPreserveAspectRatio.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGAnimatedPreserveAspectRatio.js new file mode 100644 index 0000000000000000000000000000000000000000..af253dfaeed0f7c6fc7198250ff6c5a480f573c9 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGAnimatedPreserveAspectRatio.js @@ -0,0 +1,136 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "SVGAnimatedPreserveAspectRatio"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGAnimatedPreserveAspectRatio'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGAnimatedPreserveAspectRatio"].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); +}; + +exports._internalSetup = (wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGAnimatedPreserveAspectRatio { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get baseVal() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get baseVal' called on an object that is not a valid instance of SVGAnimatedPreserveAspectRatio." + ); + } + + return utils.getSameObject(this, "baseVal", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["baseVal"]); + }); + } + + get animVal() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get animVal' called on an object that is not a valid instance of SVGAnimatedPreserveAspectRatio." + ); + } + + return utils.getSameObject(this, "animVal", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["animVal"]); + }); + } + } + Object.defineProperties(SVGAnimatedPreserveAspectRatio.prototype, { + baseVal: { enumerable: true }, + animVal: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGAnimatedPreserveAspectRatio", configurable: true } + }); + ctorRegistry[interfaceName] = SVGAnimatedPreserveAspectRatio; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGAnimatedPreserveAspectRatio + }); +}; + +const Impl = require("../svg/SVGAnimatedPreserveAspectRatio-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGAnimatedRect.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGAnimatedRect.js new file mode 100644 index 0000000000000000000000000000000000000000..66413402a75e70f40c0942ce1fd260536abd7368 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGAnimatedRect.js @@ -0,0 +1,136 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "SVGAnimatedRect"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGAnimatedRect'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGAnimatedRect"].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); +}; + +exports._internalSetup = (wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGAnimatedRect { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get baseVal() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get baseVal' called on an object that is not a valid instance of SVGAnimatedRect." + ); + } + + return utils.getSameObject(this, "baseVal", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["baseVal"]); + }); + } + + get animVal() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get animVal' called on an object that is not a valid instance of SVGAnimatedRect." + ); + } + + return utils.getSameObject(this, "animVal", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["animVal"]); + }); + } + } + Object.defineProperties(SVGAnimatedRect.prototype, { + baseVal: { enumerable: true }, + animVal: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGAnimatedRect", configurable: true } + }); + ctorRegistry[interfaceName] = SVGAnimatedRect; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGAnimatedRect + }); +}; + +const Impl = require("../svg/SVGAnimatedRect-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGAnimatedString.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGAnimatedString.js new file mode 100644 index 0000000000000000000000000000000000000000..713db35e3c489dc24395701424b6c57fb822e092 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGAnimatedString.js @@ -0,0 +1,149 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "SVGAnimatedString"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGAnimatedString'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGAnimatedString"].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); +}; + +exports._internalSetup = (wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGAnimatedString { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get baseVal() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get baseVal' called on an object that is not a valid instance of SVGAnimatedString." + ); + } + + return esValue[implSymbol]["baseVal"]; + } + + set baseVal(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set baseVal' called on an object that is not a valid instance of SVGAnimatedString." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'baseVal' property on 'SVGAnimatedString': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["baseVal"] = V; + } + + get animVal() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get animVal' called on an object that is not a valid instance of SVGAnimatedString." + ); + } + + return esValue[implSymbol]["animVal"]; + } + } + Object.defineProperties(SVGAnimatedString.prototype, { + baseVal: { enumerable: true }, + animVal: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGAnimatedString", configurable: true } + }); + ctorRegistry[interfaceName] = SVGAnimatedString; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGAnimatedString + }); +}; + +const Impl = require("../svg/SVGAnimatedString-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGBoundingBoxOptions.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGBoundingBoxOptions.js new file mode 100644 index 0000000000000000000000000000000000000000..7d1b2c58e5062f4454b6fd0c683af8c97372f361 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGBoundingBoxOptions.js @@ -0,0 +1,64 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "clipped"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'clipped' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "fill"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'fill' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = true; + } + } + + { + const key = "markers"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'markers' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } + + { + const key = "stroke"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["boolean"](value, { context: context + " has member 'stroke' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = false; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGDefsElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGDefsElement.js new file mode 100644 index 0000000000000000000000000000000000000000..b3423fa84311c8dbc8a4f58d54974a1497b6e457 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGDefsElement.js @@ -0,0 +1,109 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const SVGGraphicsElement = require("./SVGGraphicsElement.js"); + +const interfaceName = "SVGDefsElement"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGDefsElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGDefsElement"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + SVGGraphicsElement._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGDefsElement extends globalObject.SVGGraphicsElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(SVGDefsElement.prototype, { + [Symbol.toStringTag]: { value: "SVGDefsElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGDefsElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGDefsElement + }); +}; + +const Impl = require("../nodes/SVGDefsElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGDescElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGDescElement.js new file mode 100644 index 0000000000000000000000000000000000000000..0c17e60cdfa1b931677c3a7db7c554ff90d601c7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGDescElement.js @@ -0,0 +1,109 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const SVGElement = require("./SVGElement.js"); + +const interfaceName = "SVGDescElement"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGDescElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGDescElement"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + SVGElement._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGDescElement extends globalObject.SVGElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(SVGDescElement.prototype, { + [Symbol.toStringTag]: { value: "SVGDescElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGDescElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGDescElement + }); +}; + +const Impl = require("../nodes/SVGDescElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGElement.js new file mode 100644 index 0000000000000000000000000000000000000000..678b00e266b10b932de255763ac4ac91a94d243b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGElement.js @@ -0,0 +1,3155 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const create_SVGAnimatedString = require("./SVGAnimatedString.js").create; +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const OnErrorEventHandlerNonNull = require("./OnErrorEventHandlerNonNull.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Element = require("./Element.js"); + +const interfaceName = "SVGElement"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGElement"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Element._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGElement extends globalObject.Element { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + focus() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'focus' called on an object that is not a valid instance of SVGElement."); + } + + return esValue[implSymbol].focus(); + } + + blur() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'blur' called on an object that is not a valid instance of SVGElement."); + } + + return esValue[implSymbol].blur(); + } + + get className() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get className' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.getSameObject(this, "className", () => { + return create_SVGAnimatedString(globalObject, [], { + element: esValue[implSymbol], + attribute: "class" + }); + }); + } + + get ownerSVGElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ownerSVGElement' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ownerSVGElement"]); + } + + get viewportElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get viewportElement' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["viewportElement"]); + } + + get style() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get style' called on an object that is not a valid instance of SVGElement."); + } + + return utils.getSameObject(this, "style", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["style"]); + }); + } + + set style(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set style' called on an object that is not a valid instance of SVGElement."); + } + + const Q = esValue["style"]; + if (!utils.isObject(Q)) { + throw new globalObject.TypeError("Property 'style' is not an object"); + } + Reflect.set(Q, "cssText", V); + } + + get onabort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onabort' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]); + } + + set onabort(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onabort' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onabort' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onabort"] = V; + } + + get onauxclick() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onauxclick' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onauxclick"]); + } + + set onauxclick(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onauxclick' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onauxclick' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onauxclick"] = V; + } + + get onbeforeinput() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onbeforeinput' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeinput"]); + } + + set onbeforeinput(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onbeforeinput' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onbeforeinput' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onbeforeinput"] = V; + } + + get onbeforematch() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onbeforematch' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforematch"]); + } + + set onbeforematch(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onbeforematch' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onbeforematch' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onbeforematch"] = V; + } + + get onbeforetoggle() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onbeforetoggle' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforetoggle"]); + } + + set onbeforetoggle(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onbeforetoggle' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onbeforetoggle' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onbeforetoggle"] = V; + } + + get onblur() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onblur' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onblur"]); + } + + set onblur(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onblur' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onblur' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onblur"] = V; + } + + get oncancel() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncancel' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncancel"]); + } + + set oncancel(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncancel' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncancel' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncancel"] = V; + } + + get oncanplay() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncanplay' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncanplay"]); + } + + set oncanplay(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncanplay' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncanplay' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncanplay"] = V; + } + + get oncanplaythrough() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncanplaythrough' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncanplaythrough"]); + } + + set oncanplaythrough(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncanplaythrough' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncanplaythrough' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncanplaythrough"] = V; + } + + get onchange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onchange' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onchange"]); + } + + set onchange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onchange' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onchange' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onchange"] = V; + } + + get onclick() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onclick' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onclick"]); + } + + set onclick(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onclick' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onclick' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onclick"] = V; + } + + get onclose() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onclose' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onclose"]); + } + + set onclose(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onclose' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onclose' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onclose"] = V; + } + + get oncontextlost() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncontextlost' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncontextlost"]); + } + + set oncontextlost(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncontextlost' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncontextlost' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncontextlost"] = V; + } + + get oncontextmenu() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncontextmenu' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncontextmenu"]); + } + + set oncontextmenu(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncontextmenu' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncontextmenu' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncontextmenu"] = V; + } + + get oncontextrestored() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncontextrestored' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncontextrestored"]); + } + + set oncontextrestored(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncontextrestored' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncontextrestored' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncontextrestored"] = V; + } + + get oncopy() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncopy' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncopy"]); + } + + set oncopy(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncopy' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncopy' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncopy"] = V; + } + + get oncuechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oncuechange' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncuechange"]); + } + + set oncuechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oncuechange' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncuechange' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncuechange"] = V; + } + + get oncut() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get oncut' called on an object that is not a valid instance of SVGElement."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oncut"]); + } + + set oncut(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set oncut' called on an object that is not a valid instance of SVGElement."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oncut' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oncut"] = V; + } + + get ondblclick() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondblclick' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondblclick"]); + } + + set ondblclick(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondblclick' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondblclick' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondblclick"] = V; + } + + get ondrag() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondrag' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondrag"]); + } + + set ondrag(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondrag' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondrag' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondrag"] = V; + } + + get ondragend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragend' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragend"]); + } + + set ondragend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragend' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragend' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondragend"] = V; + } + + get ondragenter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragenter' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragenter"]); + } + + set ondragenter(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragenter' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragenter' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondragenter"] = V; + } + + get ondragleave() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragleave' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragleave"]); + } + + set ondragleave(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragleave' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragleave' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondragleave"] = V; + } + + get ondragover() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragover' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragover"]); + } + + set ondragover(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragover' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragover' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondragover"] = V; + } + + get ondragstart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondragstart' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondragstart"]); + } + + set ondragstart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondragstart' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondragstart' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondragstart"] = V; + } + + get ondrop() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondrop' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondrop"]); + } + + set ondrop(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondrop' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondrop' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondrop"] = V; + } + + get ondurationchange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ondurationchange' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ondurationchange"]); + } + + set ondurationchange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ondurationchange' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ondurationchange' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ondurationchange"] = V; + } + + get onemptied() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onemptied' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onemptied"]); + } + + set onemptied(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onemptied' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onemptied' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onemptied"] = V; + } + + get onended() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onended' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onended"]); + } + + set onended(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onended' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onended' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onended"] = V; + } + + get onerror() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onerror' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onerror"]); + } + + set onerror(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onerror' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = OnErrorEventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onerror' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onerror"] = V; + } + + get onfocus() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onfocus' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onfocus"]); + } + + set onfocus(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onfocus' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onfocus' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onfocus"] = V; + } + + get onformdata() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onformdata' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onformdata"]); + } + + set onformdata(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onformdata' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onformdata' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onformdata"] = V; + } + + get oninput() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oninput' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oninput"]); + } + + set oninput(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oninput' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oninput' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oninput"] = V; + } + + get oninvalid() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oninvalid' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["oninvalid"]); + } + + set oninvalid(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set oninvalid' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'oninvalid' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["oninvalid"] = V; + } + + get onkeydown() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onkeydown' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onkeydown"]); + } + + set onkeydown(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onkeydown' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onkeydown' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onkeydown"] = V; + } + + get onkeypress() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onkeypress' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onkeypress"]); + } + + set onkeypress(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onkeypress' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onkeypress' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onkeypress"] = V; + } + + get onkeyup() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onkeyup' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onkeyup"]); + } + + set onkeyup(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onkeyup' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onkeyup' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onkeyup"] = V; + } + + get onload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onload' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onload"]); + } + + set onload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onload' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onload' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onload"] = V; + } + + get onloadeddata() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadeddata' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadeddata"]); + } + + set onloadeddata(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadeddata' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadeddata' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onloadeddata"] = V; + } + + get onloadedmetadata() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadedmetadata' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadedmetadata"]); + } + + set onloadedmetadata(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadedmetadata' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadedmetadata' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onloadedmetadata"] = V; + } + + get onloadstart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadstart' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadstart"]); + } + + set onloadstart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadstart' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadstart' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onloadstart"] = V; + } + + get onmousedown() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmousedown' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmousedown"]); + } + + set onmousedown(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmousedown' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmousedown' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmousedown"] = V; + } + + get onmouseenter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseenter"]); + } + + set onmouseenter(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 'onmouseenter' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmouseenter"] = V; + } + + get onmouseleave() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + return; + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseleave"]); + } + + set onmouseleave(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 'onmouseleave' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmouseleave"] = V; + } + + get onmousemove() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmousemove' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmousemove"]); + } + + set onmousemove(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmousemove' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmousemove' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmousemove"] = V; + } + + get onmouseout() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmouseout' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseout"]); + } + + set onmouseout(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmouseout' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseout' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmouseout"] = V; + } + + get onmouseover() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmouseover' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseover"]); + } + + set onmouseover(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmouseover' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseover' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmouseover"] = V; + } + + get onmouseup() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmouseup' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmouseup"]); + } + + set onmouseup(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmouseup' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmouseup' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onmouseup"] = V; + } + + get onpaste() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpaste' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpaste"]); + } + + set onpaste(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpaste' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpaste' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onpaste"] = V; + } + + get onpause() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpause' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpause"]); + } + + set onpause(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpause' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpause' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onpause"] = V; + } + + get onplay() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onplay' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onplay"]); + } + + set onplay(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onplay' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onplay' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onplay"] = V; + } + + get onplaying() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onplaying' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onplaying"]); + } + + set onplaying(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onplaying' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onplaying' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onplaying"] = V; + } + + get onprogress() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onprogress' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onprogress"]); + } + + set onprogress(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onprogress' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onprogress' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onprogress"] = V; + } + + get onratechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onratechange' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onratechange"]); + } + + set onratechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onratechange' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onratechange' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onratechange"] = V; + } + + get onreset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onreset' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onreset"]); + } + + set onreset(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onreset' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onreset' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onreset"] = V; + } + + get onresize() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onresize' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onresize"]); + } + + set onresize(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onresize' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onresize' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onresize"] = V; + } + + get onscroll() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onscroll' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onscroll"]); + } + + set onscroll(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onscroll' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onscroll' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onscroll"] = V; + } + + get onscrollend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onscrollend' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onscrollend"]); + } + + set onscrollend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onscrollend' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onscrollend' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onscrollend"] = V; + } + + get onsecuritypolicyviolation() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onsecuritypolicyviolation' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onsecuritypolicyviolation"]); + } + + set onsecuritypolicyviolation(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onsecuritypolicyviolation' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onsecuritypolicyviolation' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onsecuritypolicyviolation"] = V; + } + + get onseeked() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onseeked' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onseeked"]); + } + + set onseeked(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onseeked' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onseeked' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onseeked"] = V; + } + + get onseeking() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onseeking' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onseeking"]); + } + + set onseeking(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onseeking' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onseeking' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onseeking"] = V; + } + + get onselect() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onselect' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onselect"]); + } + + set onselect(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onselect' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onselect' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onselect"] = V; + } + + get onslotchange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onslotchange' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onslotchange"]); + } + + set onslotchange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onslotchange' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onslotchange' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onslotchange"] = V; + } + + get onstalled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onstalled' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onstalled"]); + } + + set onstalled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onstalled' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onstalled' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onstalled"] = V; + } + + get onsubmit() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onsubmit' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onsubmit"]); + } + + set onsubmit(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onsubmit' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onsubmit' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onsubmit"] = V; + } + + get onsuspend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onsuspend' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onsuspend"]); + } + + set onsuspend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onsuspend' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onsuspend' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onsuspend"] = V; + } + + get ontimeupdate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontimeupdate' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontimeupdate"]); + } + + set ontimeupdate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontimeupdate' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontimeupdate' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ontimeupdate"] = V; + } + + get ontoggle() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontoggle' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontoggle"]); + } + + set ontoggle(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontoggle' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontoggle' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ontoggle"] = V; + } + + get onvolumechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onvolumechange' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onvolumechange"]); + } + + set onvolumechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onvolumechange' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onvolumechange' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onvolumechange"] = V; + } + + get onwaiting() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onwaiting' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onwaiting"]); + } + + set onwaiting(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onwaiting' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onwaiting' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onwaiting"] = V; + } + + get onwebkitanimationend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onwebkitanimationend' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onwebkitanimationend"]); + } + + set onwebkitanimationend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onwebkitanimationend' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onwebkitanimationend' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onwebkitanimationend"] = V; + } + + get onwebkitanimationiteration() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onwebkitanimationiteration' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onwebkitanimationiteration"]); + } + + set onwebkitanimationiteration(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onwebkitanimationiteration' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onwebkitanimationiteration' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onwebkitanimationiteration"] = V; + } + + get onwebkitanimationstart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onwebkitanimationstart' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onwebkitanimationstart"]); + } + + set onwebkitanimationstart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onwebkitanimationstart' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onwebkitanimationstart' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onwebkitanimationstart"] = V; + } + + get onwebkittransitionend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onwebkittransitionend' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onwebkittransitionend"]); + } + + set onwebkittransitionend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onwebkittransitionend' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onwebkittransitionend' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onwebkittransitionend"] = V; + } + + get onwheel() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onwheel' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onwheel"]); + } + + set onwheel(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onwheel' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onwheel' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onwheel"] = V; + } + + get ontouchstart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontouchstart' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontouchstart"]); + } + + set ontouchstart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontouchstart' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontouchstart' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ontouchstart"] = V; + } + + get ontouchend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontouchend' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontouchend"]); + } + + set ontouchend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontouchend' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontouchend' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ontouchend"] = V; + } + + get ontouchmove() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontouchmove' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontouchmove"]); + } + + set ontouchmove(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontouchmove' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontouchmove' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ontouchmove"] = V; + } + + get ontouchcancel() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontouchcancel' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontouchcancel"]); + } + + set ontouchcancel(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontouchcancel' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontouchcancel' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ontouchcancel"] = V; + } + + get onpointerover() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpointerover' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpointerover"]); + } + + set onpointerover(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpointerover' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpointerover' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onpointerover"] = V; + } + + get onpointerenter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpointerenter' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpointerenter"]); + } + + set onpointerenter(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpointerenter' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpointerenter' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onpointerenter"] = V; + } + + get onpointerdown() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpointerdown' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpointerdown"]); + } + + set onpointerdown(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpointerdown' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpointerdown' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onpointerdown"] = V; + } + + get onpointermove() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpointermove' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpointermove"]); + } + + set onpointermove(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpointermove' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpointermove' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onpointermove"] = V; + } + + get onpointerrawupdate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpointerrawupdate' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpointerrawupdate"]); + } + + set onpointerrawupdate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpointerrawupdate' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpointerrawupdate' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onpointerrawupdate"] = V; + } + + get onpointerup() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpointerup' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpointerup"]); + } + + set onpointerup(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpointerup' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpointerup' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onpointerup"] = V; + } + + get onpointercancel() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpointercancel' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpointercancel"]); + } + + set onpointercancel(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpointercancel' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpointercancel' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onpointercancel"] = V; + } + + get onpointerout() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpointerout' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpointerout"]); + } + + set onpointerout(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpointerout' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpointerout' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onpointerout"] = V; + } + + get onpointerleave() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpointerleave' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpointerleave"]); + } + + set onpointerleave(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpointerleave' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpointerleave' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onpointerleave"] = V; + } + + get ongotpointercapture() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ongotpointercapture' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ongotpointercapture"]); + } + + set ongotpointercapture(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ongotpointercapture' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ongotpointercapture' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["ongotpointercapture"] = V; + } + + get onlostpointercapture() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onlostpointercapture' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onlostpointercapture"]); + } + + set onlostpointercapture(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onlostpointercapture' called on an object that is not a valid instance of SVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onlostpointercapture' property on 'SVGElement': The provided value" + }); + } + esValue[implSymbol]["onlostpointercapture"] = V; + } + + get dataset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get dataset' called on an object that is not a valid instance of SVGElement." + ); + } + + return utils.getSameObject(this, "dataset", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["dataset"]); + }); + } + + get nonce() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get nonce' called on an object that is not a valid instance of SVGElement."); + } + + const value = esValue[implSymbol]._reflectGetTheContentAttribute("nonce"); + return value === null ? "" : value; + } + + set nonce(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set nonce' called on an object that is not a valid instance of SVGElement."); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'nonce' property on 'SVGElement': The provided value", + globals: globalObject + }); + + esValue[implSymbol]._reflectSetTheContentAttribute("nonce", V); + } + + get tabIndex() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get tabIndex' called on an object that is not a valid instance of SVGElement." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["tabIndex"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set tabIndex(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set tabIndex' called on an object that is not a valid instance of SVGElement." + ); + } + + V = conversions["long"](V, { + context: "Failed to set the 'tabIndex' property on 'SVGElement': The provided value", + globals: globalObject + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["tabIndex"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + } + Object.defineProperties(SVGElement.prototype, { + focus: { enumerable: true }, + blur: { enumerable: true }, + className: { enumerable: true }, + ownerSVGElement: { enumerable: true }, + viewportElement: { enumerable: true }, + style: { enumerable: true }, + onabort: { enumerable: true }, + onauxclick: { enumerable: true }, + onbeforeinput: { enumerable: true }, + onbeforematch: { enumerable: true }, + onbeforetoggle: { enumerable: true }, + onblur: { enumerable: true }, + oncancel: { enumerable: true }, + oncanplay: { enumerable: true }, + oncanplaythrough: { enumerable: true }, + onchange: { enumerable: true }, + onclick: { enumerable: true }, + onclose: { enumerable: true }, + oncontextlost: { enumerable: true }, + oncontextmenu: { enumerable: true }, + oncontextrestored: { enumerable: true }, + oncopy: { enumerable: true }, + oncuechange: { enumerable: true }, + oncut: { enumerable: true }, + ondblclick: { enumerable: true }, + ondrag: { enumerable: true }, + ondragend: { enumerable: true }, + ondragenter: { enumerable: true }, + ondragleave: { enumerable: true }, + ondragover: { enumerable: true }, + ondragstart: { enumerable: true }, + ondrop: { enumerable: true }, + ondurationchange: { enumerable: true }, + onemptied: { enumerable: true }, + onended: { enumerable: true }, + onerror: { enumerable: true }, + onfocus: { enumerable: true }, + onformdata: { enumerable: true }, + oninput: { enumerable: true }, + oninvalid: { enumerable: true }, + onkeydown: { enumerable: true }, + onkeypress: { enumerable: true }, + onkeyup: { enumerable: true }, + onload: { enumerable: true }, + onloadeddata: { enumerable: true }, + onloadedmetadata: { enumerable: true }, + onloadstart: { enumerable: true }, + onmousedown: { enumerable: true }, + onmouseenter: { enumerable: true }, + onmouseleave: { enumerable: true }, + onmousemove: { enumerable: true }, + onmouseout: { enumerable: true }, + onmouseover: { enumerable: true }, + onmouseup: { enumerable: true }, + onpaste: { enumerable: true }, + onpause: { enumerable: true }, + onplay: { enumerable: true }, + onplaying: { enumerable: true }, + onprogress: { enumerable: true }, + onratechange: { enumerable: true }, + onreset: { enumerable: true }, + onresize: { enumerable: true }, + onscroll: { enumerable: true }, + onscrollend: { enumerable: true }, + onsecuritypolicyviolation: { enumerable: true }, + onseeked: { enumerable: true }, + onseeking: { enumerable: true }, + onselect: { enumerable: true }, + onslotchange: { enumerable: true }, + onstalled: { enumerable: true }, + onsubmit: { enumerable: true }, + onsuspend: { enumerable: true }, + ontimeupdate: { enumerable: true }, + ontoggle: { enumerable: true }, + onvolumechange: { enumerable: true }, + onwaiting: { enumerable: true }, + onwebkitanimationend: { enumerable: true }, + onwebkitanimationiteration: { enumerable: true }, + onwebkitanimationstart: { enumerable: true }, + onwebkittransitionend: { enumerable: true }, + onwheel: { enumerable: true }, + ontouchstart: { enumerable: true }, + ontouchend: { enumerable: true }, + ontouchmove: { enumerable: true }, + ontouchcancel: { enumerable: true }, + onpointerover: { enumerable: true }, + onpointerenter: { enumerable: true }, + onpointerdown: { enumerable: true }, + onpointermove: { enumerable: true }, + onpointerrawupdate: { enumerable: true }, + onpointerup: { enumerable: true }, + onpointercancel: { enumerable: true }, + onpointerout: { enumerable: true }, + onpointerleave: { enumerable: true }, + ongotpointercapture: { enumerable: true }, + onlostpointercapture: { enumerable: true }, + dataset: { enumerable: true }, + nonce: { enumerable: true }, + tabIndex: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGElement + }); +}; + +const Impl = require("../nodes/SVGElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGGElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGGElement.js new file mode 100644 index 0000000000000000000000000000000000000000..b4fb95c6982069bf9df81610093fc0b7d41a88aa --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGGElement.js @@ -0,0 +1,109 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const SVGGraphicsElement = require("./SVGGraphicsElement.js"); + +const interfaceName = "SVGGElement"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGGElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGGElement"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + SVGGraphicsElement._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGGElement extends globalObject.SVGGraphicsElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(SVGGElement.prototype, { + [Symbol.toStringTag]: { value: "SVGGElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGGElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGGElement + }); +}; + +const Impl = require("../nodes/SVGGElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGGraphicsElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGGraphicsElement.js new file mode 100644 index 0000000000000000000000000000000000000000..837990eb69f55f7ddaccb1c6c496c5e8bf0ed703 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGGraphicsElement.js @@ -0,0 +1,139 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const SVGElement = require("./SVGElement.js"); + +const interfaceName = "SVGGraphicsElement"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGGraphicsElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGGraphicsElement"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + SVGElement._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGGraphicsElement extends globalObject.SVGElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get requiredExtensions() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get requiredExtensions' called on an object that is not a valid instance of SVGGraphicsElement." + ); + } + + return utils.getSameObject(this, "requiredExtensions", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["requiredExtensions"]); + }); + } + + get systemLanguage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get systemLanguage' called on an object that is not a valid instance of SVGGraphicsElement." + ); + } + + return utils.getSameObject(this, "systemLanguage", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["systemLanguage"]); + }); + } + } + Object.defineProperties(SVGGraphicsElement.prototype, { + requiredExtensions: { enumerable: true }, + systemLanguage: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGGraphicsElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGGraphicsElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGGraphicsElement + }); +}; + +const Impl = require("../nodes/SVGGraphicsElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGMetadataElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGMetadataElement.js new file mode 100644 index 0000000000000000000000000000000000000000..9ad2e77ce4f20a2659574115a57e583343fb9dbb --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGMetadataElement.js @@ -0,0 +1,109 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const SVGElement = require("./SVGElement.js"); + +const interfaceName = "SVGMetadataElement"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGMetadataElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGMetadataElement"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + SVGElement._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGMetadataElement extends globalObject.SVGElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(SVGMetadataElement.prototype, { + [Symbol.toStringTag]: { value: "SVGMetadataElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGMetadataElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGMetadataElement + }); +}; + +const Impl = require("../nodes/SVGMetadataElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGNumber.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGNumber.js new file mode 100644 index 0000000000000000000000000000000000000000..6a35e6feb6af5a81cef6780c3d3cf18fa7099f1d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGNumber.js @@ -0,0 +1,132 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "SVGNumber"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGNumber'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGNumber"].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); +}; + +exports._internalSetup = (wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGNumber { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get value() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get value' called on an object that is not a valid instance of SVGNumber."); + } + + return esValue[implSymbol]["value"]; + } + + set value(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set value' called on an object that is not a valid instance of SVGNumber."); + } + + V = conversions["float"](V, { + context: "Failed to set the 'value' property on 'SVGNumber': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["value"] = V; + } + } + Object.defineProperties(SVGNumber.prototype, { + value: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGNumber", configurable: true } + }); + ctorRegistry[interfaceName] = SVGNumber; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGNumber + }); +}; + +const Impl = require("../svg/SVGNumber-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGPreserveAspectRatio.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGPreserveAspectRatio.js new file mode 100644 index 0000000000000000000000000000000000000000..2080d7c54aec916fcabf5976e9a85c06337888e1 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGPreserveAspectRatio.js @@ -0,0 +1,196 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "SVGPreserveAspectRatio"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGPreserveAspectRatio'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGPreserveAspectRatio"].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); +}; + +exports._internalSetup = (wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGPreserveAspectRatio { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get align() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get align' called on an object that is not a valid instance of SVGPreserveAspectRatio." + ); + } + + return esValue[implSymbol]["align"]; + } + + set align(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set align' called on an object that is not a valid instance of SVGPreserveAspectRatio." + ); + } + + V = conversions["unsigned short"](V, { + context: "Failed to set the 'align' property on 'SVGPreserveAspectRatio': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["align"] = V; + } + + get meetOrSlice() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get meetOrSlice' called on an object that is not a valid instance of SVGPreserveAspectRatio." + ); + } + + return esValue[implSymbol]["meetOrSlice"]; + } + + set meetOrSlice(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set meetOrSlice' called on an object that is not a valid instance of SVGPreserveAspectRatio." + ); + } + + V = conversions["unsigned short"](V, { + context: "Failed to set the 'meetOrSlice' property on 'SVGPreserveAspectRatio': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["meetOrSlice"] = V; + } + } + Object.defineProperties(SVGPreserveAspectRatio.prototype, { + align: { enumerable: true }, + meetOrSlice: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGPreserveAspectRatio", configurable: true }, + SVG_PRESERVEASPECTRATIO_UNKNOWN: { value: 0, enumerable: true }, + SVG_PRESERVEASPECTRATIO_NONE: { value: 1, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMINYMIN: { value: 2, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMIDYMIN: { value: 3, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMAXYMIN: { value: 4, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMINYMID: { value: 5, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMIDYMID: { value: 6, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMAXYMID: { value: 7, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMINYMAX: { value: 8, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMIDYMAX: { value: 9, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMAXYMAX: { value: 10, enumerable: true }, + SVG_MEETORSLICE_UNKNOWN: { value: 0, enumerable: true }, + SVG_MEETORSLICE_MEET: { value: 1, enumerable: true }, + SVG_MEETORSLICE_SLICE: { value: 2, enumerable: true } + }); + Object.defineProperties(SVGPreserveAspectRatio, { + SVG_PRESERVEASPECTRATIO_UNKNOWN: { value: 0, enumerable: true }, + SVG_PRESERVEASPECTRATIO_NONE: { value: 1, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMINYMIN: { value: 2, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMIDYMIN: { value: 3, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMAXYMIN: { value: 4, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMINYMID: { value: 5, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMIDYMID: { value: 6, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMAXYMID: { value: 7, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMINYMAX: { value: 8, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMIDYMAX: { value: 9, enumerable: true }, + SVG_PRESERVEASPECTRATIO_XMAXYMAX: { value: 10, enumerable: true }, + SVG_MEETORSLICE_UNKNOWN: { value: 0, enumerable: true }, + SVG_MEETORSLICE_MEET: { value: 1, enumerable: true }, + SVG_MEETORSLICE_SLICE: { value: 2, enumerable: true } + }); + ctorRegistry[interfaceName] = SVGPreserveAspectRatio; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGPreserveAspectRatio + }); +}; + +const Impl = require("../svg/SVGPreserveAspectRatio-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGRect.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGRect.js new file mode 100644 index 0000000000000000000000000000000000000000..043979d32f4580d48b37147226d819961d1514a4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGRect.js @@ -0,0 +1,210 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "SVGRect"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGRect'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGRect"].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); +}; + +exports._internalSetup = (wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGRect { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get x() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get x' called on an object that is not a valid instance of SVGRect."); + } + + return esValue[implSymbol]["x"]; + } + + set x(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set x' called on an object that is not a valid instance of SVGRect."); + } + + V = conversions["float"](V, { + context: "Failed to set the 'x' property on 'SVGRect': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["x"] = V; + } + + get y() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get y' called on an object that is not a valid instance of SVGRect."); + } + + return esValue[implSymbol]["y"]; + } + + set y(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set y' called on an object that is not a valid instance of SVGRect."); + } + + V = conversions["float"](V, { + context: "Failed to set the 'y' property on 'SVGRect': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["y"] = V; + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get width' called on an object that is not a valid instance of SVGRect."); + } + + return esValue[implSymbol]["width"]; + } + + set width(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set width' called on an object that is not a valid instance of SVGRect."); + } + + V = conversions["float"](V, { + context: "Failed to set the 'width' property on 'SVGRect': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["width"] = V; + } + + get height() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get height' called on an object that is not a valid instance of SVGRect."); + } + + return esValue[implSymbol]["height"]; + } + + set height(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set height' called on an object that is not a valid instance of SVGRect."); + } + + V = conversions["float"](V, { + context: "Failed to set the 'height' property on 'SVGRect': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["height"] = V; + } + } + Object.defineProperties(SVGRect.prototype, { + x: { enumerable: true }, + y: { enumerable: true }, + width: { enumerable: true }, + height: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGRect", configurable: true } + }); + ctorRegistry[interfaceName] = SVGRect; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGRect + }); +}; + +const Impl = require("../svg/SVGRect-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGSVGElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGSVGElement.js new file mode 100644 index 0000000000000000000000000000000000000000..a77099e1fb719b25f236266eff7408a776c89a0f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGSVGElement.js @@ -0,0 +1,786 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const create_SVGAnimatedRect = require("./SVGAnimatedRect.js").create; +const create_SVGAnimatedPreserveAspectRatio = require("./SVGAnimatedPreserveAspectRatio.js").create; +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const OnBeforeUnloadEventHandlerNonNull = require("./OnBeforeUnloadEventHandlerNonNull.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const SVGGraphicsElement = require("./SVGGraphicsElement.js"); + +const interfaceName = "SVGSVGElement"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGSVGElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGSVGElement"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + SVGGraphicsElement._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGSVGElement extends globalObject.SVGGraphicsElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + createSVGNumber() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createSVGNumber' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].createSVGNumber()); + } + + createSVGRect() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'createSVGRect' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].createSVGRect()); + } + + 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 SVGSVGElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getElementById' on 'SVGSVGElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getElementById' on 'SVGSVGElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getElementById(...args)); + } + + suspendRedraw(maxWaitMilliseconds) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'suspendRedraw' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'suspendRedraw' on 'SVGSVGElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'suspendRedraw' on 'SVGSVGElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].suspendRedraw(...args); + } + + unsuspendRedraw(suspendHandleID) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'unsuspendRedraw' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'unsuspendRedraw' on 'SVGSVGElement': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'unsuspendRedraw' on 'SVGSVGElement': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].unsuspendRedraw(...args); + } + + unsuspendRedrawAll() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'unsuspendRedrawAll' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return esValue[implSymbol].unsuspendRedrawAll(); + } + + forceRedraw() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'forceRedraw' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return esValue[implSymbol].forceRedraw(); + } + + get viewBox() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get viewBox' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.getSameObject(this, "viewBox", () => { + return create_SVGAnimatedRect(globalObject, [], { + element: esValue[implSymbol], + attribute: "viewBox" + }); + }); + } + + get preserveAspectRatio() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get preserveAspectRatio' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.getSameObject(this, "preserveAspectRatio", () => { + return create_SVGAnimatedPreserveAspectRatio(globalObject, [], { + element: esValue[implSymbol] + }); + }); + } + + get onafterprint() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onafterprint' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onafterprint"]); + } + + set onafterprint(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onafterprint' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onafterprint' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onafterprint"] = V; + } + + get onbeforeprint() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onbeforeprint' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeprint"]); + } + + set onbeforeprint(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onbeforeprint' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onbeforeprint' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onbeforeprint"] = V; + } + + get onbeforeunload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onbeforeunload' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onbeforeunload"]); + } + + set onbeforeunload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onbeforeunload' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = OnBeforeUnloadEventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onbeforeunload' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onbeforeunload"] = V; + } + + get onhashchange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onhashchange' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onhashchange"]); + } + + set onhashchange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onhashchange' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onhashchange' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onhashchange"] = V; + } + + get onlanguagechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onlanguagechange' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onlanguagechange"]); + } + + set onlanguagechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onlanguagechange' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onlanguagechange' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onlanguagechange"] = V; + } + + get onmessage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmessage' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmessage"]); + } + + set onmessage(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmessage' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmessage' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onmessage"] = V; + } + + get onmessageerror() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmessageerror' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmessageerror"]); + } + + set onmessageerror(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmessageerror' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmessageerror' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onmessageerror"] = V; + } + + get onoffline() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onoffline' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onoffline"]); + } + + set onoffline(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onoffline' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onoffline' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onoffline"] = V; + } + + get ononline() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ononline' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ononline"]); + } + + set ononline(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ononline' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ononline' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["ononline"] = V; + } + + get onpagehide() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpagehide' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpagehide"]); + } + + set onpagehide(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpagehide' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpagehide' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onpagehide"] = V; + } + + get onpageshow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpageshow' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpageshow"]); + } + + set onpageshow(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpageshow' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpageshow' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onpageshow"] = V; + } + + get onpopstate() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onpopstate' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onpopstate"]); + } + + set onpopstate(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onpopstate' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onpopstate' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onpopstate"] = V; + } + + get onrejectionhandled() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onrejectionhandled' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onrejectionhandled"]); + } + + set onrejectionhandled(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onrejectionhandled' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onrejectionhandled' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onrejectionhandled"] = V; + } + + get onstorage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onstorage' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onstorage"]); + } + + set onstorage(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onstorage' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onstorage' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onstorage"] = V; + } + + get onunhandledrejection() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onunhandledrejection' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onunhandledrejection"]); + } + + set onunhandledrejection(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onunhandledrejection' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onunhandledrejection' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onunhandledrejection"] = V; + } + + get onunload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onunload' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onunload"]); + } + + set onunload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onunload' called on an object that is not a valid instance of SVGSVGElement." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onunload' property on 'SVGSVGElement': The provided value" + }); + } + esValue[implSymbol]["onunload"] = V; + } + } + Object.defineProperties(SVGSVGElement.prototype, { + createSVGNumber: { enumerable: true }, + createSVGRect: { enumerable: true }, + getElementById: { enumerable: true }, + suspendRedraw: { enumerable: true }, + unsuspendRedraw: { enumerable: true }, + unsuspendRedrawAll: { enumerable: true }, + forceRedraw: { enumerable: true }, + viewBox: { enumerable: true }, + preserveAspectRatio: { enumerable: true }, + onafterprint: { enumerable: true }, + onbeforeprint: { enumerable: true }, + onbeforeunload: { enumerable: true }, + onhashchange: { enumerable: true }, + onlanguagechange: { enumerable: true }, + onmessage: { enumerable: true }, + onmessageerror: { enumerable: true }, + onoffline: { enumerable: true }, + ononline: { enumerable: true }, + onpagehide: { enumerable: true }, + onpageshow: { enumerable: true }, + onpopstate: { enumerable: true }, + onrejectionhandled: { enumerable: true }, + onstorage: { enumerable: true }, + onunhandledrejection: { enumerable: true }, + onunload: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGSVGElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGSVGElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGSVGElement + }); +}; + +const Impl = require("../nodes/SVGSVGElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGStringList.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGStringList.js new file mode 100644 index 0000000000000000000000000000000000000000..e845155879b04ef0de0b91805cc634c99fd51e1f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGStringList.js @@ -0,0 +1,511 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "SVGStringList"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGStringList'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGStringList"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +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); +}; + +exports._internalSetup = (wrapper, 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 = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGStringList { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + 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 SVGStringList."); + } + + return esValue[implSymbol].clear(); + } + + initialize(newItem) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'initialize' called on an object that is not a valid instance of SVGStringList." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'initialize' on 'SVGStringList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initialize' on 'SVGStringList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].initialize(...args); + } + + getItem(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getItem' called on an object that is not a valid instance of SVGStringList." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getItem' on 'SVGStringList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'getItem' on 'SVGStringList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].getItem(...args); + } + + insertItemBefore(newItem, index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'insertItemBefore' called on an object that is not a valid instance of SVGStringList." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'insertItemBefore' on 'SVGStringList': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'insertItemBefore' on 'SVGStringList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'insertItemBefore' on 'SVGStringList': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].insertItemBefore(...args); + } + + replaceItem(newItem, index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'replaceItem' called on an object that is not a valid instance of SVGStringList." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'replaceItem' on 'SVGStringList': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'replaceItem' on 'SVGStringList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'replaceItem' on 'SVGStringList': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].replaceItem(...args); + } + + removeItem(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'removeItem' called on an object that is not a valid instance of SVGStringList." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'removeItem' on 'SVGStringList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'removeItem' on 'SVGStringList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].removeItem(...args); + } + + appendItem(newItem) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'appendItem' called on an object that is not a valid instance of SVGStringList." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'appendItem' on 'SVGStringList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'appendItem' on 'SVGStringList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].appendItem(...args); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of SVGStringList." + ); + } + + return esValue[implSymbol]["length"]; + } + + get numberOfItems() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get numberOfItems' called on an object that is not a valid instance of SVGStringList." + ); + } + + return esValue[implSymbol]["numberOfItems"]; + } + } + Object.defineProperties(SVGStringList.prototype, { + clear: { enumerable: true }, + initialize: { enumerable: true }, + getItem: { enumerable: true }, + insertItemBefore: { enumerable: true }, + replaceItem: { enumerable: true }, + removeItem: { enumerable: true }, + appendItem: { enumerable: true }, + length: { enumerable: true }, + numberOfItems: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGStringList", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = SVGStringList; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGStringList + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + + if (target[implSymbol][utils.supportsPropertyIndex](index)) { + const indexedValue = target[implSymbol].getItem(index); + return { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + let indexedValue = V; + + indexedValue = conversions["DOMString"](indexedValue, { + context: "Failed to set the " + index + " property on 'SVGStringList': The provided value", + globals: globalObject + }); + + const creating = !target[implSymbol][utils.supportsPropertyIndex](index); + if (creating) { + target[implSymbol][utils.indexedSetNew](index, indexedValue); + } else { + target[implSymbol][utils.indexedSetExisting](index, indexedValue); + } + + return true; + } + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + + if (target[implSymbol][utils.supportsPropertyIndex](index)) { + const indexedValue = target[implSymbol].getItem(index); + ownDesc = { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + return utils.ordinarySetWithOwnDescriptor(target, P, V, receiver, ownDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + if (desc.get || desc.set) { + return false; + } + + const index = P >>> 0; + let indexedValue = desc.value; + + indexedValue = conversions["DOMString"](indexedValue, { + context: "Failed to set the " + index + " property on 'SVGStringList': The provided value", + globals: globalObject + }); + + const creating = !target[implSymbol][utils.supportsPropertyIndex](index); + if (creating) { + target[implSymbol][utils.indexedSetNew](index, indexedValue); + } else { + target[implSymbol][utils.indexedSetExisting](index, indexedValue); + } + + return true; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !target[implSymbol][utils.supportsPropertyIndex](index); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../svg/SVGStringList-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGSwitchElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGSwitchElement.js new file mode 100644 index 0000000000000000000000000000000000000000..92e4b667ffc33af3399f47819a94004fb7b21a5a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGSwitchElement.js @@ -0,0 +1,109 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const SVGGraphicsElement = require("./SVGGraphicsElement.js"); + +const interfaceName = "SVGSwitchElement"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGSwitchElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGSwitchElement"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + SVGGraphicsElement._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGSwitchElement extends globalObject.SVGGraphicsElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(SVGSwitchElement.prototype, { + [Symbol.toStringTag]: { value: "SVGSwitchElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGSwitchElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGSwitchElement + }); +}; + +const Impl = require("../nodes/SVGSwitchElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGSymbolElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGSymbolElement.js new file mode 100644 index 0000000000000000000000000000000000000000..df07c2842138d5a5d1610c47be7fcd556410d959 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGSymbolElement.js @@ -0,0 +1,146 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const create_SVGAnimatedRect = require("./SVGAnimatedRect.js").create; +const create_SVGAnimatedPreserveAspectRatio = require("./SVGAnimatedPreserveAspectRatio.js").create; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const SVGGraphicsElement = require("./SVGGraphicsElement.js"); + +const interfaceName = "SVGSymbolElement"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGSymbolElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGSymbolElement"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + SVGGraphicsElement._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGSymbolElement extends globalObject.SVGGraphicsElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get viewBox() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get viewBox' called on an object that is not a valid instance of SVGSymbolElement." + ); + } + + return utils.getSameObject(this, "viewBox", () => { + return create_SVGAnimatedRect(globalObject, [], { + element: esValue[implSymbol], + attribute: "viewBox" + }); + }); + } + + get preserveAspectRatio() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get preserveAspectRatio' called on an object that is not a valid instance of SVGSymbolElement." + ); + } + + return utils.getSameObject(this, "preserveAspectRatio", () => { + return create_SVGAnimatedPreserveAspectRatio(globalObject, [], { + element: esValue[implSymbol] + }); + }); + } + } + Object.defineProperties(SVGSymbolElement.prototype, { + viewBox: { enumerable: true }, + preserveAspectRatio: { enumerable: true }, + [Symbol.toStringTag]: { value: "SVGSymbolElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGSymbolElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGSymbolElement + }); +}; + +const Impl = require("../nodes/SVGSymbolElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SVGTitleElement.js b/node_modules/jsdom/lib/jsdom/living/generated/SVGTitleElement.js new file mode 100644 index 0000000000000000000000000000000000000000..f29460377053f482b717d0b292bc948ae4f298aa --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SVGTitleElement.js @@ -0,0 +1,109 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const SVGElement = require("./SVGElement.js"); + +const interfaceName = "SVGTitleElement"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SVGTitleElement'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SVGTitleElement"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + SVGElement._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SVGTitleElement extends globalObject.SVGElement { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(SVGTitleElement.prototype, { + [Symbol.toStringTag]: { value: "SVGTitleElement", configurable: true } + }); + ctorRegistry[interfaceName] = SVGTitleElement; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SVGTitleElement + }); +}; + +const Impl = require("../nodes/SVGTitleElement-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Screen.js b/node_modules/jsdom/lib/jsdom/living/generated/Screen.js new file mode 100644 index 0000000000000000000000000000000000000000..943f35b8e019d8940140246add24f96ad3af21fa --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Screen.js @@ -0,0 +1,180 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Screen"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'Screen'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Screen"].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); +}; + +exports._internalSetup = (wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Screen { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get availWidth() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get availWidth' called on an object that is not a valid instance of Screen." + ); + } + + return esValue[implSymbol]["availWidth"]; + } + + get availHeight() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get availHeight' called on an object that is not a valid instance of Screen." + ); + } + + return esValue[implSymbol]["availHeight"]; + } + + get width() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get width' called on an object that is not a valid instance of Screen."); + } + + return esValue[implSymbol]["width"]; + } + + get height() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get height' called on an object that is not a valid instance of Screen."); + } + + return esValue[implSymbol]["height"]; + } + + get colorDepth() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get colorDepth' called on an object that is not a valid instance of Screen." + ); + } + + return esValue[implSymbol]["colorDepth"]; + } + + get pixelDepth() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get pixelDepth' called on an object that is not a valid instance of Screen." + ); + } + + return esValue[implSymbol]["pixelDepth"]; + } + } + Object.defineProperties(Screen.prototype, { + availWidth: { enumerable: true }, + availHeight: { enumerable: true }, + width: { enumerable: true }, + height: { enumerable: true }, + colorDepth: { enumerable: true }, + pixelDepth: { enumerable: true }, + [Symbol.toStringTag]: { value: "Screen", configurable: true } + }); + ctorRegistry[interfaceName] = Screen; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Screen + }); +}; + +const Impl = require("../window/Screen-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ScrollBehavior.js b/node_modules/jsdom/lib/jsdom/living/generated/ScrollBehavior.js new file mode 100644 index 0000000000000000000000000000000000000000..9668f63d8253ae1bf7ca8212f50925d819ba92ff --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ScrollBehavior.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["auto", "instant", "smooth"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for ScrollBehavior`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ScrollIntoViewOptions.js b/node_modules/jsdom/lib/jsdom/living/generated/ScrollIntoViewOptions.js new file mode 100644 index 0000000000000000000000000000000000000000..00cb221f699520ba2fffa1e7c4d9ffa43e262f99 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ScrollIntoViewOptions.js @@ -0,0 +1,45 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ScrollLogicalPosition = require("./ScrollLogicalPosition.js"); +const ScrollOptions = require("./ScrollOptions.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + ScrollOptions._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "block"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = ScrollLogicalPosition.convert(globalObject, value, { context: context + " has member 'block' that" }); + + ret[key] = value; + } else { + ret[key] = "start"; + } + } + + { + const key = "inline"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = ScrollLogicalPosition.convert(globalObject, value, { context: context + " has member 'inline' that" }); + + ret[key] = value; + } else { + ret[key] = "nearest"; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ScrollLogicalPosition.js b/node_modules/jsdom/lib/jsdom/living/generated/ScrollLogicalPosition.js new file mode 100644 index 0000000000000000000000000000000000000000..f7e9a10affcc430de94b532a82af397059114e68 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ScrollLogicalPosition.js @@ -0,0 +1,14 @@ +"use strict"; + +const enumerationValues = new Set(["start", "center", "end", "nearest"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError( + `${context} '${string}' is not a valid enumeration value for ScrollLogicalPosition` + ); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ScrollOptions.js b/node_modules/jsdom/lib/jsdom/living/generated/ScrollOptions.js new file mode 100644 index 0000000000000000000000000000000000000000..1bfa5f3729e5de192e62e42d543b6fd8433f793e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ScrollOptions.js @@ -0,0 +1,30 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ScrollBehavior = require("./ScrollBehavior.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "behavior"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = ScrollBehavior.convert(globalObject, value, { context: context + " has member 'behavior' that" }); + + ret[key] = value; + } else { + ret[key] = "auto"; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ScrollRestoration.js b/node_modules/jsdom/lib/jsdom/living/generated/ScrollRestoration.js new file mode 100644 index 0000000000000000000000000000000000000000..1b3c19bd9446b63b204724f85af5033414bcd20f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ScrollRestoration.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["auto", "manual"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for ScrollRestoration`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Selection.js b/node_modules/jsdom/lib/jsdom/living/generated/Selection.js new file mode 100644 index 0000000000000000000000000000000000000000..3e039cc84855baba1eafaf80228366507385cef8 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Selection.js @@ -0,0 +1,569 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Range = require("./Range.js"); +const Node = require("./Node.js"); +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Selection"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'Selection'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Selection"].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); +}; + +exports._internalSetup = (wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Selection { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + getRangeAt(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'getRangeAt' called on an object that is not a valid instance of Selection."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getRangeAt' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'getRangeAt' on 'Selection': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].getRangeAt(...args)); + } + + addRange(range) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'addRange' called on an object that is not a valid instance of Selection."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'addRange' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Range.convert(globalObject, curArg, { + context: "Failed to execute 'addRange' on 'Selection': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].addRange(...args); + } + + removeRange(range) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'removeRange' called on an object that is not a valid instance of Selection." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'removeRange' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Range.convert(globalObject, curArg, { + context: "Failed to execute 'removeRange' on 'Selection': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].removeRange(...args); + } + + removeAllRanges() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'removeAllRanges' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol].removeAllRanges(); + } + + empty() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'empty' called on an object that is not a valid instance of Selection."); + } + + return esValue[implSymbol].empty(); + } + + collapse(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'collapse' called on an object that is not a valid instance of Selection."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'collapse' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'collapse' on 'Selection': parameter 1" + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'collapse' on 'Selection': parameter 2", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + return esValue[implSymbol].collapse(...args); + } + + setPosition(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setPosition' called on an object that is not a valid instance of Selection." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'setPosition' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setPosition' on 'Selection': parameter 1" + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setPosition' on 'Selection': parameter 2", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + return esValue[implSymbol].setPosition(...args); + } + + collapseToStart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'collapseToStart' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol].collapseToStart(); + } + + collapseToEnd() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'collapseToEnd' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol].collapseToEnd(); + } + + extend(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'extend' called on an object that is not a valid instance of Selection."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'extend' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'extend' on 'Selection': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'extend' on 'Selection': parameter 2", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + return esValue[implSymbol].extend(...args); + } + + setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setBaseAndExtent' called on an object that is not a valid instance of Selection." + ); + } + + if (arguments.length < 4) { + throw new globalObject.TypeError( + `Failed to execute 'setBaseAndExtent' on 'Selection': 4 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setBaseAndExtent' on 'Selection': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setBaseAndExtent' on 'Selection': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'setBaseAndExtent' on 'Selection': parameter 3" + }); + args.push(curArg); + } + { + let curArg = arguments[3]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'setBaseAndExtent' on 'Selection': parameter 4", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setBaseAndExtent(...args); + } + + selectAllChildren(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'selectAllChildren' called on an object that is not a valid instance of Selection." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'selectAllChildren' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'selectAllChildren' on 'Selection': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].selectAllChildren(...args); + } + + deleteFromDocument() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'deleteFromDocument' called on an object that is not a valid instance of Selection." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol].deleteFromDocument(); + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + containsNode(node) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'containsNode' called on an object that is not a valid instance of Selection." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'containsNode' on 'Selection': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'containsNode' on 'Selection': parameter 1" + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'containsNode' on 'Selection': parameter 2", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + return esValue[implSymbol].containsNode(...args); + } + + toString() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'toString' called on an object that is not a valid instance of Selection."); + } + + return esValue[implSymbol].toString(); + } + + get anchorNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get anchorNode' called on an object that is not a valid instance of Selection." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["anchorNode"]); + } + + get anchorOffset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get anchorOffset' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol]["anchorOffset"]; + } + + get focusNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get focusNode' called on an object that is not a valid instance of Selection." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["focusNode"]); + } + + get focusOffset() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get focusOffset' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol]["focusOffset"]; + } + + get isCollapsed() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get isCollapsed' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol]["isCollapsed"]; + } + + get rangeCount() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rangeCount' called on an object that is not a valid instance of Selection." + ); + } + + return esValue[implSymbol]["rangeCount"]; + } + + get type() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get type' called on an object that is not a valid instance of Selection."); + } + + return esValue[implSymbol]["type"]; + } + } + Object.defineProperties(Selection.prototype, { + getRangeAt: { enumerable: true }, + addRange: { enumerable: true }, + removeRange: { enumerable: true }, + removeAllRanges: { enumerable: true }, + empty: { enumerable: true }, + collapse: { enumerable: true }, + setPosition: { enumerable: true }, + collapseToStart: { enumerable: true }, + collapseToEnd: { enumerable: true }, + extend: { enumerable: true }, + setBaseAndExtent: { enumerable: true }, + selectAllChildren: { enumerable: true }, + deleteFromDocument: { enumerable: true }, + containsNode: { enumerable: true }, + toString: { enumerable: true }, + anchorNode: { enumerable: true }, + anchorOffset: { enumerable: true }, + focusNode: { enumerable: true }, + focusOffset: { enumerable: true }, + isCollapsed: { enumerable: true }, + rangeCount: { enumerable: true }, + type: { enumerable: true }, + [Symbol.toStringTag]: { value: "Selection", configurable: true } + }); + ctorRegistry[interfaceName] = Selection; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Selection + }); +}; + +const Impl = require("../selection/Selection-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SelectionMode.js b/node_modules/jsdom/lib/jsdom/living/generated/SelectionMode.js new file mode 100644 index 0000000000000000000000000000000000000000..dc807c74a0ca2b1951e1ce57f6f52da5852771cc --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SelectionMode.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["select", "start", "end", "preserve"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for SelectionMode`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ShadowRoot.js b/node_modules/jsdom/lib/jsdom/living/generated/ShadowRoot.js new file mode 100644 index 0000000000000000000000000000000000000000..b170d132fb1a6cada42c8abee8d1ee49414e1e5a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ShadowRoot.js @@ -0,0 +1,187 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ceReactionsPreSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPreSteps; +const ceReactionsPostSteps_helpers_custom_elements = require("../helpers/custom-elements.js").ceReactionsPostSteps; +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const DocumentFragment = require("./DocumentFragment.js"); + +const interfaceName = "ShadowRoot"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'ShadowRoot'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["ShadowRoot"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + DocumentFragment._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class ShadowRoot extends globalObject.DocumentFragment { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get mode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get mode' called on an object that is not a valid instance of ShadowRoot."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["mode"]); + } + + get host() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get host' called on an object that is not a valid instance of ShadowRoot."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["host"]); + } + + get innerHTML() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get innerHTML' called on an object that is not a valid instance of ShadowRoot." + ); + } + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + return esValue[implSymbol]["innerHTML"]; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + set innerHTML(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set innerHTML' called on an object that is not a valid instance of ShadowRoot." + ); + } + + V = conversions["DOMString"](V, { + context: "Failed to set the 'innerHTML' property on 'ShadowRoot': The provided value", + globals: globalObject, + treatNullAsEmptyString: true + }); + + ceReactionsPreSteps_helpers_custom_elements(globalObject); + try { + esValue[implSymbol]["innerHTML"] = V; + } finally { + ceReactionsPostSteps_helpers_custom_elements(globalObject); + } + } + + get activeElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get activeElement' called on an object that is not a valid instance of ShadowRoot." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["activeElement"]); + } + } + Object.defineProperties(ShadowRoot.prototype, { + mode: { enumerable: true }, + host: { enumerable: true }, + innerHTML: { enumerable: true }, + activeElement: { enumerable: true }, + [Symbol.toStringTag]: { value: "ShadowRoot", configurable: true } + }); + ctorRegistry[interfaceName] = ShadowRoot; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: ShadowRoot + }); +}; + +const Impl = require("../nodes/ShadowRoot-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ShadowRootInit.js b/node_modules/jsdom/lib/jsdom/living/generated/ShadowRootInit.js new file mode 100644 index 0000000000000000000000000000000000000000..660214762d779e31ba19c41a37a1cc0139fb86f4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ShadowRootInit.js @@ -0,0 +1,30 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const ShadowRootMode = require("./ShadowRootMode.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "mode"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = ShadowRootMode.convert(globalObject, value, { context: context + " has member 'mode' that" }); + + ret[key] = value; + } else { + throw new globalObject.TypeError("mode is required in 'ShadowRootInit'"); + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ShadowRootMode.js b/node_modules/jsdom/lib/jsdom/living/generated/ShadowRootMode.js new file mode 100644 index 0000000000000000000000000000000000000000..37607134596dc914f28a2510a13f7685c7aedf1f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ShadowRootMode.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["open", "closed"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for ShadowRootMode`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/StaticRange.js b/node_modules/jsdom/lib/jsdom/living/generated/StaticRange.js new file mode 100644 index 0000000000000000000000000000000000000000..50270da1b10cad694240cde176e0e3523b4a1b2c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/StaticRange.js @@ -0,0 +1,123 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const StaticRangeInit = require("./StaticRangeInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const AbstractRange = require("./AbstractRange.js"); + +const interfaceName = "StaticRange"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'StaticRange'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["StaticRange"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + AbstractRange._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class StaticRange extends globalObject.AbstractRange { + constructor(init) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'StaticRange': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = StaticRangeInit.convert(globalObject, curArg, { + context: "Failed to construct 'StaticRange': parameter 1" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + } + Object.defineProperties(StaticRange.prototype, { + [Symbol.toStringTag]: { value: "StaticRange", configurable: true } + }); + ctorRegistry[interfaceName] = StaticRange; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: StaticRange + }); +}; + +const Impl = require("../range/StaticRange-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/StaticRangeInit.js b/node_modules/jsdom/lib/jsdom/living/generated/StaticRangeInit.js new file mode 100644 index 0000000000000000000000000000000000000000..0be22119d84a402963644ceeb6df10364605e867 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/StaticRangeInit.js @@ -0,0 +1,72 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Node = require("./Node.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + { + const key = "endContainer"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = Node.convert(globalObject, value, { context: context + " has member 'endContainer' that" }); + + ret[key] = value; + } else { + throw new globalObject.TypeError("endContainer is required in 'StaticRangeInit'"); + } + } + + { + const key = "endOffset"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long"](value, { + context: context + " has member 'endOffset' that", + globals: globalObject + }); + + ret[key] = value; + } else { + throw new globalObject.TypeError("endOffset is required in 'StaticRangeInit'"); + } + } + + { + const key = "startContainer"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = Node.convert(globalObject, value, { context: context + " has member 'startContainer' that" }); + + ret[key] = value; + } else { + throw new globalObject.TypeError("startContainer is required in 'StaticRangeInit'"); + } + } + + { + const key = "startOffset"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long"](value, { + context: context + " has member 'startOffset' that", + globals: globalObject + }); + + ret[key] = value; + } else { + throw new globalObject.TypeError("startOffset is required in 'StaticRangeInit'"); + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Storage.js b/node_modules/jsdom/lib/jsdom/living/generated/Storage.js new file mode 100644 index 0000000000000000000000000000000000000000..3c4b561c578404c1a7f87998c966e7ab1e4b9dbb --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Storage.js @@ -0,0 +1,397 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "Storage"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'Storage'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Storage"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +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); +}; + +exports._internalSetup = (wrapper, 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 = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Storage { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + key(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'key' called on an object that is not a valid instance of Storage."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'key' on 'Storage': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'key' on 'Storage': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].key(...args); + } + + getItem(key) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'getItem' called on an object that is not a valid instance of Storage."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getItem' on 'Storage': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'getItem' on 'Storage': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].getItem(...args); + } + + setItem(key, value) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'setItem' called on an object that is not a valid instance of Storage."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'setItem' on 'Storage': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setItem' on 'Storage': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'setItem' on 'Storage': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setItem(...args); + } + + removeItem(key) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'removeItem' called on an object that is not a valid instance of Storage."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'removeItem' on 'Storage': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'removeItem' on 'Storage': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].removeItem(...args); + } + + 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 Storage."); + } + + return esValue[implSymbol].clear(); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get length' called on an object that is not a valid instance of Storage."); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(Storage.prototype, { + key: { enumerable: true }, + getItem: { enumerable: true }, + setItem: { enumerable: true }, + removeItem: { enumerable: true }, + clear: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "Storage", configurable: true } + }); + ctorRegistry[interfaceName] = Storage; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Storage + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyNames]) { + if (!(key in target)) { + keys.add(`${key}`); + } + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + const namedValue = target[implSymbol].getItem(P); + + if (namedValue !== null && !(P in target) && !ignoreNamedProps) { + return { + writable: true, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(namedValue) + }; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + + if (typeof P === "string") { + let namedValue = V; + + namedValue = conversions["DOMString"](namedValue, { + context: "Failed to set the '" + P + "' property on 'Storage': The provided value", + globals: globalObject + }); + + target[implSymbol].setItem(P, namedValue); + + return true; + } + } + let ownDesc; + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + return utils.ordinarySetWithOwnDescriptor(target, P, V, receiver, ownDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + if (!Object.hasOwn(target, P)) { + if (desc.get || desc.set) { + return false; + } + + let namedValue = desc.value; + + namedValue = conversions["DOMString"](namedValue, { + context: "Failed to set the '" + P + "' property on 'Storage': The provided value", + globals: globalObject + }); + + target[implSymbol].setItem(P, namedValue); + + return true; + } + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (target[implSymbol].getItem(P) !== null && !(P in target)) { + target[implSymbol].removeItem(P); + return true; + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../webstorage/Storage-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/StorageEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/StorageEvent.js new file mode 100644 index 0000000000000000000000000000000000000000..23a92d8bb6f775dc51bf114b34a3f0ed0b7fbac0 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/StorageEvent.js @@ -0,0 +1,318 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const StorageEventInit = require("./StorageEventInit.js"); +const Storage = require("./Storage.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "StorageEvent"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'StorageEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["StorageEvent"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class StorageEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'StorageEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'StorageEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = StorageEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'StorageEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + initStorageEvent(type) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'initStorageEvent' called on an object that is not a valid instance of StorageEvent." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'initStorageEvent' on 'StorageEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 2", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 3", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 4", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[4]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 5", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[5]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 6", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[6]; + if (curArg !== undefined) { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 7", + globals: globalObject + }); + } else { + curArg = ""; + } + args.push(curArg); + } + { + let curArg = arguments[7]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = Storage.convert(globalObject, curArg, { + context: "Failed to execute 'initStorageEvent' on 'StorageEvent': parameter 8" + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + return esValue[implSymbol].initStorageEvent(...args); + } + + get key() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get key' called on an object that is not a valid instance of StorageEvent."); + } + + return esValue[implSymbol]["key"]; + } + + get oldValue() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get oldValue' called on an object that is not a valid instance of StorageEvent." + ); + } + + return esValue[implSymbol]["oldValue"]; + } + + get newValue() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get newValue' called on an object that is not a valid instance of StorageEvent." + ); + } + + return esValue[implSymbol]["newValue"]; + } + + 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 StorageEvent."); + } + + return esValue[implSymbol]["url"]; + } + + get storageArea() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get storageArea' called on an object that is not a valid instance of StorageEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["storageArea"]); + } + } + Object.defineProperties(StorageEvent.prototype, { + initStorageEvent: { enumerable: true }, + key: { enumerable: true }, + oldValue: { enumerable: true }, + newValue: { enumerable: true }, + url: { enumerable: true }, + storageArea: { enumerable: true }, + [Symbol.toStringTag]: { value: "StorageEvent", configurable: true } + }); + ctorRegistry[interfaceName] = StorageEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: StorageEvent + }); +}; + +const Impl = require("../events/StorageEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/StorageEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/StorageEventInit.js new file mode 100644 index 0000000000000000000000000000000000000000..c51c7127d002553686115edac2a70aa1048802a3 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/StorageEventInit.js @@ -0,0 +1,99 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Storage = require("./Storage.js"); +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "key"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = conversions["DOMString"](value, { context: context + " has member 'key' that", globals: globalObject }); + } + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "newValue"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = conversions["DOMString"](value, { + context: context + " has member 'newValue' that", + globals: globalObject + }); + } + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "oldValue"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = conversions["DOMString"](value, { + context: context + " has member 'oldValue' that", + globals: globalObject + }); + } + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "storageArea"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = Storage.convert(globalObject, value, { context: context + " has member 'storageArea' that" }); + } + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "url"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["USVString"](value, { context: context + " has member 'url' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/StyleSheetList.js b/node_modules/jsdom/lib/jsdom/living/generated/StyleSheetList.js new file mode 100644 index 0000000000000000000000000000000000000000..89a889a68807eb14043e2d806a7ccd2f8eb2e616 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/StyleSheetList.js @@ -0,0 +1,300 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "StyleSheetList"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'StyleSheetList'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["StyleSheetList"].prototype; + } + + return Object.create(proto); +} + +function makeProxy(wrapper, globalObject) { + let proxyHandler = proxyHandlerCache.get(globalObject); + if (proxyHandler === undefined) { + proxyHandler = new ProxyHandler(globalObject); + proxyHandlerCache.set(globalObject, proxyHandler); + } + return new Proxy(wrapper, proxyHandler); +} + +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); +}; + +exports._internalSetup = (wrapper, 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 = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper; +}; + +exports.new = (globalObject, newTarget) => { + let wrapper = makeWrapper(globalObject, newTarget); + + exports._internalSetup(wrapper, globalObject); + Object.defineProperty(wrapper, implSymbol, { + value: Object.create(Impl.implementation.prototype), + configurable: true + }); + + wrapper = makeProxy(wrapper, globalObject); + + wrapper[implSymbol][utils.wrapperSymbol] = wrapper; + if (Impl.init) { + Impl.init(wrapper[implSymbol]); + } + return wrapper[implSymbol]; +}; + +const exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class StyleSheetList { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + item(index) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'item' called on an object that is not a valid instance of StyleSheetList."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'item' on 'StyleSheetList': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'item' on 'StyleSheetList': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].item(...args)); + } + + get length() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get length' called on an object that is not a valid instance of StyleSheetList." + ); + } + + return esValue[implSymbol]["length"]; + } + } + Object.defineProperties(StyleSheetList.prototype, { + item: { enumerable: true }, + length: { enumerable: true }, + [Symbol.toStringTag]: { value: "StyleSheetList", configurable: true }, + [Symbol.iterator]: { value: globalObject.Array.prototype[Symbol.iterator], configurable: true, writable: true } + }); + ctorRegistry[interfaceName] = StyleSheetList; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: StyleSheetList + }); +}; + +const proxyHandlerCache = new WeakMap(); +class ProxyHandler { + constructor(globalObject) { + this._globalObject = globalObject; + } + + get(target, P, receiver) { + if (typeof P === "symbol") { + return Reflect.get(target, P, receiver); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc === undefined) { + const parent = Object.getPrototypeOf(target); + if (parent === null) { + return undefined; + } + return Reflect.get(target, P, receiver); + } + if (!desc.get && !desc.set) { + return desc.value; + } + const getter = desc.get; + if (getter === undefined) { + return undefined; + } + return Reflect.apply(getter, receiver, []); + } + + has(target, P) { + if (typeof P === "symbol") { + return Reflect.has(target, P); + } + const desc = this.getOwnPropertyDescriptor(target, P); + if (desc !== undefined) { + return true; + } + const parent = Object.getPrototypeOf(target); + if (parent !== null) { + return Reflect.has(parent, P); + } + return false; + } + + ownKeys(target) { + const keys = new Set(); + + for (const key of target[implSymbol][utils.supportedPropertyIndices]) { + keys.add(`${key}`); + } + + for (const key of Reflect.ownKeys(target)) { + keys.add(key); + } + return [...keys]; + } + + getOwnPropertyDescriptor(target, P) { + if (typeof P === "symbol") { + return Reflect.getOwnPropertyDescriptor(target, P); + } + let ignoreNamedProps = false; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + return { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + ignoreNamedProps = true; + } + + return Reflect.getOwnPropertyDescriptor(target, P); + } + + set(target, P, V, receiver) { + if (typeof P === "symbol") { + return Reflect.set(target, P, V, receiver); + } + // The `receiver` argument refers to the Proxy exotic object or an object + // that inherits from it, whereas `target` refers to the Proxy target: + if (target[implSymbol][utils.wrapperSymbol] === receiver) { + const globalObject = this._globalObject; + } + let ownDesc; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + const indexedValue = target[implSymbol].item(index); + if (indexedValue !== null) { + ownDesc = { + writable: false, + enumerable: true, + configurable: true, + value: utils.tryWrapperForImpl(indexedValue) + }; + } + } + + if (ownDesc === undefined) { + ownDesc = Reflect.getOwnPropertyDescriptor(target, P); + } + return utils.ordinarySetWithOwnDescriptor(target, P, V, receiver, ownDesc); + } + + defineProperty(target, P, desc) { + if (typeof P === "symbol") { + return Reflect.defineProperty(target, P, desc); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + return false; + } + + return Reflect.defineProperty(target, P, desc); + } + + deleteProperty(target, P) { + if (typeof P === "symbol") { + return Reflect.deleteProperty(target, P); + } + + const globalObject = this._globalObject; + + if (utils.isArrayIndexPropName(P)) { + const index = P >>> 0; + return !(target[implSymbol].item(index) !== null); + } + + return Reflect.deleteProperty(target, P); + } + + preventExtensions() { + return false; + } +} + +const Impl = require("../cssom/StyleSheetList-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SubmitEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/SubmitEvent.js new file mode 100644 index 0000000000000000000000000000000000000000..94c9aec49b0fc1ec22714e7353970e70e842c511 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SubmitEvent.js @@ -0,0 +1,144 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const SubmitEventInit = require("./SubmitEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "SubmitEvent"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'SubmitEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["SubmitEvent"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class SubmitEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'SubmitEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'SubmitEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = SubmitEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'SubmitEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get submitter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get submitter' called on an object that is not a valid instance of SubmitEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["submitter"]); + } + } + Object.defineProperties(SubmitEvent.prototype, { + submitter: { enumerable: true }, + [Symbol.toStringTag]: { value: "SubmitEvent", configurable: true } + }); + ctorRegistry[interfaceName] = SubmitEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: SubmitEvent + }); +}; + +const Impl = require("../events/SubmitEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SubmitEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/SubmitEventInit.js new file mode 100644 index 0000000000000000000000000000000000000000..a911318c72571a1e4c8e866cb74e997c7744d461 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SubmitEventInit.js @@ -0,0 +1,36 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const HTMLElement = require("./HTMLElement.js"); +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "submitter"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = HTMLElement.convert(globalObject, value, { context: context + " has member 'submitter' that" }); + } + ret[key] = value; + } else { + ret[key] = null; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/SupportedType.js b/node_modules/jsdom/lib/jsdom/living/generated/SupportedType.js new file mode 100644 index 0000000000000000000000000000000000000000..f64ae10dad84ab762422cd7a3e15cfc113d49fb1 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/SupportedType.js @@ -0,0 +1,18 @@ +"use strict"; + +const enumerationValues = new Set([ + "text/html", + "text/xml", + "application/xml", + "application/xhtml+xml", + "image/svg+xml" +]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for SupportedType`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/Text.js b/node_modules/jsdom/lib/jsdom/living/generated/Text.js new file mode 100644 index 0000000000000000000000000000000000000000..0ab77e02f147d9d996e49d77111796d80a3b457a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/Text.js @@ -0,0 +1,170 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const CharacterData = require("./CharacterData.js"); + +const interfaceName = "Text"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'Text'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["Text"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + CharacterData._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class Text extends globalObject.CharacterData { + constructor() { + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'Text': parameter 1", + globals: globalObject + }); + } else { + curArg = ""; + } + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + splitText(offset) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'splitText' called on an object that is not a valid instance of Text."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'splitText' on 'Text': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["unsigned long"](curArg, { + context: "Failed to execute 'splitText' on 'Text': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return utils.tryWrapperForImpl(esValue[implSymbol].splitText(...args)); + } + + get wholeText() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get wholeText' called on an object that is not a valid instance of Text."); + } + + return esValue[implSymbol]["wholeText"]; + } + + get assignedSlot() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get assignedSlot' called on an object that is not a valid instance of Text." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["assignedSlot"]); + } + } + Object.defineProperties(Text.prototype, { + splitText: { enumerable: true }, + wholeText: { enumerable: true }, + assignedSlot: { enumerable: true }, + [Symbol.toStringTag]: { value: "Text", configurable: true } + }); + ctorRegistry[interfaceName] = Text; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: Text + }); +}; + +const Impl = require("../nodes/Text-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/TextTrackKind.js b/node_modules/jsdom/lib/jsdom/living/generated/TextTrackKind.js new file mode 100644 index 0000000000000000000000000000000000000000..5ad709a71b547280cc2572d8be18cfe488acb11b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/TextTrackKind.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["subtitles", "captions", "descriptions", "chapters", "metadata"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for TextTrackKind`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/TouchEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/TouchEvent.js new file mode 100644 index 0000000000000000000000000000000000000000..5ef8cc7fdca0a2087ca3507295f0035bf4f81869 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/TouchEvent.js @@ -0,0 +1,222 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const TouchEventInit = require("./TouchEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const UIEvent = require("./UIEvent.js"); + +const interfaceName = "TouchEvent"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'TouchEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["TouchEvent"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + UIEvent._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class TouchEvent extends globalObject.UIEvent { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'TouchEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'TouchEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = TouchEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'TouchEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get touches() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get touches' called on an object that is not a valid instance of TouchEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["touches"]); + } + + get targetTouches() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get targetTouches' called on an object that is not a valid instance of TouchEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["targetTouches"]); + } + + get changedTouches() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get changedTouches' called on an object that is not a valid instance of TouchEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["changedTouches"]); + } + + get altKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get altKey' called on an object that is not a valid instance of TouchEvent." + ); + } + + return esValue[implSymbol]["altKey"]; + } + + get metaKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get metaKey' called on an object that is not a valid instance of TouchEvent." + ); + } + + return esValue[implSymbol]["metaKey"]; + } + + get ctrlKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ctrlKey' called on an object that is not a valid instance of TouchEvent." + ); + } + + return esValue[implSymbol]["ctrlKey"]; + } + + get shiftKey() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get shiftKey' called on an object that is not a valid instance of TouchEvent." + ); + } + + return esValue[implSymbol]["shiftKey"]; + } + } + Object.defineProperties(TouchEvent.prototype, { + touches: { enumerable: true }, + targetTouches: { enumerable: true }, + changedTouches: { enumerable: true }, + altKey: { enumerable: true }, + metaKey: { enumerable: true }, + ctrlKey: { enumerable: true }, + shiftKey: { enumerable: true }, + [Symbol.toStringTag]: { value: "TouchEvent", configurable: true } + }); + ctorRegistry[interfaceName] = TouchEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: TouchEvent + }); +}; + +const Impl = require("../events/TouchEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/TouchEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/TouchEventInit.js new file mode 100644 index 0000000000000000000000000000000000000000..7a47277693170d9b41daaa9b58527feeee794a2a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/TouchEventInit.js @@ -0,0 +1,89 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventModifierInit = require("./EventModifierInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventModifierInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "changedTouches"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (!utils.isObject(value)) { + throw new globalObject.TypeError(context + " has member 'changedTouches' that" + " is not an iterable object."); + } else { + const V = []; + const tmp = value; + for (let nextItem of tmp) { + nextItem = utils.tryImplForWrapper(nextItem); + + V.push(nextItem); + } + value = V; + } + + ret[key] = value; + } else { + ret[key] = []; + } + } + + { + const key = "targetTouches"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (!utils.isObject(value)) { + throw new globalObject.TypeError(context + " has member 'targetTouches' that" + " is not an iterable object."); + } else { + const V = []; + const tmp = value; + for (let nextItem of tmp) { + nextItem = utils.tryImplForWrapper(nextItem); + + V.push(nextItem); + } + value = V; + } + + ret[key] = value; + } else { + ret[key] = []; + } + } + + { + const key = "touches"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (!utils.isObject(value)) { + throw new globalObject.TypeError(context + " has member 'touches' that" + " is not an iterable object."); + } else { + const V = []; + const tmp = value; + for (let nextItem of tmp) { + nextItem = utils.tryImplForWrapper(nextItem); + + V.push(nextItem); + } + value = V; + } + + ret[key] = value; + } else { + ret[key] = []; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/TransitionEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/TransitionEvent.js new file mode 100644 index 0000000000000000000000000000000000000000..b0f718198f3958e2b1524d71982c1ee07db9c725 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/TransitionEvent.js @@ -0,0 +1,170 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const TransitionEventInit = require("./TransitionEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "TransitionEvent"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'TransitionEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["TransitionEvent"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class TransitionEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'TransitionEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'TransitionEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = TransitionEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'TransitionEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get propertyName() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get propertyName' called on an object that is not a valid instance of TransitionEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["propertyName"]); + } + + get elapsedTime() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get elapsedTime' called on an object that is not a valid instance of TransitionEvent." + ); + } + + return esValue[implSymbol]["elapsedTime"]; + } + + get pseudoElement() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get pseudoElement' called on an object that is not a valid instance of TransitionEvent." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["pseudoElement"]); + } + } + Object.defineProperties(TransitionEvent.prototype, { + propertyName: { enumerable: true }, + elapsedTime: { enumerable: true }, + pseudoElement: { enumerable: true }, + [Symbol.toStringTag]: { value: "TransitionEvent", configurable: true } + }); + ctorRegistry[interfaceName] = TransitionEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: TransitionEvent + }); +}; + +const Impl = require("../events/TransitionEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/TransitionEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/TransitionEventInit.js new file mode 100644 index 0000000000000000000000000000000000000000..0eb30f4d793ccac199dbf57249fc8e6d77a4a5e8 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/TransitionEventInit.js @@ -0,0 +1,65 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "elapsedTime"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["double"](value, { + context: context + " has member 'elapsedTime' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0.0; + } + } + + { + const key = "propertyName"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["DOMString"](value, { + context: context + " has member 'propertyName' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } + + { + const key = "pseudoElement"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["DOMString"](value, { + context: context + " has member 'pseudoElement' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = ""; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/TreeWalker.js b/node_modules/jsdom/lib/jsdom/living/generated/TreeWalker.js new file mode 100644 index 0000000000000000000000000000000000000000..41683b26dfe4e3ce1158e23eb95b19bc58310dd0 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/TreeWalker.js @@ -0,0 +1,255 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Node = require("./Node.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "TreeWalker"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'TreeWalker'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["TreeWalker"].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); +}; + +exports._internalSetup = (wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class TreeWalker { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + parentNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'parentNode' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].parentNode()); + } + + firstChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'firstChild' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].firstChild()); + } + + lastChild() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'lastChild' called on an object that is not a valid instance of TreeWalker."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].lastChild()); + } + + previousSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'previousSibling' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].previousSibling()); + } + + nextSibling() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'nextSibling' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].nextSibling()); + } + + previousNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'previousNode' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].previousNode()); + } + + nextNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'nextNode' called on an object that is not a valid instance of TreeWalker."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol].nextNode()); + } + + get root() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get root' called on an object that is not a valid instance of TreeWalker."); + } + + return utils.getSameObject(this, "root", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["root"]); + }); + } + + get whatToShow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get whatToShow' called on an object that is not a valid instance of TreeWalker." + ); + } + + return esValue[implSymbol]["whatToShow"]; + } + + get filter() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get filter' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["filter"]); + } + + get currentNode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get currentNode' called on an object that is not a valid instance of TreeWalker." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["currentNode"]); + } + + set currentNode(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set currentNode' called on an object that is not a valid instance of TreeWalker." + ); + } + + V = Node.convert(globalObject, V, { + context: "Failed to set the 'currentNode' property on 'TreeWalker': The provided value" + }); + + esValue[implSymbol]["currentNode"] = V; + } + } + Object.defineProperties(TreeWalker.prototype, { + parentNode: { enumerable: true }, + firstChild: { enumerable: true }, + lastChild: { enumerable: true }, + previousSibling: { enumerable: true }, + nextSibling: { enumerable: true }, + previousNode: { enumerable: true }, + nextNode: { enumerable: true }, + root: { enumerable: true }, + whatToShow: { enumerable: true }, + filter: { enumerable: true }, + currentNode: { enumerable: true }, + [Symbol.toStringTag]: { value: "TreeWalker", configurable: true } + }); + ctorRegistry[interfaceName] = TreeWalker; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: TreeWalker + }); +}; + +const Impl = require("../traversal/TreeWalker-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/UIEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/UIEvent.js new file mode 100644 index 0000000000000000000000000000000000000000..487e5e2e2ad8c68b2b241b25b447e0bc89fd1888 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/UIEvent.js @@ -0,0 +1,235 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const UIEventInit = require("./UIEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Event = require("./Event.js"); + +const interfaceName = "UIEvent"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'UIEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["UIEvent"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Event._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class UIEvent extends globalObject.Event { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'UIEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'UIEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = UIEventInit.convert(globalObject, curArg, { context: "Failed to construct 'UIEvent': parameter 2" }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + initUIEvent(typeArg) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'initUIEvent' called on an object that is not a valid instance of UIEvent."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'initUIEvent' on 'UIEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'initUIEvent' on 'UIEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initUIEvent' on 'UIEvent': parameter 2", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[2]; + if (curArg !== undefined) { + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'initUIEvent' on 'UIEvent': parameter 3", + globals: globalObject + }); + } else { + curArg = false; + } + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = utils.tryImplForWrapper(curArg); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[4]; + if (curArg !== undefined) { + curArg = conversions["long"](curArg, { + context: "Failed to execute 'initUIEvent' on 'UIEvent': parameter 5", + globals: globalObject + }); + } else { + curArg = 0; + } + args.push(curArg); + } + return esValue[implSymbol].initUIEvent(...args); + } + + get view() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get view' called on an object that is not a valid instance of UIEvent."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["view"]); + } + + get detail() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get detail' called on an object that is not a valid instance of UIEvent."); + } + + return esValue[implSymbol]["detail"]; + } + + get which() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get which' called on an object that is not a valid instance of UIEvent."); + } + + return esValue[implSymbol]["which"]; + } + } + Object.defineProperties(UIEvent.prototype, { + initUIEvent: { enumerable: true }, + view: { enumerable: true }, + detail: { enumerable: true }, + which: { enumerable: true }, + [Symbol.toStringTag]: { value: "UIEvent", configurable: true } + }); + ctorRegistry[interfaceName] = UIEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: UIEvent + }); +}; + +const Impl = require("../events/UIEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/UIEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/UIEventInit.js new file mode 100644 index 0000000000000000000000000000000000000000..3051b230a3207e7d78d12fc434d00eb6ffec8587 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/UIEventInit.js @@ -0,0 +1,62 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventInit = require("./EventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + EventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "detail"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["long"](value, { context: context + " has member 'detail' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "view"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + if (value === null || value === undefined) { + value = null; + } else { + value = utils.tryImplForWrapper(value); + } + ret[key] = value; + } else { + ret[key] = null; + } + } + + { + const key = "which"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long"](value, { + context: context + " has member 'which' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/ValidityState.js b/node_modules/jsdom/lib/jsdom/living/generated/ValidityState.js new file mode 100644 index 0000000000000000000000000000000000000000..9491d7caa8df7e6b5ad3fd018d9d75a7cd387992 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/ValidityState.js @@ -0,0 +1,249 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "ValidityState"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'ValidityState'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["ValidityState"].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); +}; + +exports._internalSetup = (wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class ValidityState { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get valueMissing() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get valueMissing' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["valueMissing"]; + } + + get typeMismatch() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get typeMismatch' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["typeMismatch"]; + } + + get patternMismatch() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get patternMismatch' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["patternMismatch"]; + } + + get tooLong() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get tooLong' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["tooLong"]; + } + + get tooShort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get tooShort' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["tooShort"]; + } + + get rangeUnderflow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rangeUnderflow' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["rangeUnderflow"]; + } + + get rangeOverflow() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get rangeOverflow' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["rangeOverflow"]; + } + + get stepMismatch() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get stepMismatch' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["stepMismatch"]; + } + + get badInput() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get badInput' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["badInput"]; + } + + get customError() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get customError' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["customError"]; + } + + get valid() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get valid' called on an object that is not a valid instance of ValidityState." + ); + } + + return esValue[implSymbol]["valid"]; + } + } + Object.defineProperties(ValidityState.prototype, { + valueMissing: { enumerable: true }, + typeMismatch: { enumerable: true }, + patternMismatch: { enumerable: true }, + tooLong: { enumerable: true }, + tooShort: { enumerable: true }, + rangeUnderflow: { enumerable: true }, + rangeOverflow: { enumerable: true }, + stepMismatch: { enumerable: true }, + badInput: { enumerable: true }, + customError: { enumerable: true }, + valid: { enumerable: true }, + [Symbol.toStringTag]: { value: "ValidityState", configurable: true } + }); + ctorRegistry[interfaceName] = ValidityState; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: ValidityState + }); +}; + +const Impl = require("../constraint-validation/ValidityState-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/VisibilityState.js b/node_modules/jsdom/lib/jsdom/living/generated/VisibilityState.js new file mode 100644 index 0000000000000000000000000000000000000000..798eb094537a7d1724f4f42f24a6323ba0e31d39 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/VisibilityState.js @@ -0,0 +1,12 @@ +"use strict"; + +const enumerationValues = new Set(["hidden", "visible", "prerender"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError(`${context} '${string}' is not a valid enumeration value for VisibilityState`); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/VoidFunction.js b/node_modules/jsdom/lib/jsdom/living/generated/VoidFunction.js new file mode 100644 index 0000000000000000000000000000000000000000..9a00672a7eefb56865c9ec5872c3d331bc8cd845 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/VoidFunction.js @@ -0,0 +1,26 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + if (typeof value !== "function") { + throw new globalObject.TypeError(context + " is not a function"); + } + + function invokeTheCallbackFunction() { + const thisArg = utils.tryWrapperForImpl(this); + let callResult; + + callResult = Reflect.apply(value, thisArg, []); + } + + invokeTheCallbackFunction.construct = () => { + let callResult = Reflect.construct(value, []); + }; + + invokeTheCallbackFunction[utils.wrapperSymbol] = value; + invokeTheCallbackFunction.objectReference = value; + + return invokeTheCallbackFunction; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/WebSocket.js b/node_modules/jsdom/lib/jsdom/living/generated/WebSocket.js new file mode 100644 index 0000000000000000000000000000000000000000..faa6d77d0847794f42fad541a2ccec2e4eeb2abc --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/WebSocket.js @@ -0,0 +1,480 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Blob = require("./Blob.js"); +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const BinaryType = require("./BinaryType.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const EventTarget = require("./EventTarget.js"); + +const interfaceName = "WebSocket"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'WebSocket'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["WebSocket"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + EventTarget._internalSetup(wrapper, 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 exposed = new Set(["Window", "Worker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class WebSocket extends globalObject.EventTarget { + constructor(url) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'WebSocket': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to construct 'WebSocket': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + if (utils.isObject(curArg)) { + if (curArg[Symbol.iterator] !== undefined) { + if (!utils.isObject(curArg)) { + throw new globalObject.TypeError( + "Failed to construct 'WebSocket': parameter 2" + " sequence" + " is not an iterable object." + ); + } else { + const V = []; + const tmp = curArg; + for (let nextItem of tmp) { + nextItem = conversions["DOMString"](nextItem, { + context: "Failed to construct 'WebSocket': parameter 2" + " sequence" + "'s element", + globals: globalObject + }); + + V.push(nextItem); + } + curArg = V; + } + } else { + } + } else { + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'WebSocket': parameter 2", + globals: globalObject + }); + } + } else { + curArg = []; + } + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + 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 WebSocket."); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + curArg = conversions["unsigned short"](curArg, { + context: "Failed to execute 'close' on 'WebSocket': parameter 1", + globals: globalObject, + clamp: true + }); + } + args.push(curArg); + } + { + let curArg = arguments[1]; + if (curArg !== undefined) { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'close' on 'WebSocket': parameter 2", + globals: globalObject + }); + } + args.push(curArg); + } + return esValue[implSymbol].close(...args); + } + + send(data) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'send' called on an object that is not a valid instance of WebSocket."); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'send' on 'WebSocket': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + if (Blob.is(curArg)) { + { + let curArg = arguments[0]; + curArg = Blob.convert(globalObject, curArg, { + context: "Failed to execute 'send' on 'WebSocket': parameter 1" + }); + args.push(curArg); + } + } else if (utils.isArrayBuffer(curArg)) { + { + let curArg = arguments[0]; + curArg = conversions["ArrayBuffer"](curArg, { + context: "Failed to execute 'send' on 'WebSocket': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + } else if (ArrayBuffer.isView(curArg)) { + { + let curArg = arguments[0]; + if (ArrayBuffer.isView(curArg)) { + curArg = conversions["ArrayBufferView"](curArg, { + context: "Failed to execute 'send' on 'WebSocket': parameter 1", + globals: globalObject + }); + } else { + throw new globalObject.TypeError( + "Failed to execute 'send' on 'WebSocket': parameter 1" + " is not of any supported type." + ); + } + args.push(curArg); + } + } else { + { + let curArg = arguments[0]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'send' on 'WebSocket': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + } + } + return esValue[implSymbol].send(...args); + } + + 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 WebSocket."); + } + + return esValue[implSymbol]["url"]; + } + + 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 WebSocket." + ); + } + + return esValue[implSymbol]["readyState"]; + } + + get bufferedAmount() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get bufferedAmount' called on an object that is not a valid instance of WebSocket." + ); + } + + return esValue[implSymbol]["bufferedAmount"]; + } + + get onopen() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'get onopen' called on an object that is not a valid instance of WebSocket."); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onopen"]); + } + + set onopen(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'set onopen' called on an object that is not a valid instance of WebSocket."); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onopen' property on 'WebSocket': The provided value" + }); + } + esValue[implSymbol]["onopen"] = V; + } + + get onerror() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onerror' called on an object that is not a valid instance of WebSocket." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onerror"]); + } + + set onerror(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onerror' called on an object that is not a valid instance of WebSocket." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onerror' property on 'WebSocket': The provided value" + }); + } + esValue[implSymbol]["onerror"] = V; + } + + get onclose() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onclose' called on an object that is not a valid instance of WebSocket." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onclose"]); + } + + set onclose(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onclose' called on an object that is not a valid instance of WebSocket." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onclose' property on 'WebSocket': The provided value" + }); + } + esValue[implSymbol]["onclose"] = V; + } + + get extensions() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get extensions' called on an object that is not a valid instance of WebSocket." + ); + } + + return esValue[implSymbol]["extensions"]; + } + + get protocol() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get protocol' called on an object that is not a valid instance of WebSocket." + ); + } + + return esValue[implSymbol]["protocol"]; + } + + get onmessage() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onmessage' called on an object that is not a valid instance of WebSocket." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onmessage"]); + } + + set onmessage(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onmessage' called on an object that is not a valid instance of WebSocket." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onmessage' property on 'WebSocket': The provided value" + }); + } + esValue[implSymbol]["onmessage"] = V; + } + + get binaryType() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get binaryType' called on an object that is not a valid instance of WebSocket." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["binaryType"]); + } + + set binaryType(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set binaryType' called on an object that is not a valid instance of WebSocket." + ); + } + + V = `${V}`; + if (!BinaryType.enumerationValues.has(V)) { + return; + } + + esValue[implSymbol]["binaryType"] = V; + } + } + Object.defineProperties(WebSocket.prototype, { + close: { enumerable: true }, + send: { enumerable: true }, + url: { enumerable: true }, + readyState: { enumerable: true }, + bufferedAmount: { enumerable: true }, + onopen: { enumerable: true }, + onerror: { enumerable: true }, + onclose: { enumerable: true }, + extensions: { enumerable: true }, + protocol: { enumerable: true }, + onmessage: { enumerable: true }, + binaryType: { enumerable: true }, + [Symbol.toStringTag]: { value: "WebSocket", configurable: true }, + CONNECTING: { value: 0, enumerable: true }, + OPEN: { value: 1, enumerable: true }, + CLOSING: { value: 2, enumerable: true }, + CLOSED: { value: 3, enumerable: true } + }); + Object.defineProperties(WebSocket, { + CONNECTING: { value: 0, enumerable: true }, + OPEN: { value: 1, enumerable: true }, + CLOSING: { value: 2, enumerable: true }, + CLOSED: { value: 3, enumerable: true } + }); + ctorRegistry[interfaceName] = WebSocket; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: WebSocket + }); +}; + +const Impl = require("../websockets/WebSocket-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/WheelEvent.js b/node_modules/jsdom/lib/jsdom/living/generated/WheelEvent.js new file mode 100644 index 0000000000000000000000000000000000000000..8ab0e976fc105fe81cedde7b39e88220353bb09a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/WheelEvent.js @@ -0,0 +1,191 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const WheelEventInit = require("./WheelEventInit.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const MouseEvent = require("./MouseEvent.js"); + +const interfaceName = "WheelEvent"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'WheelEvent'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["WheelEvent"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + MouseEvent._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class WheelEvent extends globalObject.MouseEvent { + constructor(type) { + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to construct 'WheelEvent': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to construct 'WheelEvent': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = WheelEventInit.convert(globalObject, curArg, { + context: "Failed to construct 'WheelEvent': parameter 2" + }); + args.push(curArg); + } + return exports.setup(Object.create(new.target.prototype), globalObject, args); + } + + get deltaX() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get deltaX' called on an object that is not a valid instance of WheelEvent." + ); + } + + return esValue[implSymbol]["deltaX"]; + } + + get deltaY() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get deltaY' called on an object that is not a valid instance of WheelEvent." + ); + } + + return esValue[implSymbol]["deltaY"]; + } + + get deltaZ() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get deltaZ' called on an object that is not a valid instance of WheelEvent." + ); + } + + return esValue[implSymbol]["deltaZ"]; + } + + get deltaMode() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get deltaMode' called on an object that is not a valid instance of WheelEvent." + ); + } + + return esValue[implSymbol]["deltaMode"]; + } + } + Object.defineProperties(WheelEvent.prototype, { + deltaX: { enumerable: true }, + deltaY: { enumerable: true }, + deltaZ: { enumerable: true }, + deltaMode: { enumerable: true }, + [Symbol.toStringTag]: { value: "WheelEvent", configurable: true }, + DOM_DELTA_PIXEL: { value: 0x00, enumerable: true }, + DOM_DELTA_LINE: { value: 0x01, enumerable: true }, + DOM_DELTA_PAGE: { value: 0x02, enumerable: true } + }); + Object.defineProperties(WheelEvent, { + DOM_DELTA_PIXEL: { value: 0x00, enumerable: true }, + DOM_DELTA_LINE: { value: 0x01, enumerable: true }, + DOM_DELTA_PAGE: { value: 0x02, enumerable: true } + }); + ctorRegistry[interfaceName] = WheelEvent; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: WheelEvent + }); +}; + +const Impl = require("../events/WheelEvent-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/WheelEventInit.js b/node_modules/jsdom/lib/jsdom/living/generated/WheelEventInit.js new file mode 100644 index 0000000000000000000000000000000000000000..757f81c3b93a618ec74f8576fb01c074a89b681e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/WheelEventInit.js @@ -0,0 +1,71 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const MouseEventInit = require("./MouseEventInit.js"); + +exports._convertInherit = (globalObject, obj, ret, { context = "The provided value" } = {}) => { + MouseEventInit._convertInherit(globalObject, obj, ret, { context }); + + { + const key = "deltaMode"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["unsigned long"](value, { + context: context + " has member 'deltaMode' that", + globals: globalObject + }); + + ret[key] = value; + } else { + ret[key] = 0; + } + } + + { + const key = "deltaX"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["double"](value, { context: context + " has member 'deltaX' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0.0; + } + } + + { + const key = "deltaY"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["double"](value, { context: context + " has member 'deltaY' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0.0; + } + } + + { + const key = "deltaZ"; + let value = obj === undefined || obj === null ? undefined : obj[key]; + if (value !== undefined) { + value = conversions["double"](value, { context: context + " has member 'deltaZ' that", globals: globalObject }); + + ret[key] = value; + } else { + ret[key] = 0.0; + } + } +}; + +exports.convert = (globalObject, obj, { context = "The provided value" } = {}) => { + if (obj !== undefined && typeof obj !== "object" && typeof obj !== "function") { + throw new globalObject.TypeError(`${context} is not an object.`); + } + + const ret = Object.create(null); + exports._convertInherit(globalObject, obj, ret, { context }); + return ret; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/XMLDocument.js b/node_modules/jsdom/lib/jsdom/living/generated/XMLDocument.js new file mode 100644 index 0000000000000000000000000000000000000000..d493a5e5c19d098b496e903c6e63823699d58dd9 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/XMLDocument.js @@ -0,0 +1,109 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const Document = require("./Document.js"); + +const interfaceName = "XMLDocument"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'XMLDocument'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["XMLDocument"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + Document._internalSetup(wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class XMLDocument extends globalObject.Document { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(XMLDocument.prototype, { + [Symbol.toStringTag]: { value: "XMLDocument", configurable: true } + }); + ctorRegistry[interfaceName] = XMLDocument; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: XMLDocument + }); +}; + +const Impl = require("../nodes/XMLDocument-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequest.js b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequest.js new file mode 100644 index 0000000000000000000000000000000000000000..83b86fd3538c53c8610a3173c17492cf19728a13 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequest.js @@ -0,0 +1,663 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Document = require("./Document.js"); +const Blob = require("./Blob.js"); +const FormData = require("./FormData.js"); +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const XMLHttpRequestResponseType = require("./XMLHttpRequestResponseType.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const XMLHttpRequestEventTarget = require("./XMLHttpRequestEventTarget.js"); + +const interfaceName = "XMLHttpRequest"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'XMLHttpRequest'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["XMLHttpRequest"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + XMLHttpRequestEventTarget._internalSetup(wrapper, 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 exposed = new Set(["Window", "DedicatedWorker", "SharedWorker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class XMLHttpRequest extends globalObject.XMLHttpRequestEventTarget { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + open(method, url) { + 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 XMLHttpRequest."); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'open' on 'XMLHttpRequest': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + switch (arguments.length) { + case 2: + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + break; + case 3: + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 3", + globals: globalObject + }); + args.push(curArg); + } + break; + case 4: + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 3", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 4", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + break; + default: + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[2]; + curArg = conversions["boolean"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 3", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[3]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 4", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + { + let curArg = arguments[4]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'open' on 'XMLHttpRequest': parameter 5", + globals: globalObject + }); + } + } else { + curArg = null; + } + args.push(curArg); + } + } + return esValue[implSymbol].open(...args); + } + + setRequestHeader(name, value) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'setRequestHeader' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + if (arguments.length < 2) { + throw new globalObject.TypeError( + `Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 2 arguments required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'setRequestHeader' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + { + let curArg = arguments[1]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'setRequestHeader' on 'XMLHttpRequest': parameter 2", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].setRequestHeader(...args); + } + + send() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'send' called on an object that is not a valid instance of XMLHttpRequest."); + } + const args = []; + { + let curArg = arguments[0]; + if (curArg !== undefined) { + if (curArg === null || curArg === undefined) { + curArg = null; + } else { + if (Document.is(curArg) || Blob.is(curArg) || FormData.is(curArg)) { + curArg = utils.implForWrapper(curArg); + } else if (utils.isArrayBuffer(curArg)) { + curArg = conversions["ArrayBuffer"](curArg, { + context: "Failed to execute 'send' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + } else if (ArrayBuffer.isView(curArg)) { + curArg = conversions["ArrayBufferView"](curArg, { + context: "Failed to execute 'send' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + } else { + curArg = conversions["USVString"](curArg, { + context: "Failed to execute 'send' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + } + } + } else { + curArg = null; + } + args.push(curArg); + } + return esValue[implSymbol].send(...args); + } + + abort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError("'abort' called on an object that is not a valid instance of XMLHttpRequest."); + } + + return esValue[implSymbol].abort(); + } + + getResponseHeader(name) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getResponseHeader' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'getResponseHeader' on 'XMLHttpRequest': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["ByteString"](curArg, { + context: "Failed to execute 'getResponseHeader' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].getResponseHeader(...args); + } + + getAllResponseHeaders() { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'getAllResponseHeaders' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol].getAllResponseHeaders(); + } + + overrideMimeType(mime) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'overrideMimeType' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'overrideMimeType' on 'XMLHttpRequest': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = conversions["DOMString"](curArg, { + context: "Failed to execute 'overrideMimeType' on 'XMLHttpRequest': parameter 1", + globals: globalObject + }); + args.push(curArg); + } + return esValue[implSymbol].overrideMimeType(...args); + } + + get onreadystatechange() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onreadystatechange' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onreadystatechange"]); + } + + set onreadystatechange(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onreadystatechange' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onreadystatechange' property on 'XMLHttpRequest': The provided value" + }); + } + esValue[implSymbol]["onreadystatechange"] = V; + } + + 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 XMLHttpRequest." + ); + } + + return esValue[implSymbol]["readyState"]; + } + + get timeout() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get timeout' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["timeout"]; + } + + set timeout(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set timeout' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + V = conversions["unsigned long"](V, { + context: "Failed to set the 'timeout' property on 'XMLHttpRequest': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["timeout"] = V; + } + + get withCredentials() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get withCredentials' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["withCredentials"]; + } + + set withCredentials(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set withCredentials' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + V = conversions["boolean"](V, { + context: "Failed to set the 'withCredentials' property on 'XMLHttpRequest': The provided value", + globals: globalObject + }); + + esValue[implSymbol]["withCredentials"] = V; + } + + get upload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get upload' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return utils.getSameObject(this, "upload", () => { + return utils.tryWrapperForImpl(esValue[implSymbol]["upload"]); + }); + } + + get responseURL() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get responseURL' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["responseURL"]; + } + + get status() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get status' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["status"]; + } + + get statusText() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get statusText' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["statusText"]; + } + + get responseType() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get responseType' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["responseType"]); + } + + set responseType(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set responseType' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + V = `${V}`; + if (!XMLHttpRequestResponseType.enumerationValues.has(V)) { + return; + } + + esValue[implSymbol]["responseType"] = V; + } + + get response() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get response' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["response"]; + } + + get responseText() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get responseText' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return esValue[implSymbol]["responseText"]; + } + + get responseXML() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get responseXML' called on an object that is not a valid instance of XMLHttpRequest." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["responseXML"]); + } + } + Object.defineProperties(XMLHttpRequest.prototype, { + open: { enumerable: true }, + setRequestHeader: { enumerable: true }, + send: { enumerable: true }, + abort: { enumerable: true }, + getResponseHeader: { enumerable: true }, + getAllResponseHeaders: { enumerable: true }, + overrideMimeType: { enumerable: true }, + onreadystatechange: { enumerable: true }, + readyState: { enumerable: true }, + timeout: { enumerable: true }, + withCredentials: { enumerable: true }, + upload: { enumerable: true }, + responseURL: { enumerable: true }, + status: { enumerable: true }, + statusText: { enumerable: true }, + responseType: { enumerable: true }, + response: { enumerable: true }, + responseText: { enumerable: true }, + responseXML: { enumerable: true }, + [Symbol.toStringTag]: { value: "XMLHttpRequest", configurable: true }, + UNSENT: { value: 0, enumerable: true }, + OPENED: { value: 1, enumerable: true }, + HEADERS_RECEIVED: { value: 2, enumerable: true }, + LOADING: { value: 3, enumerable: true }, + DONE: { value: 4, enumerable: true } + }); + Object.defineProperties(XMLHttpRequest, { + UNSENT: { value: 0, enumerable: true }, + OPENED: { value: 1, enumerable: true }, + HEADERS_RECEIVED: { value: 2, enumerable: true }, + LOADING: { value: 3, enumerable: true }, + DONE: { value: 4, enumerable: true } + }); + ctorRegistry[interfaceName] = XMLHttpRequest; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: XMLHttpRequest + }); +}; + +const Impl = require("../xhr/XMLHttpRequest-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestEventTarget.js b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestEventTarget.js new file mode 100644 index 0000000000000000000000000000000000000000..94d7666457e50513da258e98e07413863da58598 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestEventTarget.js @@ -0,0 +1,334 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const EventHandlerNonNull = require("./EventHandlerNonNull.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const EventTarget = require("./EventTarget.js"); + +const interfaceName = "XMLHttpRequestEventTarget"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'XMLHttpRequestEventTarget'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["XMLHttpRequestEventTarget"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + EventTarget._internalSetup(wrapper, 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 exposed = new Set(["Window", "DedicatedWorker", "SharedWorker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class XMLHttpRequestEventTarget extends globalObject.EventTarget { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + + get onloadstart() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadstart' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadstart"]); + } + + set onloadstart(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadstart' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadstart' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["onloadstart"] = V; + } + + get onprogress() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onprogress' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onprogress"]); + } + + set onprogress(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onprogress' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onprogress' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["onprogress"] = V; + } + + get onabort() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onabort' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onabort"]); + } + + set onabort(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onabort' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onabort' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["onabort"] = V; + } + + get onerror() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onerror' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onerror"]); + } + + set onerror(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onerror' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onerror' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["onerror"] = V; + } + + get onload() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onload' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onload"]); + } + + set onload(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onload' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onload' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["onload"] = V; + } + + get ontimeout() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get ontimeout' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["ontimeout"]); + } + + set ontimeout(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set ontimeout' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'ontimeout' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["ontimeout"] = V; + } + + get onloadend() { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'get onloadend' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + return utils.tryWrapperForImpl(esValue[implSymbol]["onloadend"]); + } + + set onloadend(V) { + const esValue = this !== null && this !== undefined ? this : globalObject; + + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'set onloadend' called on an object that is not a valid instance of XMLHttpRequestEventTarget." + ); + } + + if (!utils.isObject(V)) { + V = null; + } else { + V = EventHandlerNonNull.convert(globalObject, V, { + context: "Failed to set the 'onloadend' property on 'XMLHttpRequestEventTarget': The provided value" + }); + } + esValue[implSymbol]["onloadend"] = V; + } + } + Object.defineProperties(XMLHttpRequestEventTarget.prototype, { + onloadstart: { enumerable: true }, + onprogress: { enumerable: true }, + onabort: { enumerable: true }, + onerror: { enumerable: true }, + onload: { enumerable: true }, + ontimeout: { enumerable: true }, + onloadend: { enumerable: true }, + [Symbol.toStringTag]: { value: "XMLHttpRequestEventTarget", configurable: true } + }); + ctorRegistry[interfaceName] = XMLHttpRequestEventTarget; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: XMLHttpRequestEventTarget + }); +}; + +const Impl = require("../xhr/XMLHttpRequestEventTarget-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestResponseType.js b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestResponseType.js new file mode 100644 index 0000000000000000000000000000000000000000..96a958fa72c346ef98e436a55862c1098ef79a38 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestResponseType.js @@ -0,0 +1,14 @@ +"use strict"; + +const enumerationValues = new Set(["", "arraybuffer", "blob", "document", "json", "text"]); +exports.enumerationValues = enumerationValues; + +exports.convert = (globalObject, value, { context = "The provided value" } = {}) => { + const string = `${value}`; + if (!enumerationValues.has(string)) { + throw new globalObject.TypeError( + `${context} '${string}' is not a valid enumeration value for XMLHttpRequestResponseType` + ); + } + return string; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestUpload.js b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestUpload.js new file mode 100644 index 0000000000000000000000000000000000000000..148e8a24072891f6e6bb9ce15dab6ef4e8e28a16 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/XMLHttpRequestUpload.js @@ -0,0 +1,109 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; +const XMLHttpRequestEventTarget = require("./XMLHttpRequestEventTarget.js"); + +const interfaceName = "XMLHttpRequestUpload"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'XMLHttpRequestUpload'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["XMLHttpRequestUpload"].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); +}; + +exports._internalSetup = (wrapper, globalObject) => { + XMLHttpRequestEventTarget._internalSetup(wrapper, 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 exposed = new Set(["Window", "DedicatedWorker", "SharedWorker"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class XMLHttpRequestUpload extends globalObject.XMLHttpRequestEventTarget { + constructor() { + throw new globalObject.TypeError("Illegal constructor"); + } + } + Object.defineProperties(XMLHttpRequestUpload.prototype, { + [Symbol.toStringTag]: { value: "XMLHttpRequestUpload", configurable: true } + }); + ctorRegistry[interfaceName] = XMLHttpRequestUpload; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: XMLHttpRequestUpload + }); +}; + +const Impl = require("../xhr/XMLHttpRequestUpload-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/XMLSerializer.js b/node_modules/jsdom/lib/jsdom/living/generated/XMLSerializer.js new file mode 100644 index 0000000000000000000000000000000000000000..be23a186044549caec5af9d2c849d721d98b453f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/XMLSerializer.js @@ -0,0 +1,132 @@ +"use strict"; + +const conversions = require("webidl-conversions"); +const utils = require("./utils.js"); + +const Node = require("./Node.js"); +const implSymbol = utils.implSymbol; +const ctorRegistrySymbol = utils.ctorRegistrySymbol; + +const interfaceName = "XMLSerializer"; + +exports.is = value => { + return utils.isObject(value) && Object.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 'XMLSerializer'.`); +}; + +function makeWrapper(globalObject, newTarget) { + let proto; + if (newTarget !== undefined) { + proto = newTarget.prototype; + } + + if (!utils.isObject(proto)) { + proto = globalObject[ctorRegistrySymbol]["XMLSerializer"].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); +}; + +exports._internalSetup = (wrapper, 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 exposed = new Set(["Window"]); + +exports.install = (globalObject, globalNames) => { + if (!globalNames.some(globalName => exposed.has(globalName))) { + return; + } + + const ctorRegistry = utils.initCtorRegistry(globalObject); + class XMLSerializer { + constructor() { + return exports.setup(Object.create(new.target.prototype), globalObject, undefined); + } + + serializeToString(root) { + const esValue = this !== null && this !== undefined ? this : globalObject; + if (!exports.is(esValue)) { + throw new globalObject.TypeError( + "'serializeToString' called on an object that is not a valid instance of XMLSerializer." + ); + } + + if (arguments.length < 1) { + throw new globalObject.TypeError( + `Failed to execute 'serializeToString' on 'XMLSerializer': 1 argument required, but only ${arguments.length} present.` + ); + } + const args = []; + { + let curArg = arguments[0]; + curArg = Node.convert(globalObject, curArg, { + context: "Failed to execute 'serializeToString' on 'XMLSerializer': parameter 1" + }); + args.push(curArg); + } + return esValue[implSymbol].serializeToString(...args); + } + } + Object.defineProperties(XMLSerializer.prototype, { + serializeToString: { enumerable: true }, + [Symbol.toStringTag]: { value: "XMLSerializer", configurable: true } + }); + ctorRegistry[interfaceName] = XMLSerializer; + + Object.defineProperty(globalObject, interfaceName, { + configurable: true, + writable: true, + value: XMLSerializer + }); +}; + +const Impl = require("../domparsing/XMLSerializer-impl.js"); diff --git a/node_modules/jsdom/lib/jsdom/living/generated/utils.js b/node_modules/jsdom/lib/jsdom/living/generated/utils.js new file mode 100644 index 0000000000000000000000000000000000000000..5e50979102f86ea582fb283de311bdb993b6597d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/generated/utils.js @@ -0,0 +1,252 @@ +"use strict"; + +// Returns "Type(value) is Object" in ES terminology. +function isObject(value) { + return (typeof value === "object" && value !== null) || typeof value === "function"; +} + +const call = Function.call.bind(Function.call); + +// Like `Object.assign`, but using `[[GetOwnProperty]]` and `[[DefineOwnProperty]]` +// instead of `[[Get]]` and `[[Set]]` and only allowing objects +function define(target, source) { + for (const key of Reflect.ownKeys(source)) { + const descriptor = Reflect.getOwnPropertyDescriptor(source, key); + if (descriptor && !Reflect.defineProperty(target, key, descriptor)) { + throw new TypeError(`Cannot redefine property: ${String(key)}`); + } + } +} + +function newObjectInRealm(globalObject, object) { + const ctorRegistry = initCtorRegistry(globalObject); + return Object.defineProperties( + Object.create(ctorRegistry["%Object.prototype%"]), + Object.getOwnPropertyDescriptors(object) + ); +} + +const wrapperSymbol = Symbol("wrapper"); +const implSymbol = Symbol("impl"); +const sameObjectCaches = Symbol("SameObject caches"); +const ctorRegistrySymbol = Symbol.for("[webidl2js] constructor registry"); + +const AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype); + +function initCtorRegistry(globalObject) { + if (Object.hasOwn(globalObject, ctorRegistrySymbol)) { + return globalObject[ctorRegistrySymbol]; + } + + const ctorRegistry = Object.create(null); + + // In addition to registering all the WebIDL2JS-generated types in the constructor registry, + // we also register a few intrinsics that we make use of in generated code, since they are not + // easy to grab from the globalObject variable. + ctorRegistry["%Object.prototype%"] = globalObject.Object.prototype; + ctorRegistry["%IteratorPrototype%"] = Object.getPrototypeOf( + Object.getPrototypeOf(new globalObject.Array()[Symbol.iterator]()) + ); + + try { + ctorRegistry["%AsyncIteratorPrototype%"] = Object.getPrototypeOf( + Object.getPrototypeOf( + globalObject.eval("(async function* () {})").prototype + ) + ); + } catch { + ctorRegistry["%AsyncIteratorPrototype%"] = AsyncIteratorPrototype; + } + + globalObject[ctorRegistrySymbol] = ctorRegistry; + return ctorRegistry; +} + +function getSameObject(wrapper, prop, creator) { + if (!wrapper[sameObjectCaches]) { + wrapper[sameObjectCaches] = Object.create(null); + } + + if (prop in wrapper[sameObjectCaches]) { + return wrapper[sameObjectCaches][prop]; + } + + wrapper[sameObjectCaches][prop] = creator(); + return wrapper[sameObjectCaches][prop]; +} + +function wrapperForImpl(impl) { + return impl ? impl[wrapperSymbol] : null; +} + +function implForWrapper(wrapper) { + return wrapper ? wrapper[implSymbol] : null; +} + +function tryWrapperForImpl(impl) { + const wrapper = wrapperForImpl(impl); + return wrapper ? wrapper : impl; +} + +function tryImplForWrapper(wrapper) { + const impl = implForWrapper(wrapper); + return impl ? impl : wrapper; +} + +const iterInternalSymbol = Symbol("internal"); + +function isArrayIndexPropName(P) { + if (typeof P !== "string") { + return false; + } + const i = P >>> 0; + if (i === 2 ** 32 - 1) { + return false; + } + const s = `${i}`; + if (P !== s) { + return false; + } + return true; +} + +const arrayBufferByteLengthGetter = + Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get; +function isArrayBuffer(value) { + try { + arrayBufferByteLengthGetter.call(value); + return true; + } catch { + return false; + } +} + +const sharedArrayBufferByteLengthGetter = + Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "byteLength").get; +function isSharedArrayBuffer(value) { + try { + sharedArrayBufferByteLengthGetter.call(value); + return true; + } catch { + return false; + } +} + +function iteratorResult([key, value], kind) { + let result; + switch (kind) { + case "key": + result = key; + break; + case "value": + result = value; + break; + case "key+value": + result = [key, value]; + break; + } + return { value: result, done: false }; +} + +function ordinarySetWithOwnDescriptor(target, property, value, receiver, ownDesc) { + if (ownDesc === undefined) { + const parent = Reflect.getPrototypeOf(target); + if (parent !== null) { + return Reflect.set(parent, property, value, receiver); + } + ownDesc = { writable: true, enumerable: true, configurable: true, value: undefined }; + } + if (isDataDescriptor(ownDesc)) { + if (!ownDesc.writable) { + return false; + } + if (!isObject(receiver)) { + return false; + } + const existingDesc = Reflect.getOwnPropertyDescriptor(receiver, property); + if (existingDesc !== undefined) { + if (isAccessorDescriptor(existingDesc)) { + return false; + } + if (existingDesc.writable === false) { + return false; + } + const valueDesc = { value }; + return Reflect.defineProperty(receiver, property, valueDesc); + } + + return Reflect.defineProperty( + receiver, + property, + { value, writable: true, enumerable: true, configurable: true } + ); + } + + const setter = ownDesc.set; + if (setter === undefined) { + return false; + } + call(setter, receiver, value); + return true; +} + +function isDataDescriptor(desc) { + return Object.hasOwn(desc, "value") || Object.hasOwn(desc, "writable"); +} + +function isAccessorDescriptor(desc) { + return Object.hasOwn(desc, "get") || Object.hasOwn(desc, "set"); +} + +const supportsPropertyIndex = Symbol("supports property index"); +const supportedPropertyIndices = Symbol("supported property indices"); +const supportsPropertyName = Symbol("supports property name"); +const supportedPropertyNames = Symbol("supported property names"); +const indexedGet = Symbol("indexed property get"); +const indexedSetNew = Symbol("indexed property set new"); +const indexedSetExisting = Symbol("indexed property set existing"); +const namedGet = Symbol("named property get"); +const namedSetNew = Symbol("named property set new"); +const namedSetExisting = Symbol("named property set existing"); +const namedDelete = Symbol("named property delete"); + +const asyncIteratorNext = Symbol("async iterator get the next iteration result"); +const asyncIteratorReturn = Symbol("async iterator return steps"); +const asyncIteratorInit = Symbol("async iterator initialization steps"); +const asyncIteratorEOI = Symbol("async iterator end of iteration"); + +module.exports = exports = { + isObject, + define, + newObjectInRealm, + wrapperSymbol, + implSymbol, + getSameObject, + ctorRegistrySymbol, + initCtorRegistry, + wrapperForImpl, + implForWrapper, + tryWrapperForImpl, + tryImplForWrapper, + iterInternalSymbol, + isArrayBuffer, + isSharedArrayBuffer, + isArrayIndexPropName, + supportsPropertyIndex, + supportedPropertyIndices, + supportsPropertyName, + supportedPropertyNames, + indexedGet, + indexedSetNew, + indexedSetExisting, + namedGet, + namedSetNew, + namedSetExisting, + namedDelete, + asyncIteratorNext, + asyncIteratorReturn, + asyncIteratorInit, + asyncIteratorEOI, + iteratorResult, + ordinarySetWithOwnDescriptor +}; diff --git a/node_modules/jsdom/lib/jsdom/living/geometry/DOMRect-impl.js b/node_modules/jsdom/lib/jsdom/living/geometry/DOMRect-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..7a71f55a25fd9d5695b7e3293671c6ce17fbdaa8 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/geometry/DOMRect-impl.js @@ -0,0 +1,39 @@ +"use strict"; +const DOMRectReadOnlyImpl = require("./DOMRectReadOnly-impl").implementation; +const DOMRect = require("../generated/DOMRect"); + +class DOMRectImpl extends DOMRectReadOnlyImpl { + static fromRect(globalObject, other) { + return DOMRect.createImpl(globalObject, [other.x, other.y, other.width, other.height]); + } + + get x() { + return super.x; + } + set x(newX) { + this._x = newX; + } + + get y() { + return super.y; + } + set y(newY) { + this._y = newY; + } + + get width() { + return super.width; + } + set width(newWidth) { + this._width = newWidth; + } + + get height() { + return super.height; + } + set height(newHeight) { + this._height = newHeight; + } +} + +exports.implementation = DOMRectImpl; diff --git a/node_modules/jsdom/lib/jsdom/living/geometry/DOMRectReadOnly-impl.js b/node_modules/jsdom/lib/jsdom/living/geometry/DOMRectReadOnly-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..5179865a49029531e675053f52cdeadf6b5b7596 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/geometry/DOMRectReadOnly-impl.js @@ -0,0 +1,72 @@ +"use strict"; +const DOMRectReadOnly = require("../generated/DOMRectReadOnly"); + +class DOMRectReadOnlyImpl { + constructor(globalObject, [x = 0, y = 0, width = 0, height = 0]) { + this._globalObject = globalObject; + this._x = x; + this._y = y; + this._width = width; + this._height = height; + } + + static fromRect(globalObject, other) { + return DOMRectReadOnly.createImpl(globalObject, [other.x, other.y, other.width, other.height]); + } + + get x() { + return this._x; + } + + get y() { + return this._y; + } + + get width() { + return this._width; + } + + get height() { + return this._height; + } + + get top() { + const { height, y } = this; + // We use Math.min's built-in NaN handling: https://github.com/w3c/fxtf-drafts/issues/222 + return Math.min(y, y + height); + } + + get right() { + const { width, x } = this; + // We use Math.max's built-in NaN handling: https://github.com/w3c/fxtf-drafts/issues/222 + return Math.max(x, x + width); + } + + get bottom() { + const { height, y } = this; + // We use Math.max's built-in NaN handling: https://github.com/w3c/fxtf-drafts/issues/222 + return Math.max(y, y + height); + } + + get left() { + const { width, x } = this; + // We use Math.min's built-in NaN handling: https://github.com/w3c/fxtf-drafts/issues/222 + return Math.min(x, x + width); + } + + // Could be removed after https://github.com/jsdom/webidl2js/issues/185 gets fixed. + toJSON() { + return { + x: this.x, + y: this.y, + width: this.width, + height: this.height, + top: this.top, + right: this.right, + bottom: this.bottom, + left: this.left + }; + } +} + +exports.implementation = DOMRectReadOnlyImpl; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/agent-factory.js b/node_modules/jsdom/lib/jsdom/living/helpers/agent-factory.js new file mode 100644 index 0000000000000000000000000000000000000000..02d2469d6a27735d0f651402b361778fa190e3a0 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/agent-factory.js @@ -0,0 +1,13 @@ +"use strict"; +const http = require("http"); +const https = require("https"); +const { HttpProxyAgent } = require("http-proxy-agent"); +const { HttpsProxyAgent } = require("https-proxy-agent"); + +module.exports = function agentFactory(proxy, rejectUnauthorized) { + const agentOpts = { keepAlive: true, rejectUnauthorized }; + if (proxy) { + return { https: new HttpsProxyAgent(proxy, agentOpts), http: new HttpProxyAgent(proxy, agentOpts) }; + } + return { http: new http.Agent(agentOpts), https: new https.Agent(agentOpts) }; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/binary-data.js b/node_modules/jsdom/lib/jsdom/living/helpers/binary-data.js new file mode 100644 index 0000000000000000000000000000000000000000..dc5909c86889edd9cf524d883c0ff9e0062686c4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/binary-data.js @@ -0,0 +1,9 @@ +"use strict"; + +// See https://github.com/jsdom/jsdom/pull/2743#issuecomment-562991955 for background. +exports.copyToArrayBufferInNewRealm = (nodejsBuffer, newRealm) => { + const newAB = new newRealm.ArrayBuffer(nodejsBuffer.byteLength); + const view = new Uint8Array(newAB); + view.set(nodejsBuffer); + return newAB; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/colors.js b/node_modules/jsdom/lib/jsdom/living/helpers/colors.js new file mode 100644 index 0000000000000000000000000000000000000000..ca8653cca3636cb5cda0317d73b67b3ccabb3fe5 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/colors.js @@ -0,0 +1,245 @@ +"use strict"; + +// https://drafts.csswg.org/css-color-4/#named-color +const namedColors = { + __proto__: null, + aliceblue: [0xF0, 0xF8, 0xFF], + antiquewhite: [0xFA, 0xEB, 0xD7], + aqua: [0x00, 0xFF, 0xFF], + aquamarine: [0x7F, 0xFF, 0xD4], + azure: [0xF0, 0xFF, 0xFF], + beige: [0xF5, 0xF5, 0xDC], + bisque: [0xFF, 0xE4, 0xC4], + black: [0x00, 0x00, 0x00], + blanchedalmond: [0xFF, 0xEB, 0xCD], + blue: [0x00, 0x00, 0xFF], + blueviolet: [0x8A, 0x2B, 0xE2], + brown: [0xA5, 0x2A, 0x2A], + burlywood: [0xDE, 0xB8, 0x87], + cadetblue: [0x5F, 0x9E, 0xA0], + chartreuse: [0x7F, 0xFF, 0x00], + chocolate: [0xD2, 0x69, 0x1E], + coral: [0xFF, 0x7F, 0x50], + cornflowerblue: [0x64, 0x95, 0xED], + cornsilk: [0xFF, 0xF8, 0xDC], + crimson: [0xDC, 0x14, 0x3C], + cyan: [0x00, 0xFF, 0xFF], + darkblue: [0x00, 0x00, 0x8B], + darkcyan: [0x00, 0x8B, 0x8B], + darkgoldenrod: [0xB8, 0x86, 0x0B], + darkgray: [0xA9, 0xA9, 0xA9], + darkgreen: [0x00, 0x64, 0x00], + darkgrey: [0xA9, 0xA9, 0xA9], + darkkhaki: [0xBD, 0xB7, 0x6B], + darkmagenta: [0x8B, 0x00, 0x8B], + darkolivegreen: [0x55, 0x6B, 0x2F], + darkorange: [0xFF, 0x8C, 0x00], + darkorchid: [0x99, 0x32, 0xCC], + darkred: [0x8B, 0x00, 0x00], + darksalmon: [0xE9, 0x96, 0x7A], + darkseagreen: [0x8F, 0xBC, 0x8F], + darkslateblue: [0x48, 0x3D, 0x8B], + darkslategray: [0x2F, 0x4F, 0x4F], + darkslategrey: [0x2F, 0x4F, 0x4F], + darkturquoise: [0x00, 0xCE, 0xD1], + darkviolet: [0x94, 0x00, 0xD3], + deeppink: [0xFF, 0x14, 0x93], + deepskyblue: [0x00, 0xBF, 0xFF], + dimgray: [0x69, 0x69, 0x69], + dimgrey: [0x69, 0x69, 0x69], + dodgerblue: [0x1E, 0x90, 0xFF], + firebrick: [0xB2, 0x22, 0x22], + floralwhite: [0xFF, 0xFA, 0xF0], + forestgreen: [0x22, 0x8B, 0x22], + fuchsia: [0xFF, 0x00, 0xFF], + gainsboro: [0xDC, 0xDC, 0xDC], + ghostwhite: [0xF8, 0xF8, 0xFF], + gold: [0xFF, 0xD7, 0x00], + goldenrod: [0xDA, 0xA5, 0x20], + gray: [0x80, 0x80, 0x80], + green: [0x00, 0x80, 0x00], + greenyellow: [0xAD, 0xFF, 0x2F], + grey: [0x80, 0x80, 0x80], + honeydew: [0xF0, 0xFF, 0xF0], + hotpink: [0xFF, 0x69, 0xB4], + indianred: [0xCD, 0x5C, 0x5C], + indigo: [0x4B, 0x00, 0x82], + ivory: [0xFF, 0xFF, 0xF0], + khaki: [0xF0, 0xE6, 0x8C], + lavender: [0xE6, 0xE6, 0xFA], + lavenderblush: [0xFF, 0xF0, 0xF5], + lawngreen: [0x7C, 0xFC, 0x00], + lemonchiffon: [0xFF, 0xFA, 0xCD], + lightblue: [0xAD, 0xD8, 0xE6], + lightcoral: [0xF0, 0x80, 0x80], + lightcyan: [0xE0, 0xFF, 0xFF], + lightgoldenrodyellow: [0xFA, 0xFA, 0xD2], + lightgray: [0xD3, 0xD3, 0xD3], + lightgreen: [0x90, 0xEE, 0x90], + lightgrey: [0xD3, 0xD3, 0xD3], + lightpink: [0xFF, 0xB6, 0xC1], + lightsalmon: [0xFF, 0xA0, 0x7A], + lightseagreen: [0x20, 0xB2, 0xAA], + lightskyblue: [0x87, 0xCE, 0xFA], + lightslategray: [0x77, 0x88, 0x99], + lightslategrey: [0x77, 0x88, 0x99], + lightsteelblue: [0xB0, 0xC4, 0xDE], + lightyellow: [0xFF, 0xFF, 0xE0], + lime: [0x00, 0xFF, 0x00], + limegreen: [0x32, 0xCD, 0x32], + linen: [0xFA, 0xF0, 0xE6], + magenta: [0xFF, 0x00, 0xFF], + maroon: [0x80, 0x00, 0x00], + mediumaquamarine: [0x66, 0xCD, 0xAA], + mediumblue: [0x00, 0x00, 0xCD], + mediumorchid: [0xBA, 0x55, 0xD3], + mediumpurple: [0x93, 0x70, 0xDB], + mediumseagreen: [0x3C, 0xB3, 0x71], + mediumslateblue: [0x7B, 0x68, 0xEE], + mediumspringgreen: [0x00, 0xFA, 0x9A], + mediumturquoise: [0x48, 0xD1, 0xCC], + mediumvioletred: [0xC7, 0x15, 0x85], + midnightblue: [0x19, 0x19, 0x70], + mintcream: [0xF5, 0xFF, 0xFA], + mistyrose: [0xFF, 0xE4, 0xE1], + moccasin: [0xFF, 0xE4, 0xB5], + navajowhite: [0xFF, 0xDE, 0xAD], + navy: [0x00, 0x00, 0x80], + oldlace: [0xFD, 0xF5, 0xE6], + olive: [0x80, 0x80, 0x00], + olivedrab: [0x6B, 0x8E, 0x23], + orange: [0xFF, 0xA5, 0x00], + orangered: [0xFF, 0x45, 0x00], + orchid: [0xDA, 0x70, 0xD6], + palegoldenrod: [0xEE, 0xE8, 0xAA], + palegreen: [0x98, 0xFB, 0x98], + paleturquoise: [0xAF, 0xEE, 0xEE], + palevioletred: [0xDB, 0x70, 0x93], + papayawhip: [0xFF, 0xEF, 0xD5], + peachpuff: [0xFF, 0xDA, 0xB9], + peru: [0xCD, 0x85, 0x3F], + pink: [0xFF, 0xC0, 0xCB], + plum: [0xDD, 0xA0, 0xDD], + powderblue: [0xB0, 0xE0, 0xE6], + purple: [0x80, 0x00, 0x80], + rebeccapurple: [0x66, 0x33, 0x99], + red: [0xFF, 0x00, 0x00], + rosybrown: [0xBC, 0x8F, 0x8F], + royalblue: [0x41, 0x69, 0xE1], + saddlebrown: [0x8B, 0x45, 0x13], + salmon: [0xFA, 0x80, 0x72], + sandybrown: [0xF4, 0xA4, 0x60], + seagreen: [0x2E, 0x8B, 0x57], + seashell: [0xFF, 0xF5, 0xEE], + sienna: [0xA0, 0x52, 0x2D], + silver: [0xC0, 0xC0, 0xC0], + skyblue: [0x87, 0xCE, 0xEB], + slateblue: [0x6A, 0x5A, 0xCD], + slategray: [0x70, 0x80, 0x90], + slategrey: [0x70, 0x80, 0x90], + snow: [0xFF, 0xFA, 0xFA], + springgreen: [0x00, 0xFF, 0x7F], + steelblue: [0x46, 0x82, 0xB4], + tan: [0xD2, 0xB4, 0x8C], + teal: [0x00, 0x80, 0x80], + thistle: [0xD8, 0xBF, 0xD8], + tomato: [0xFF, 0x63, 0x47], + turquoise: [0x40, 0xE0, 0xD0], + violet: [0xEE, 0x82, 0xEE], + wheat: [0xF5, 0xDE, 0xB3], + white: [0xFF, 0xFF, 0xFF], + whitesmoke: [0xF5, 0xF5, 0xF5], + yellow: [0xFF, 0xFF, 0x00], + yellowgreen: [0x9A, 0xCD, 0x32] +}; + +// Implements some of https://drafts.csswg.org/css-color-4/#resolving-sRGB-values and +// https://drafts.csswg.org/css-color-4/#serializing-sRGB-values, in a somewhat fragile way since +// we're not using a real parser/serializer. Attempts to cover: +// * hex colors +// * 'rgb()' and 'rgba()' values +// * named colors +// * 'transparent' + +exports.getSpecifiedColor = color => { + const lowercasedColor = color.toLowerCase(); + if (Object.hasOwn(namedColors, lowercasedColor) || lowercasedColor === "transparent") { + return lowercasedColor; + } + + return sharedSpecifiedAndComputedAndUsed(color); +}; + +exports.getComputedOrUsedColor = color => { + const lowercasedColor = color.toLowerCase(); + const fromNamedColors = namedColors[lowercasedColor]; + if (fromNamedColors !== undefined) { + return `rgb(${fromNamedColors.join(", ")})`; + } + + if (lowercasedColor === "transparent") { + return "rgba(0, 0, 0, 0)"; + } + + return sharedSpecifiedAndComputedAndUsed(color); +}; + +function sharedSpecifiedAndComputedAndUsed(color) { + if (/^#[0-9A-Fa-f]{6}$/.test(color) || /^#[0-9A-Fa-f]{3}$/.test(color)) { + return hexToRGB(color.slice(1)); + } + + if (/^#[0-9A-Fa-f]{8}$/.test(color) || /^#[0-9A-Fa-f]{4}$/.test(color)) { + return hexToRGBA(color.slice(1)); + } + + if (/^rgba?\(/.test(color)) { + return color.split(",").map(s => s.trim()).join(", "); + } + + return color; +} + +function hexToRGB(color) { + if (color.length === 6) { + const [r1, r2, g1, g2, b1, b2] = color.split(""); + + return `rgb(${hexesToDecimals([r1, r2], [g1, g2], [b1, b2]).join(", ")})`; + } + + if (color.length === 3) { + const [r1, g1, b1] = color.split(""); + + return `rgb(${hexesToDecimals([r1, r1], [g1, g1], [b1, b1]).join(", ")})`; + } + + return "rgb(0, 0, 0)"; +} + +function hexToRGBA(color) { + if (color.length === 8) { + const [r1, r2, g1, g2, b1, b2, a1, a2] = color.split(""); + + return `rgba(${hexesToDecimals([r1, r2], [g1, g2], [b1, b2]).join(", ")}, ${hexToPercent(a1, a2)})`; + } + + if (color.length === 4) { + const [r1, g1, b1, a1] = color.split(""); + + return `rgba(${hexesToDecimals([r1, r1], [g1, g1], [b1, b1]).join(", ")}, ${hexToPercent(a1, a1)})`; + } + + return "rgba(0, 0, 0, 1)"; +} + +function hexToDecimal(d1, d2) { + return parseInt(d1, 16) * 16 + parseInt(d2, 16); +} + +function hexesToDecimals(...hexes) { + return hexes.map(pair => hexToDecimal(pair[0], pair[1])); +} + +function hexToPercent(d1, d2) { + return Math.floor(1000 * hexToDecimal(d1, d2) / 255) / 1000; +} diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/create-element.js b/node_modules/jsdom/lib/jsdom/living/helpers/create-element.js new file mode 100644 index 0000000000000000000000000000000000000000..fca473fb533adb1d4490f8787113ad78bfbe5e54 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/create-element.js @@ -0,0 +1,329 @@ +"use strict"; + +const DOMException = require("../generated/DOMException"); + +const interfaces = require("../interfaces"); + +const { implForWrapper } = require("../generated/utils"); + +const { HTML_NS, SVG_NS } = require("./namespaces"); +const { domSymbolTree } = require("./internal-constants"); +const { validateAndExtract } = require("./validate-names"); +const reportException = require("./runtime-script-errors"); +const { + isValidCustomElementName, upgradeElement, lookupCEDefinition, enqueueCEUpgradeReaction +} = require("./custom-elements"); + +const INTERFACE_TAG_MAPPING = { + __proto__: null, + // https://html.spec.whatwg.org/multipage/dom.html#elements-in-the-dom%3Aelement-interface + // https://html.spec.whatwg.org/multipage/indices.html#elements-3 + [HTML_NS]: { + __proto__: null, + HTMLElement: [ + "abbr", "address", "article", "aside", "b", "bdi", "bdo", "cite", "code", "dd", "dfn", "dt", "em", "figcaption", + "figure", "footer", "header", "hgroup", "i", "kbd", "main", "mark", "nav", "noscript", "rp", "rt", "ruby", "s", + "samp", "section", "small", "strong", "sub", "summary", "sup", "u", "var", "wbr" + ], + HTMLAnchorElement: ["a"], + HTMLAreaElement: ["area"], + HTMLAudioElement: ["audio"], + HTMLBaseElement: ["base"], + HTMLBodyElement: ["body"], + HTMLBRElement: ["br"], + HTMLButtonElement: ["button"], + HTMLCanvasElement: ["canvas"], + HTMLDataElement: ["data"], + HTMLDataListElement: ["datalist"], + HTMLDetailsElement: ["details"], + HTMLDialogElement: ["dialog"], + HTMLDirectoryElement: ["dir"], + HTMLDivElement: ["div"], + HTMLDListElement: ["dl"], + HTMLEmbedElement: ["embed"], + HTMLFieldSetElement: ["fieldset"], + HTMLFontElement: ["font"], + HTMLFormElement: ["form"], + HTMLFrameElement: ["frame"], + HTMLFrameSetElement: ["frameset"], + HTMLHeadingElement: ["h1", "h2", "h3", "h4", "h5", "h6"], + HTMLHeadElement: ["head"], + HTMLHRElement: ["hr"], + HTMLHtmlElement: ["html"], + HTMLIFrameElement: ["iframe"], + HTMLImageElement: ["img"], + HTMLInputElement: ["input"], + HTMLLabelElement: ["label"], + HTMLLegendElement: ["legend"], + HTMLLIElement: ["li"], + HTMLLinkElement: ["link"], + HTMLMapElement: ["map"], + HTMLMarqueeElement: ["marquee"], + HTMLMediaElement: [], + HTMLMenuElement: ["menu"], + HTMLMetaElement: ["meta"], + HTMLMeterElement: ["meter"], + HTMLModElement: ["del", "ins"], + HTMLObjectElement: ["object"], + HTMLOListElement: ["ol"], + HTMLOptGroupElement: ["optgroup"], + HTMLOptionElement: ["option"], + HTMLOutputElement: ["output"], + HTMLParagraphElement: ["p"], + HTMLParamElement: ["param"], + HTMLPictureElement: ["picture"], + HTMLPreElement: ["listing", "pre", "xmp"], + HTMLProgressElement: ["progress"], + HTMLQuoteElement: ["blockquote", "q"], + HTMLScriptElement: ["script"], + HTMLSelectElement: ["select"], + HTMLSlotElement: ["slot"], + HTMLSourceElement: ["source"], + HTMLSpanElement: ["span"], + HTMLStyleElement: ["style"], + HTMLTableCaptionElement: ["caption"], + HTMLTableCellElement: ["th", "td"], + HTMLTableColElement: ["col", "colgroup"], + HTMLTableElement: ["table"], + HTMLTimeElement: ["time"], + HTMLTitleElement: ["title"], + HTMLTableRowElement: ["tr"], + HTMLTableSectionElement: ["thead", "tbody", "tfoot"], + HTMLTemplateElement: ["template"], + HTMLTextAreaElement: ["textarea"], + HTMLTrackElement: ["track"], + HTMLUListElement: ["ul"], + HTMLUnknownElement: [], + HTMLVideoElement: ["video"] + }, + [SVG_NS]: { + __proto__: null, + SVGElement: [], + SVGGraphicsElement: [], + SVGDefsElement: ["defs"], + SVGDescElement: ["desc"], + SVGGElement: ["g"], + SVGMetadataElement: ["metadata"], + SVGSVGElement: ["svg"], + SVGSwitchElement: ["switch"], + SVGSymbolElement: ["symbol"], + SVGTitleElement: ["title"] + } +}; + +const TAG_INTERFACE_LOOKUP = Object.create(null); + +for (const namespace of [HTML_NS, SVG_NS]) { + TAG_INTERFACE_LOOKUP[namespace] = Object.create(null); + + const interfaceNames = Object.keys(INTERFACE_TAG_MAPPING[namespace]); + for (const interfaceName of interfaceNames) { + const tagNames = INTERFACE_TAG_MAPPING[namespace][interfaceName]; + + for (const tagName of tagNames) { + TAG_INTERFACE_LOOKUP[namespace][tagName] = interfaceName; + } + } +} + +const UNKNOWN_HTML_ELEMENTS_NAMES = ["applet", "bgsound", "blink", "isindex", "keygen", "multicol", "nextid", "spacer"]; +const HTML_ELEMENTS_NAMES = [ + "acronym", "basefont", "big", "center", "nobr", "noembed", "noframes", "plaintext", "rb", "rtc", + "strike", "tt" +]; + +// https://html.spec.whatwg.org/multipage/dom.html#elements-in-the-dom:element-interface +function getHTMLElementInterface(name) { + if (UNKNOWN_HTML_ELEMENTS_NAMES.includes(name)) { + return interfaces.getInterfaceWrapper("HTMLUnknownElement"); + } + + if (HTML_ELEMENTS_NAMES.includes(name)) { + return interfaces.getInterfaceWrapper("HTMLElement"); + } + + const specDefinedInterface = TAG_INTERFACE_LOOKUP[HTML_NS][name]; + if (specDefinedInterface !== undefined) { + return interfaces.getInterfaceWrapper(specDefinedInterface); + } + + if (isValidCustomElementName(name)) { + return interfaces.getInterfaceWrapper("HTMLElement"); + } + + return interfaces.getInterfaceWrapper("HTMLUnknownElement"); +} + +// https://svgwg.org/svg2-draft/types.html#ElementsInTheSVGDOM +function getSVGInterface(name) { + const specDefinedInterface = TAG_INTERFACE_LOOKUP[SVG_NS][name]; + if (specDefinedInterface !== undefined) { + return interfaces.getInterfaceWrapper(specDefinedInterface); + } + + return interfaces.getInterfaceWrapper("SVGElement"); +} + +// Returns the list of valid tag names that can bo associated with a element given its namespace and name. +function getValidTagNames(namespace, name) { + if (INTERFACE_TAG_MAPPING[namespace] && INTERFACE_TAG_MAPPING[namespace][name]) { + return INTERFACE_TAG_MAPPING[namespace][name]; + } + + return []; +} + +// https://dom.spec.whatwg.org/#concept-create-element +function createElement( + document, + localName, + namespace, + prefix = null, + isValue = null, + synchronousCE = false +) { + let result = null; + + const { _globalObject } = document; + const definition = lookupCEDefinition(document, namespace, localName, isValue); + + if (definition !== null && definition.name !== localName) { + const elementInterface = getHTMLElementInterface(localName); + + result = elementInterface.createImpl(_globalObject, [], { + ownerDocument: document, + localName, + namespace: HTML_NS, + prefix, + ceState: "undefined", + ceDefinition: null, + isValue + }); + + if (synchronousCE) { + upgradeElement(definition, result); + } else { + enqueueCEUpgradeReaction(result, definition); + } + } else if (definition !== null) { + if (synchronousCE) { + try { + const C = definition.constructor; + + const resultWrapper = C.construct(); + result = implForWrapper(resultWrapper); + + if (!result._ceState || !result._ceDefinition || result._namespaceURI !== HTML_NS) { + throw new TypeError("Internal error: Invalid custom element."); + } + + if (result._attributeList.length !== 0) { + throw DOMException.create(_globalObject, ["Unexpected attributes.", "NotSupportedError"]); + } + if (domSymbolTree.hasChildren(result)) { + throw DOMException.create(_globalObject, ["Unexpected child nodes.", "NotSupportedError"]); + } + if (domSymbolTree.parent(result)) { + throw DOMException.create(_globalObject, ["Unexpected element parent.", "NotSupportedError"]); + } + if (result._ownerDocument !== document) { + throw DOMException.create(_globalObject, ["Unexpected element owner document.", "NotSupportedError"]); + } + if (result._namespaceURI !== namespace) { + throw DOMException.create(_globalObject, ["Unexpected element namespace URI.", "NotSupportedError"]); + } + if (result._localName !== localName) { + throw DOMException.create(_globalObject, ["Unexpected element local name.", "NotSupportedError"]); + } + + result._prefix = prefix; + result._isValue = isValue; + } catch (error) { + reportException(document._defaultView, error); + + const interfaceWrapper = interfaces.getInterfaceWrapper("HTMLUnknownElement"); + result = interfaceWrapper.createImpl(_globalObject, [], { + ownerDocument: document, + localName, + namespace: HTML_NS, + prefix, + ceState: "failed", + ceDefinition: null, + isValue: null + }); + } + } else { + const interfaceWrapper = interfaces.getInterfaceWrapper("HTMLElement"); + result = interfaceWrapper.createImpl(_globalObject, [], { + ownerDocument: document, + localName, + namespace: HTML_NS, + prefix, + ceState: "undefined", + ceDefinition: null, + isValue: null + }); + + enqueueCEUpgradeReaction(result, definition); + } + } else { + let elementInterface; + + switch (namespace) { + case HTML_NS: + elementInterface = getHTMLElementInterface(localName); + break; + + case SVG_NS: + elementInterface = getSVGInterface(localName); + break; + + default: + elementInterface = interfaces.getInterfaceWrapper("Element"); + break; + } + + result = elementInterface.createImpl(_globalObject, [], { + ownerDocument: document, + localName, + namespace, + prefix, + ceState: "uncustomized", + ceDefinition: null, + isValue + }); + + if (namespace === HTML_NS && (isValidCustomElementName(localName) || isValue !== null)) { + result._ceState = "undefined"; + } + } + + return result; +} + +// https://dom.spec.whatwg.org/#internal-createelementns-steps +function internalCreateElementNSSteps(document, namespace, qualifiedName, options) { + const extracted = validateAndExtract(document._globalObject, namespace, qualifiedName); + + let isValue = null; + if (options && options.is !== undefined) { + isValue = options.is; + } + + return createElement( + document, + extracted.localName, + extracted.namespace, + extracted.prefix, + isValue, + true + ); +} + +module.exports = { + createElement, + internalCreateElementNSSteps, + + getValidTagNames, + getHTMLElementInterface +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js b/node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js new file mode 100644 index 0000000000000000000000000000000000000000..31693f2a7d86b9346a8e0455f0129aa518266c57 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js @@ -0,0 +1,188 @@ +"use strict"; + +const idlUtils = require("../generated/utils"); +const ErrorEvent = require("../generated/ErrorEvent"); +const BeforeUnloadEvent = require("../generated/BeforeUnloadEvent"); +const EventHandlerNonNull = require("../generated/EventHandlerNonNull.js"); +const OnBeforeUnloadEventHandlerNonNull = require("../generated/OnBeforeUnloadEventHandlerNonNull.js"); +const OnErrorEventHandlerNonNull = require("../generated/OnErrorEventHandlerNonNull.js"); +const reportException = require("./runtime-script-errors"); + +exports.appendHandler = (el, eventName) => { + // tryImplForWrapper() is currently required due to use in Window.js + idlUtils.tryImplForWrapper(el).addEventListener(eventName, event => { + // https://html.spec.whatwg.org/#the-event-handler-processing-algorithm + const callback = exports.getCurrentEventHandlerValue(el, eventName); + if (callback === null) { + return; + } + + const specialError = ErrorEvent.isImpl(event) && event.type === "error" && + event.currentTarget.constructor.name === "Window"; + + let returnValue = null; + // https://heycam.github.io/webidl/#es-invoking-callback-functions + if (typeof callback === "function") { + if (specialError) { + returnValue = callback.call( + event.currentTarget, + event.message, + event.filename, + event.lineno, + event.colno, + event.error + ); + } else { + returnValue = callback.call(event.currentTarget, event); + } + } + + if (event.type === "beforeunload" && BeforeUnloadEvent.isImpl(event)) { + if (returnValue !== null) { + event._canceledFlag = true; + if (event.returnValue === "") { + event.returnValue = returnValue; + } + } + } else if (specialError) { + if (returnValue === true) { + event._canceledFlag = true; + } + } else if (returnValue === false) { + event._canceledFlag = true; + } + }); +}; + +// "Simple" in this case means "no content attributes involved" +exports.setupForSimpleEventAccessors = (prototype, events) => { + prototype._getEventHandlerFor = function (event) { + return this._eventHandlers ? this._eventHandlers[event] : undefined; + }; + + prototype._setEventHandlerFor = function (event, handler) { + if (!this._registeredHandlers) { + this._registeredHandlers = new Set(); + this._eventHandlers = Object.create(null); + } + + if (!this._registeredHandlers.has(event) && handler !== null) { + this._registeredHandlers.add(event); + exports.appendHandler(this, event); + } + this._eventHandlers[event] = handler; + }; + + for (const event of events) { + exports.createEventAccessor(prototype, event); + } +}; + +// https://html.spec.whatwg.org/multipage/webappapis.html#getting-the-current-value-of-the-event-handler +exports.getCurrentEventHandlerValue = (target, event) => { + const value = target._getEventHandlerFor(event); + if (!value) { + return null; + } + + if (value.body !== undefined) { + let element, document, fn; + if (target.constructor.name === "Window") { + element = null; + document = idlUtils.implForWrapper(target.document); + } else { + element = target; + document = element.ownerDocument; + } + const { body } = value; + + const formOwner = element !== null && element.form ? element.form : null; + const window = target.constructor.name === "Window" && target._document ? target : document.defaultView; + + try { + // eslint-disable-next-line no-new-func + Function(body); // properly error out on syntax errors + // Note: this won't execute body; that would require `Function(body)()`. + } catch (e) { + if (window) { + reportException(window, e); + } + target._setEventHandlerFor(event, null); + return null; + } + + // Note: the with (window) { } is not necessary in Node, but is necessary in a browserified environment. + + const createFunction = document.defaultView.Function; + if (event === "error" && element === null) { + const sourceURL = document ? `\n//# sourceURL=${document.URL}` : ""; + + fn = createFunction(`\ +with (arguments[0]) { return function onerror(event, source, lineno, colno, error) { +${body} +}; }${sourceURL}`)(window); + + fn = OnErrorEventHandlerNonNull.convert(window, fn); + } else { + const calls = []; + if (element !== null) { + calls.push(idlUtils.wrapperForImpl(document)); + } + + if (formOwner !== null) { + calls.push(idlUtils.wrapperForImpl(formOwner)); + } + + if (element !== null) { + calls.push(idlUtils.wrapperForImpl(element)); + } + + let wrapperBody = `\ +with (arguments[0]) { return function on${event}(event) { +${body} +}; }`; + + // eslint-disable-next-line no-unused-vars + for (const call of calls) { + wrapperBody = `\ +with (arguments[0]) { return function () { +${wrapperBody} +}; }`; + } + + if (document) { + wrapperBody += `\n//# sourceURL=${document.URL}`; + } + + fn = createFunction(wrapperBody)(window); + for (const call of calls) { + fn = fn(call); + } + + if (event === "beforeunload") { + fn = OnBeforeUnloadEventHandlerNonNull.convert(window, fn); + } else { + fn = EventHandlerNonNull.convert(window, fn); + } + } + + target._setEventHandlerFor(event, fn); + } + + return target._getEventHandlerFor(event); +}; + +// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-idl-attributes +// TODO: Consider replacing this with `[ReflectEvent]` +exports.createEventAccessor = (obj, event) => { + Object.defineProperty(obj, "on" + event, { + configurable: true, + enumerable: true, + get() { + return exports.getCurrentEventHandlerValue(this, event); + }, + set(val) { + this._setEventHandlerFor(event, val); + } + }); +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/custom-elements.js b/node_modules/jsdom/lib/jsdom/living/helpers/custom-elements.js new file mode 100644 index 0000000000000000000000000000000000000000..ab31de3a4a619b8b1e7b269f13112556d96570c7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/custom-elements.js @@ -0,0 +1,272 @@ +"use strict"; + +const DOMException = require("../generated/DOMException"); +const isPotentialCustomElementName = require("is-potential-custom-element-name"); + +const NODE_TYPE = require("../node-type"); +const { HTML_NS } = require("./namespaces"); +const { shadowIncludingRoot } = require("./shadow-dom"); +const reportException = require("./runtime-script-errors"); + +const { implForWrapper, wrapperForImpl } = require("../generated/utils"); + +// https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-reactions-stack +class CEReactionsStack { + constructor() { + this._stack = []; + + // https://html.spec.whatwg.org/multipage/custom-elements.html#backup-element-queue + this.backupElementQueue = []; + + // https://html.spec.whatwg.org/multipage/custom-elements.html#processing-the-backup-element-queue + this.processingBackupElementQueue = false; + } + + push(elementQueue) { + this._stack.push(elementQueue); + } + + pop() { + return this._stack.pop(); + } + + get currentElementQueue() { + const { _stack } = this; + return _stack[_stack.length - 1]; + } + + isEmpty() { + return this._stack.length === 0; + } +} + +// In theory separate cross-origin Windows created by separate JSDOM instances could have separate stacks. But, we would +// need to implement the whole agent architecture. Which is kind of questionable given that we don't run our Windows in +// their own separate threads, which is what agents are meant to represent. +const customElementReactionsStack = new CEReactionsStack(); + +// https://html.spec.whatwg.org/multipage/custom-elements.html#cereactions +function ceReactionsPreSteps() { + customElementReactionsStack.push([]); +} +function ceReactionsPostSteps() { + const queue = customElementReactionsStack.pop(); + invokeCEReactions(queue); +} + +const RESTRICTED_CUSTOM_ELEMENT_NAME = new Set([ + "annotation-xml", + "color-profile", + "font-face", + "font-face-src", + "font-face-uri", + "font-face-format", + "font-face-name", + "missing-glyph" +]); + +// https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name +function isValidCustomElementName(name) { + if (RESTRICTED_CUSTOM_ELEMENT_NAME.has(name)) { + return false; + } + + return isPotentialCustomElementName(name); +} + +// https://html.spec.whatwg.org/multipage/custom-elements.html#concept-upgrade-an-element +function upgradeElement(definition, element) { + if (element._ceState !== "undefined" || element._ceState === "uncustomized") { + return; + } + + element._ceDefinition = definition; + element._ceState = "failed"; + + for (const attribute of element._attributeList) { + const { _localName, _namespace, _value } = attribute; + enqueueCECallbackReaction(element, "attributeChangedCallback", [_localName, null, _value, _namespace]); + } + + if (shadowIncludingRoot(element).nodeType === NODE_TYPE.DOCUMENT_NODE) { + enqueueCECallbackReaction(element, "connectedCallback", []); + } + + definition.constructionStack.push(element); + + const { constructionStack, constructor: C } = definition; + + let constructionError; + try { + if (definition.disableShadow === true && element._shadowRoot !== null) { + throw DOMException.create(element._globalObject, [ + "Can't upgrade a custom element with a shadow root if shadow is disabled", + "NotSupportedError" + ]); + } + + element._ceState = "precustomized"; + + const constructionResult = C.construct(); + const constructionResultImpl = implForWrapper(constructionResult); + + if (constructionResultImpl !== element) { + throw new TypeError("Invalid custom element constructor return value"); + } + } catch (error) { + constructionError = error; + } + + constructionStack.pop(); + + if (constructionError !== undefined) { + element._ceDefinition = null; + element._ceReactionQueue = []; + + throw constructionError; + } + + element._ceState = "custom"; +} + +// https://html.spec.whatwg.org/#concept-try-upgrade +function tryUpgradeElement(element) { + const { _ownerDocument, _namespaceURI, _localName, _isValue } = element; + const definition = lookupCEDefinition(_ownerDocument, _namespaceURI, _localName, _isValue); + + if (definition !== null) { + enqueueCEUpgradeReaction(element, definition); + } +} + +// https://html.spec.whatwg.org/#look-up-a-custom-element-definition +function lookupCEDefinition(document, namespace, localName, isValue) { + const definition = null; + + if (namespace !== HTML_NS) { + return definition; + } + + if (!document._defaultView) { + return definition; + } + + const registry = implForWrapper(document._globalObject._customElementRegistry); + + const definitionByName = registry._customElementDefinitions.find(def => { + return def.name === def.localName && def.localName === localName; + }); + if (definitionByName !== undefined) { + return definitionByName; + } + + const definitionByIs = registry._customElementDefinitions.find(def => { + return def.name === isValue && def.localName === localName; + }); + if (definitionByIs !== undefined) { + return definitionByIs; + } + + return definition; +} + +// https://html.spec.whatwg.org/multipage/custom-elements.html#invoke-custom-element-reactions +function invokeCEReactions(elementQueue) { + while (elementQueue.length > 0) { + const element = elementQueue.shift(); + + const reactions = element._ceReactionQueue; + + try { + while (reactions.length > 0) { + const reaction = reactions.shift(); + + switch (reaction.type) { + case "upgrade": + upgradeElement(reaction.definition, element); + break; + + case "callback": + reaction.callback.apply(wrapperForImpl(element), reaction.args); + break; + } + } + } catch (error) { + reportException(element._globalObject, error); + } + } +} + +// https://html.spec.whatwg.org/multipage/custom-elements.html#enqueue-an-element-on-the-appropriate-element-queue +function enqueueElementOnAppropriateElementQueue(element) { + if (customElementReactionsStack.isEmpty()) { + customElementReactionsStack.backupElementQueue.push(element); + + if (customElementReactionsStack.processingBackupElementQueue) { + return; + } + + customElementReactionsStack.processingBackupElementQueue = true; + + Promise.resolve().then(() => { + const elementQueue = customElementReactionsStack.backupElementQueue; + invokeCEReactions(elementQueue); + + customElementReactionsStack.processingBackupElementQueue = false; + }); + } else { + customElementReactionsStack.currentElementQueue.push(element); + } +} + +// https://html.spec.whatwg.org/multipage/custom-elements.html#enqueue-a-custom-element-callback-reaction +function enqueueCECallbackReaction(element, callbackName, args) { + const { _ceDefinition: { lifecycleCallbacks, observedAttributes } } = element; + + const callback = lifecycleCallbacks[callbackName]; + if (callback === null) { + return; + } + + if (callbackName === "attributeChangedCallback") { + const attributeName = args[0]; + if (!observedAttributes.includes(attributeName)) { + return; + } + } + + element._ceReactionQueue.push({ + type: "callback", + callback, + args + }); + + enqueueElementOnAppropriateElementQueue(element); +} + +// https://html.spec.whatwg.org/#enqueue-a-custom-element-upgrade-reaction +function enqueueCEUpgradeReaction(element, definition) { + element._ceReactionQueue.push({ + type: "upgrade", + definition + }); + + enqueueElementOnAppropriateElementQueue(element); +} + +module.exports = { + customElementReactionsStack, + + ceReactionsPreSteps, + ceReactionsPostSteps, + + isValidCustomElementName, + + upgradeElement, + tryUpgradeElement, + + lookupCEDefinition, + enqueueCEUpgradeReaction, + enqueueCECallbackReaction, + invokeCEReactions +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/dates-and-times.js b/node_modules/jsdom/lib/jsdom/living/helpers/dates-and-times.js new file mode 100644 index 0000000000000000000000000000000000000000..15d920b4dd6687e42b4f23c3d2d4a95617a8794f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/dates-and-times.js @@ -0,0 +1,270 @@ +"use strict"; + +function isLeapYear(year) { + return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0); +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#number-of-days-in-month-month-of-year-year +const daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; +function numberOfDaysInMonthOfYear(month, year) { + if (month === 2 && isLeapYear(year)) { + return 29; + } + return daysInMonth[month - 1]; +} + +const monthRe = /^([0-9]{4,})-([0-9]{2})$/; + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-month-string +function parseMonthString(str) { + const matches = monthRe.exec(str); + if (!matches) { + return null; + } + const year = Number(matches[1]); + if (year <= 0) { + return null; + } + const month = Number(matches[2]); + if (month < 1 || month > 12) { + return null; + } + return { year, month }; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-month-string +function isValidMonthString(str) { + return parseMonthString(str) !== null; +} +function serializeMonth({ year, month }) { + const yearStr = `${year}`.padStart(4, "0"); + const monthStr = `${month}`.padStart(2, "0"); + return `${yearStr}-${monthStr}`; +} + +const dateRe = /^([0-9]{4,})-([0-9]{2})-([0-9]{2})$/; + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-date-string +function parseDateString(str) { + const matches = dateRe.exec(str); + if (!matches) { + return null; + } + const year = Number(matches[1]); + if (year <= 0) { + return null; + } + const month = Number(matches[2]); + if (month < 1 || month > 12) { + return null; + } + const day = Number(matches[3]); + if (day < 1 || day > numberOfDaysInMonthOfYear(month, year)) { + return null; + } + return { year, month, day }; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string +function isValidDateString(str) { + return parseDateString(str) !== null; +} +function serializeDate(date) { + const dayStr = `${date.day}`.padStart(2, "0"); + return `${serializeMonth(date)}-${dayStr}`; +} + +const yearlessDateRe = /^(?:--)?([0-9]{2})-([0-9]{2})$/; + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-yearless-date-string +function parseYearlessDateString(str) { + const matches = yearlessDateRe.exec(str); + if (!matches) { + return null; + } + const month = Number(matches[1]); + if (month < 1 || month > 12) { + return null; + } + const day = Number(matches[2]); + if (day < 1 || day > numberOfDaysInMonthOfYear(month, 4)) { + return null; + } + return { month, day }; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-yearless-date-string +function isValidYearlessDateString(str) { + return parseYearlessDateString(str) !== null; +} +function serializeYearlessDate({ month, day }) { + const monthStr = `${month}`.padStart(2, "0"); + const dayStr = `${day}`.padStart(2, "0"); + return `${monthStr}-${dayStr}`; +} + +const timeRe = /^([0-9]{2}):([0-9]{2})(?::([0-9]{2}(?:\.([0-9]{1,3}))?))?$/; + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-time-string +function parseTimeString(str) { + const matches = timeRe.exec(str); + if (!matches) { + return null; + } + const hour = Number(matches[1]); + if (hour < 0 || hour > 23) { + return null; + } + const minute = Number(matches[2]); + if (minute < 0 || minute > 59) { + return null; + } + const second = matches[3] !== undefined ? Math.trunc(Number(matches[3])) : 0; + if (second < 0 || second >= 60) { + return null; + } + const millisecond = matches[4] !== undefined ? Number(matches[4]) : 0; + return { hour, minute, second, millisecond }; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-time-string +function isValidTimeString(str) { + return parseTimeString(str) !== null; +} + +function serializeTime({ hour, minute, second, millisecond }) { + const hourStr = `${hour}`.padStart(2, "0"); + const minuteStr = `${minute}`.padStart(2, "0"); + if (second === 0 && millisecond === 0) { + return `${hourStr}:${minuteStr}`; + } + const secondStr = `${second}`.padStart(2, "0"); + const millisecondStr = `${millisecond}`.padStart(3, "0"); + return `${hourStr}:${minuteStr}:${secondStr}.${millisecondStr}`; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-local-date-and-time-string +function parseLocalDateAndTimeString(str, normalized = false) { + let separatorIdx = str.indexOf("T"); + if (separatorIdx < 0 && !normalized) { + separatorIdx = str.indexOf(" "); + } + if (separatorIdx < 0) { + return null; + } + const date = parseDateString(str.slice(0, separatorIdx)); + if (date === null) { + return null; + } + const time = parseTimeString(str.slice(separatorIdx + 1)); + if (time === null) { + return null; + } + return { date, time }; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-local-date-and-time-string +function isValidLocalDateAndTimeString(str) { + return parseLocalDateAndTimeString(str) !== null; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-normalised-local-date-and-time-string +function isValidNormalizedLocalDateAndTimeString(str) { + return parseLocalDateAndTimeString(str, true) !== null; +} +function serializeNormalizedDateAndTime({ date, time }) { + return `${serializeDate(date)}T${serializeTime(time)}`; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#week-number-of-the-last-day +// https://stackoverflow.com/a/18538272/1937836 +function weekNumberOfLastDay(year) { + const jan1 = new Date(year, 0); + return jan1.getDay() === 4 || (isLeapYear(year) && jan1.getDay() === 3) ? 53 : 52; +} + +const weekRe = /^([0-9]{4,5})-W([0-9]{2})$/; + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#parse-a-week-string +function parseWeekString(str) { + const matches = weekRe.exec(str); + if (!matches) { + return null; + } + const year = Number(matches[1]); + if (year <= 0) { + return null; + } + const week = Number(matches[2]); + if (week < 1 || week > weekNumberOfLastDay(year)) { + return null; + } + return { year, week }; +} + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-week-string +function isValidWeekString(str) { + return parseWeekString(str) !== null; +} +function serializeWeek({ year, week }) { + const yearStr = `${year}`.padStart(4, "0"); + const weekStr = `${week}`.padStart(2, "0"); + return `${yearStr}-W${weekStr}`; +} + +// https://stackoverflow.com/a/6117889 +function parseDateAsWeek(originalDate) { + const dayInSeconds = 86400000; + // Copy date so don't modify original + const date = new Date(Date.UTC(originalDate.getUTCFullYear(), originalDate.getUTCMonth(), originalDate.getUTCDate())); + // Set to nearest Thursday: current date + 4 - current day number + // Make Sunday's day number 7 + date.setUTCDate(date.getUTCDate() + 4 - (date.getUTCDay() || 7)); + // Get first day of year + const yearStart = new Date(Date.UTC(date.getUTCFullYear(), 0, 1)); + // Calculate full weeks to nearest Thursday + const week = Math.ceil((((date - yearStart) / dayInSeconds) + 1) / 7); + + return { year: date.getUTCFullYear(), week }; +} + +function isDate(obj) { + try { + Date.prototype.valueOf.call(obj); + return true; + } catch { + return false; + } +} + +module.exports = { + isDate, + numberOfDaysInMonthOfYear, + + parseMonthString, + isValidMonthString, + serializeMonth, + + parseDateString, + isValidDateString, + serializeDate, + + parseYearlessDateString, + isValidYearlessDateString, + serializeYearlessDate, + + parseTimeString, + isValidTimeString, + serializeTime, + + parseLocalDateAndTimeString, + isValidLocalDateAndTimeString, + isValidNormalizedLocalDateAndTimeString, + serializeNormalizedDateAndTime, + + parseDateAsWeek, + weekNumberOfLastDay, + parseWeekString, + isValidWeekString, + serializeWeek +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/details.js b/node_modules/jsdom/lib/jsdom/living/helpers/details.js new file mode 100644 index 0000000000000000000000000000000000000000..25c5387dd28b1bb186fab35cca7115e3dafbb87e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/details.js @@ -0,0 +1,15 @@ +"use strict"; +const { firstChildWithLocalName } = require("./traversal"); +const { HTML_NS } = require("./namespaces"); + +// https://html.spec.whatwg.org/multipage/interactive-elements.html#summary-for-its-parent-details +exports.isSummaryForParentDetails = summaryElement => { + const parent = summaryElement.parentNode; + if (parent === null) { + return false; + } + if (parent._localName !== "details" || parent._namespaceURI !== HTML_NS) { + return false; + } + return firstChildWithLocalName(parent, "summary") === summaryElement; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/events.js b/node_modules/jsdom/lib/jsdom/living/helpers/events.js new file mode 100644 index 0000000000000000000000000000000000000000..cd65a3872cac4b7fb46484b2f045c6cd079893b6 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/events.js @@ -0,0 +1,24 @@ +"use strict"; + +const Event = require("../generated/Event"); +const { tryImplForWrapper } = require("../generated/utils"); + +function createAnEvent(e, globalObject, eventInterface = Event, attributes = {}) { + return eventInterface.createImpl( + globalObject, + [e, attributes], + { isTrusted: attributes.isTrusted !== false } + ); +} + +function fireAnEvent(e, target, eventInterface, attributes, legacyTargetOverrideFlag) { + const event = createAnEvent(e, target._globalObject, eventInterface, attributes); + + // tryImplForWrapper() is currently required due to use in Window.js + return tryImplForWrapper(target)._dispatch(event, legacyTargetOverrideFlag); +} + +module.exports = { + createAnEvent, + fireAnEvent +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/focusing.js b/node_modules/jsdom/lib/jsdom/living/helpers/focusing.js new file mode 100644 index 0000000000000000000000000000000000000000..7d1a38c5c8e1f5028b26418b3631a037e0017b8e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/focusing.js @@ -0,0 +1,104 @@ +"use strict"; +const FocusEvent = require("../generated/FocusEvent.js"); +const idlUtils = require("../generated/utils.js"); +const { isDisabled } = require("./form-controls.js"); +const { firstChildWithLocalName } = require("./traversal"); +const { createAnEvent } = require("./events"); +const { HTML_NS, SVG_NS } = require("./namespaces"); +const { isRenderedElement } = require("./svg/render"); + +const focusableFormElements = new Set(["input", "select", "textarea", "button"]); + +// https://html.spec.whatwg.org/multipage/interaction.html#focusable-area, but also some of +// https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps and some of +// https://svgwg.org/svg2-draft/interact.html#TermFocusable +exports.isFocusableAreaElement = elImpl => { + // We implemented most of the suggested focusable elements found here: + // https://html.spec.whatwg.org/multipage/interaction.html#tabindex-value + // However, some suggested elements are not focusable in web browsers, as detailed here: + // https://github.com/whatwg/html/issues/5490 + if (elImpl._namespaceURI === HTML_NS) { + if (!elImpl._ownerDocument._defaultView) { + return false; + } + + if (!elImpl.isConnected) { + return false; + } + + if (!Number.isNaN(parseInt(elImpl.getAttributeNS(null, "tabindex")))) { + return true; + } + + if (elImpl._localName === "iframe") { + return true; + } + + if (elImpl._localName === "a" && elImpl.hasAttributeNS(null, "href")) { + return true; + } + + if (elImpl._localName === "summary" && elImpl.parentNode && + elImpl.parentNode._localName === "details" && + elImpl === firstChildWithLocalName(elImpl.parentNode, "summary")) { + return true; + } + + if (focusableFormElements.has(elImpl._localName) && !isDisabled(elImpl)) { + if (elImpl._localName === "input" && elImpl.type === "hidden") { + return false; + } + + return true; + } + + if (elImpl.hasAttributeNS(null, "contenteditable")) { + return true; + } + + return false; + + // This does not check for a designMode Document as specified in + // https://html.spec.whatwg.org/multipage/interaction.html#editing-host because the designMode + // attribute is not implemented. + } + + if (elImpl._namespaceURI === SVG_NS) { + if (!Number.isNaN(parseInt(elImpl.getAttributeNS(null, "tabindex"))) && isRenderedElement(elImpl)) { + return true; + } + + if (elImpl._localName === "a" && elImpl.hasAttributeNS(null, "href")) { + return true; + } + + return false; + } + + return false; +}; + +// https://html.spec.whatwg.org/multipage/interaction.html#fire-a-focus-event plus the steps of +// https://html.spec.whatwg.org/multipage/interaction.html#focus-update-steps that adjust Documents to Windows +// It's extended with the bubbles option to also handle focusin/focusout, which are "defined" in +// https://w3c.github.io/uievents/#event-type-focusin. See https://github.com/whatwg/html/issues/3514. +exports.fireFocusEventWithTargetAdjustment = (name, target, relatedTarget, { bubbles = false } = {}) => { + if (target === null) { + // E.g. firing blur with nothing previously focused. + return; + } + + const event = createAnEvent(name, target._globalObject, FocusEvent, { + bubbles, + composed: true, + relatedTarget, + view: target._ownerDocument._defaultView, + detail: 0 + }); + + if (target._defaultView) { + target = idlUtils.implForWrapper(target._defaultView); + } + + target._dispatch(event); +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/form-controls.js b/node_modules/jsdom/lib/jsdom/living/helpers/form-controls.js new file mode 100644 index 0000000000000000000000000000000000000000..8dee41edb66e759c46410e599322bd1d9984ae32 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/form-controls.js @@ -0,0 +1,309 @@ +"use strict"; + +const { + isValidFloatingPointNumber, + isValidSimpleColor, + parseFloatingPointNumber, + stripLeadingAndTrailingASCIIWhitespace, + stripNewlines, + splitOnCommas +} = require("./strings"); +const { + isValidDateString, + isValidMonthString, + isValidTimeString, + isValidWeekString, + parseLocalDateAndTimeString, + serializeNormalizedDateAndTime +} = require("./dates-and-times"); +const whatwgURL = require("whatwg-url"); + +const NodeList = require("../generated/NodeList"); +const { domSymbolTree } = require("./internal-constants"); +const { closest, firstChildWithLocalName } = require("./traversal"); +const NODE_TYPE = require("../node-type"); +const { HTML_NS } = require("./namespaces"); + +// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-disabled +exports.isDisabled = formControl => { + if (formControl.localName === "button" || formControl.localName === "input" || formControl.localName === "select" || + formControl.localName === "textarea") { + if (formControl.hasAttributeNS(null, "disabled")) { + return true; + } + } + + let e = formControl.parentNode; + while (e) { + if (e.localName === "fieldset" && e.hasAttributeNS(null, "disabled")) { + const firstLegendElementChild = firstChildWithLocalName(e, "legend"); + if (!firstLegendElementChild || !firstLegendElementChild.contains(formControl)) { + return true; + } + } + e = e.parentNode; + } + + return false; +}; + +// https://html.spec.whatwg.org/multipage/forms.html#category-listed +const listedElements = new Set(["button", "fieldset", "input", "object", "output", "select", "textarea"]); +exports.isListed = formControl => listedElements.has(formControl._localName) && formControl.namespaceURI === HTML_NS; + +// https://html.spec.whatwg.org/multipage/forms.html#category-submit +const submittableElements = new Set(["button", "input", "object", "select", "textarea"]); +exports.isSubmittable = formControl => { + return submittableElements.has(formControl._localName) && formControl.namespaceURI === HTML_NS; +}; + +// https://html.spec.whatwg.org/multipage/forms.html#concept-submit-button +const submitButtonInputTypes = new Set(["submit", "image"]); +exports.isSubmitButton = formControl => { + return ((formControl._localName === "input" && submitButtonInputTypes.has(formControl.type)) || + (formControl._localName === "button" && formControl.type === "submit")) && + formControl.namespaceURI === HTML_NS; +}; + +// https://html.spec.whatwg.org/multipage/forms.html#concept-button +const buttonInputTypes = new Set([...submitButtonInputTypes, "reset", "button"]); +exports.isButton = formControl => { + return ((formControl._localName === "input" && buttonInputTypes.has(formControl.type)) || + formControl._localName === "button") && + formControl.namespaceURI === HTML_NS; +}; + +// https://html.spec.whatwg.org/multipage/dom.html#interactive-content-2 +exports.isInteractiveContent = node => { + if (node.nodeType !== NODE_TYPE.ELEMENT_NODE) { + return false; + } + if (node.namespaceURI !== HTML_NS) { + return false; + } + if (node.hasAttributeNS(null, "tabindex")) { + return true; + } + switch (node.localName) { + case "a": + return node.hasAttributeNS(null, "href"); + + case "audio": + case "video": + return node.hasAttributeNS(null, "controls"); + + case "img": + case "object": + return node.hasAttributeNS(null, "usemap"); + + case "input": + return node.type !== "hidden"; + + case "button": + case "details": + case "embed": + case "iframe": + case "label": + case "select": + case "textarea": + return true; + } + + return false; +}; + +// https://html.spec.whatwg.org/multipage/forms.html#category-label +exports.isLabelable = node => { + if (node.nodeType !== NODE_TYPE.ELEMENT_NODE) { + return false; + } + if (node.namespaceURI !== HTML_NS) { + return false; + } + switch (node.localName) { + case "button": + case "meter": + case "output": + case "progress": + case "select": + case "textarea": + return true; + + case "input": + return node.type !== "hidden"; + } + if (node._ceDefinition?.formAssociated) { + return true; + } + + return false; +}; + +exports.getLabelsForLabelable = labelable => { + if (!exports.isLabelable(labelable)) { + return null; + } + if (!labelable._labels) { + const root = labelable.getRootNode({}); + labelable._labels = NodeList.createImpl(root._globalObject, [], { + element: root, + query: () => { + const nodes = []; + for (const descendant of domSymbolTree.treeIterator(root)) { + if (descendant.control === labelable) { + nodes.push(descendant); + } + } + return nodes; + } + }); + } + return labelable._labels; +}; + +// https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address +exports.isValidEmailAddress = (emailAddress, multiple = false) => { + const emailAddressRegExp = new RegExp("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9]" + + "(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}" + + "[a-zA-Z0-9])?)*$"); + // A valid e-mail address list is a set of comma-separated tokens, where each token is itself + // a valid e - mail address.To obtain the list of tokens from a valid e - mail address list, + // an implementation must split the string on commas. + if (multiple) { + return splitOnCommas(emailAddress).every(value => emailAddressRegExp.test(value)); + } + return emailAddressRegExp.test(emailAddress); +}; + +exports.isValidAbsoluteURL = url => { + return whatwgURL.parseURL(url) !== null; +}; + +exports.sanitizeValueByType = (input, val) => { + switch (input.type.toLowerCase()) { + case "password": + case "search": + case "tel": + case "text": + val = stripNewlines(val); + break; + + case "color": + // https://html.spec.whatwg.org/multipage/forms.html#color-state-(type=color):value-sanitization-algorithm + val = isValidSimpleColor(val) ? val.toLowerCase() : "#000000"; + break; + + case "date": + // https://html.spec.whatwg.org/multipage/input.html#date-state-(type=date):value-sanitization-algorithm + if (!isValidDateString(val)) { + val = ""; + } + break; + + case "datetime-local": { + // https://html.spec.whatwg.org/multipage/input.html#local-date-and-time-state-(type=datetime-local):value-sanitization-algorithm + const dateAndTime = parseLocalDateAndTimeString(val); + val = dateAndTime !== null ? serializeNormalizedDateAndTime(dateAndTime) : ""; + break; + } + + case "email": + // https://html.spec.whatwg.org/multipage/forms.html#e-mail-state-(type=email):value-sanitization-algorithm + // https://html.spec.whatwg.org/multipage/forms.html#e-mail-state-(type=email):value-sanitization-algorithm-2 + if (input.hasAttributeNS(null, "multiple")) { + val = val.split(",").map(token => stripLeadingAndTrailingASCIIWhitespace(token)).join(","); + } else { + val = stripNewlines(val); + val = stripLeadingAndTrailingASCIIWhitespace(val); + } + break; + + case "month": + // https://html.spec.whatwg.org/multipage/input.html#month-state-(type=month):value-sanitization-algorithm + if (!isValidMonthString(val)) { + val = ""; + } + break; + + case "number": + // https://html.spec.whatwg.org/multipage/input.html#number-state-(type=number):value-sanitization-algorithm + // TODO: using parseFloatingPointNumber in addition to isValidFloatingPointNumber to pass number.html WPT. + // Possible spec bug. + if (!isValidFloatingPointNumber(val) || parseFloatingPointNumber(val) === null) { + val = ""; + } + break; + + case "range": + // https://html.spec.whatwg.org/multipage/input.html#range-state-(type=range):value-sanitization-algorithm + // TODO: using parseFloatingPointNumber in addition to isValidFloatingPointNumber to pass number.html WPT. + // Possible spec bug. + if (!isValidFloatingPointNumber(val) || parseFloatingPointNumber(val) === null) { + const minimum = input._minimum; + const maximum = input._maximum; + const defaultValue = maximum < minimum ? minimum : (minimum + maximum) / 2; + val = `${defaultValue}`; + } else if (val < input._minimum) { + val = `${input._minimum}`; + } else if (val > input._maximum) { + val = `${input._maximum}`; + } + break; + + case "time": + // https://html.spec.whatwg.org/multipage/input.html#time-state-(type=time):value-sanitization-algorithm + if (!isValidTimeString(val)) { + val = ""; + } + break; + + case "url": + // https://html.spec.whatwg.org/multipage/forms.html#url-state-(type=url):value-sanitization-algorithm + val = stripNewlines(val); + val = stripLeadingAndTrailingASCIIWhitespace(val); + break; + + case "week": + // https://html.spec.whatwg.org/multipage/input.html#week-state-(type=week):value-sanitization-algorithm + if (!isValidWeekString(val)) { + val = ""; + } + } + + return val; +}; + +// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-owner +// TODO: The spec describes an imperative process for assigning/resetting an element's form +// owner based on activities involving form-associated elements. This simpler implementation +// instead calculates the current form owner only when the property is accessed. This is not +// sufficient to pass all the web platform tests, but is good enough for most purposes. We +// should eventually update it to use the correct version, though. See +// https://github.com/whatwg/html/issues/4050 for some discussion. + +exports.formOwner = formControl => { + const formAttr = formControl.getAttributeNS(null, "form"); + if (formAttr === "") { + return null; + } + if (formAttr === null) { + return closest(formControl, "form"); + } + + const root = formControl.getRootNode({}); + let firstElementWithId; + for (const descendant of domSymbolTree.treeIterator(root)) { + if (descendant.nodeType === NODE_TYPE.ELEMENT_NODE && + descendant.getAttributeNS(null, "id") === formAttr) { + firstElementWithId = descendant; + break; + } + } + + if (firstElementWithId && + firstElementWithId.namespaceURI === HTML_NS && + firstElementWithId.localName === "form") { + return firstElementWithId; + } + return null; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/html-constructor.js b/node_modules/jsdom/lib/jsdom/living/helpers/html-constructor.js new file mode 100644 index 0000000000000000000000000000000000000000..5543aa7ee86214f55ebe7ef3e05a7238a0a56673 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/html-constructor.js @@ -0,0 +1,78 @@ +"use strict"; + +const { HTML_NS } = require("./namespaces"); +const { createElement, getValidTagNames } = require("./create-element"); + +const { implForWrapper, wrapperForImpl } = require("../generated/utils"); + +// https://html.spec.whatwg.org/multipage/custom-elements.html#concept-already-constructed-marker +const ALREADY_CONSTRUCTED_MARKER = Symbol("already-constructed-marker"); + +// https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor +function HTMLConstructor(globalObject, constructorName, newTarget) { + const registry = implForWrapper(globalObject._customElementRegistry); + if (newTarget === HTMLConstructor) { + throw new TypeError("Invalid constructor"); + } + + const definition = registry._customElementDefinitions.find(entry => entry.objectReference === newTarget); + if (definition === undefined) { + throw new TypeError("Invalid constructor, the constructor is not part of the custom element registry"); + } + + let isValue = null; + + if (definition.localName === definition.name) { + if (constructorName !== "HTMLElement") { + throw new TypeError("Invalid constructor, autonomous custom element should extend from HTMLElement"); + } + } else { + const validLocalNames = getValidTagNames(HTML_NS, constructorName); + if (!validLocalNames.includes(definition.localName)) { + throw new TypeError(`${definition.localName} is not valid local name for ${constructorName}`); + } + + isValue = definition.name; + } + + let { prototype } = newTarget; + + if (prototype === null || typeof prototype !== "object") { + // The following line deviates from the specification. The HTMLElement prototype should be retrieved from the realm + // associated with the "new.target". Because it is impossible to get such information in jsdom, we fallback to the + // HTMLElement prototype associated with the current object. + prototype = globalObject.HTMLElement.prototype; + } + + if (definition.constructionStack.length === 0) { + const documentImpl = implForWrapper(globalObject.document); + + const elementImpl = createElement(documentImpl, definition.localName, HTML_NS); + + const element = wrapperForImpl(elementImpl); + Object.setPrototypeOf(element, prototype); + + elementImpl._ceState = "custom"; + elementImpl._ceDefinition = definition; + elementImpl._isValue = isValue; + + return element; + } + + const elementImpl = definition.constructionStack[definition.constructionStack.length - 1]; + const element = wrapperForImpl(elementImpl); + + if (elementImpl === ALREADY_CONSTRUCTED_MARKER) { + throw new TypeError("This instance is already constructed"); + } + + Object.setPrototypeOf(element, prototype); + + definition.constructionStack[definition.constructionStack.length - 1] = ALREADY_CONSTRUCTED_MARKER; + + return element; +} + +module.exports = { + HTMLConstructor +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/http-request.js b/node_modules/jsdom/lib/jsdom/living/helpers/http-request.js new file mode 100644 index 0000000000000000000000000000000000000000..574013ae002e35d8565f6ce42239a673a1c760bc --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/http-request.js @@ -0,0 +1,266 @@ +"use strict"; +const http = require("http"); +const https = require("https"); +const { Writable } = require("stream"); +const zlib = require("zlib"); + +const ver = process.version.replace("v", "").split("."); +const majorNodeVersion = Number.parseInt(ver[0]); + +function abortRequest(clientRequest) { + clientRequest.destroy(); + clientRequest.removeAllListeners(); + clientRequest.on("error", () => {}); +} + +module.exports = class Request extends Writable { + constructor(url, clientOptions, requestOptions) { + super(); + Object.assign(this, clientOptions); + this.currentURL = url; + this._requestOptions = requestOptions; + this.headers = requestOptions.headers; + this._ended = false; + this._redirectCount = 0; + this._requestBodyBuffers = []; + this._bufferIndex = 0; + this._performRequest(); + } + + abort() { + abortRequest(this._currentRequest); + this.emit("abort"); + this.removeAllListeners(); + } + + pipeRequest(form) { + form.pipe(this._currentRequest); + } + + write(data, encoding) { + if (data.length > 0) { + this._requestBodyBuffers.push({ data, encoding }); + this._currentRequest.write(data, encoding); + } + } + + end() { + this.emit("request", this._currentRequest); + this._ended = true; + this._currentRequest.end(); + } + + setHeader(name, value) { + this.headers[name] = value; + this._currentRequest.setHeader(name, value); + } + + removeHeader(name) { + delete this.headers[name]; + this._currentRequest.removeHeader(name); + } + + // Without this method, the test send-redirect-infinite-sync will halt the test suite + // TODO: investigate this further and ideally remove + toJSON() { + const { method, headers } = this._requestOptions; + return { uri: new URL(this.currentURL), method, headers }; + } + + _writeNext(error) { + if (this._currentRequest) { + if (error) { + this.emit("error", error); + } else if (this._bufferIndex < this._requestBodyBuffers.length) { + const buffer = this._requestBodyBuffers[this._bufferIndex++]; + if (!this._currentRequest.writableEnded) { + this._currentRequest.write( + buffer.data, + buffer.encoding, + this._writeNext.bind(this) + ); + } + } else if (this._ended) { + this._currentRequest.end(); + } + } + } + + _performRequest() { + const urlOptions = new URL(this.currentURL); + const scheme = urlOptions.protocol; + + // browserify's (http|https).request() does not work correctly with the (url, options, callback) signature. Instead + // we need to have options for each of the URL components. Note that we can't use the spread operator because URL + // instances don't have own properties for the URL components. + const requestOptions = { + ...this._requestOptions, + agent: this.agents[scheme.substring(0, scheme.length - 1)], + protocol: urlOptions.protocol, + hostname: urlOptions.hostname, + port: urlOptions.port, + path: urlOptions.pathname + urlOptions.search + }; + + const { request } = scheme === "https:" ? https : http; + this._currentRequest = request(requestOptions, response => { + this._processResponse(response); + }); + + let cookies; + if (this._redirectCount === 0) { + this.originalCookieHeader = this.getHeader("Cookie"); + } + if (this.cookieJar) { + cookies = this.cookieJar.getCookieStringSync(this.currentURL); + } + if (cookies && cookies.length) { + if (this.originalCookieHeader) { + this.setHeader("Cookie", this.originalCookieHeader + "; " + cookies); + } else { + this.setHeader("Cookie", cookies); + } + } + + for (const event of ["connect", "error", "socket", "timeout"]) { + this._currentRequest.on(event, (...args) => { + this.emit(event, ...args); + }); + } + if (this._isRedirect) { + this._bufferIndex = 0; + this._writeNext(); + } + } + + _processResponse(response) { + const cookies = response.headers["set-cookie"]; + if (this.cookieJar && Array.isArray(cookies)) { + try { + cookies.forEach(cookie => { + this.cookieJar.setCookieSync(cookie, this.currentURL, { ignoreError: true }); + }); + } catch (e) { + this.emit("error", e); + } + } + + const { statusCode } = response; + const { location } = response.headers; + // In Node v15, aborting a message with remaining data causes an error to be thrown, + // hence the version check + const catchResErrors = err => { + if (!(majorNodeVersion >= 15 && err.message === "aborted")) { + this.emit("error", err); + } + }; + response.on("error", catchResErrors); + let redirectAddress = null; + let resendWithAuth = false; + if (typeof location === "string" && + location.length && + this.followRedirects && + statusCode >= 300 && + statusCode < 400) { + redirectAddress = location; + } else if (statusCode === 401 && + /^Basic /i.test(response.headers["www-authenticate"] || "") && + (this.user && this.user.length)) { + this._requestOptions.auth = `${this.user}:${this.pass}`; + resendWithAuth = true; + } + if (redirectAddress || resendWithAuth) { + if (++this._redirectCount > 21) { + const redirectError = new Error("Maximum number of redirects exceeded"); + redirectError.code = "ERR_TOO_MANY_REDIRECTS"; + this.emit("error", redirectError); + return; + } + abortRequest(this._currentRequest); + response.destroy(); + this._isRedirect = true; + if (((statusCode === 301 || statusCode === 302) && this._requestOptions.method === "POST") || + (statusCode === 303 && !/^(?:GET|HEAD)$/.test(this._requestOptions.method))) { + this._requestOptions.method = "GET"; + this._requestBodyBuffers = []; + } + let previousHostName = this._removeMatchingHeaders(/^host$/i); + if (!previousHostName) { + previousHostName = new URL(this.currentURL).hostname; + } + const previousURL = this.currentURL; + if (!resendWithAuth) { + let nextURL; + try { + nextURL = new URL(redirectAddress, this.currentURL); + } catch (e) { + this.emit("error", e); + return; + } + + if (nextURL.hostname !== previousHostName) { + this._removeMatchingHeaders(/^authorization$/i); + } + this.currentURL = nextURL.toString(); + } + this.headers.Referer = previousURL; + this.emit("redirect", response, this.headers, this.currentURL); + try { + this._performRequest(); + } catch (cause) { + this.emit("error", cause); + } + } else { + let pipeline = response; + const acceptEncoding = this.headers["Accept-Encoding"]; + const requestCompressed = typeof acceptEncoding === "string" && + (acceptEncoding.includes("gzip") || acceptEncoding.includes("deflate")); + if ( + requestCompressed && + this._requestOptions.method !== "HEAD" && + statusCode >= 200 && + statusCode !== 204 && + statusCode !== 304 + ) { + // Browserify's zlib does not support zlib.constants. + const zlibOptions = { + flush: (zlib.constants ?? zlib).Z_SYNC_FLUSH, + finishFlush: (zlib.constants ?? zlib).Z_SYNC_FLUSH + }; + const contentEncoding = (response.headers["content-encoding"] || "identity").trim().toLowerCase(); + if (contentEncoding === "gzip") { + pipeline = zlib.createGunzip(zlibOptions); + response.pipe(pipeline); + } else if (contentEncoding === "deflate") { + pipeline = zlib.createInflate(zlibOptions); + response.pipe(pipeline); + } + } + pipeline.removeAllListeners("error"); + this.emit("response", response, this.currentURL); + pipeline.on("data", bytes => this.emit("data", bytes)); + pipeline.once("end", bytes => this.emit("end", bytes)); + pipeline.on("error", catchResErrors); + pipeline.on("close", () => this.emit("close")); + this._requestBodyBuffers = []; + } + } + + getHeader(key, value) { + if (this._currentRequest) { + return this._currentRequest.getHeader(key, value); + } + return null; + } + + _removeMatchingHeaders(regex) { + let lastValue; + for (const header in this.headers) { + if (regex.test(header)) { + lastValue = this.headers[header]; + delete this.headers[header]; + } + } + return lastValue; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/internal-constants.js b/node_modules/jsdom/lib/jsdom/living/helpers/internal-constants.js new file mode 100644 index 0000000000000000000000000000000000000000..707add9d8f182435771d436d3642d109cef04d8c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/internal-constants.js @@ -0,0 +1,12 @@ +"use strict"; +const SymbolTree = require("symbol-tree"); + +exports.cloningSteps = Symbol("cloning steps"); + +// TODO: the many underscore-prefixed hooks should move here +// E.g. _attrModified (which maybe should be split into its per-spec variants) + +/** + * This SymbolTree is used to build the tree for all Node in a document + */ +exports.domSymbolTree = new SymbolTree("DOM SymbolTree"); diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/is-window.js b/node_modules/jsdom/lib/jsdom/living/helpers/is-window.js new file mode 100644 index 0000000000000000000000000000000000000000..a05deb7d5ebe720037edd01c93997b9264e237cb --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/is-window.js @@ -0,0 +1,18 @@ +"use strict"; +const idlUtils = require("../generated/utils"); + +// Until webidl2js gains support for checking for Window, this would have to do. +module.exports = val => { + if (typeof val !== "object") { + return false; + } + const wrapper = idlUtils.wrapperForImpl(val); + if (typeof wrapper === "object") { + return wrapper === wrapper._globalProxy; + } + + // `val` may be either impl or wrapper currently, because webidl2js currently unwraps Window objects (and their global + // proxies) to their underlying EventTargetImpl during conversion, which is not what we want. But at the same time, + // some internal usage call this constructor with the actual global proxy. + return module.exports(idlUtils.implForWrapper(val)); +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/iterable-weak-set.js b/node_modules/jsdom/lib/jsdom/living/helpers/iterable-weak-set.js new file mode 100644 index 0000000000000000000000000000000000000000..9d5e1670c5ed9d5279688f104ab1f621eed9d633 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/iterable-weak-set.js @@ -0,0 +1,48 @@ +"use strict"; + +// An iterable WeakSet implementation inspired by the iterable WeakMap example code in the WeakRefs specification: +// https://github.com/tc39/proposal-weakrefs#iterable-weakmaps +module.exports = class IterableWeakSet { + constructor() { + this._refSet = new Set(); + this._refMap = new WeakMap(); + this._finalizationRegistry = new FinalizationRegistry(({ ref, set }) => set.delete(ref)); + } + + add(value) { + if (!this._refMap.has(value)) { + const ref = new WeakRef(value); + this._refMap.set(value, ref); + this._refSet.add(ref); + this._finalizationRegistry.register(value, { ref, set: this._refSet }, ref); + } + + return this; + } + + delete(value) { + const ref = this._refMap.get(value); + if (!ref) { + return false; + } + + this._refMap.delete(value); + this._refSet.delete(ref); + this._finalizationRegistry.unregister(ref); + return true; + } + + has(value) { + return this._refMap.has(value); + } + + * [Symbol.iterator]() { + for (const ref of this._refSet) { + const value = ref.deref(); + if (value === undefined) { + continue; + } + yield value; + } + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/json.js b/node_modules/jsdom/lib/jsdom/living/helpers/json.js new file mode 100644 index 0000000000000000000000000000000000000000..6920bc2ece55cbc3de07b08641a2e0ea97fb93ae --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/json.js @@ -0,0 +1,12 @@ +"use strict"; + +// https://infra.spec.whatwg.org/#parse-json-from-bytes +exports.parseJSONFromBytes = bytes => { + // https://encoding.spec.whatwg.org/#utf-8-decode + if (bytes[0] === 0xEF && bytes[1] === 0xBB && bytes[2] === 0xBF) { + bytes = bytes.subarray(3); + } + const jsonText = bytes.toString("utf-8"); + + return JSON.parse(jsonText); +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/mutation-observers.js b/node_modules/jsdom/lib/jsdom/living/helpers/mutation-observers.js new file mode 100644 index 0000000000000000000000000000000000000000..c1c92097d6223bc26cd56edc5a5df95a372e8433 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/mutation-observers.js @@ -0,0 +1,198 @@ +"use strict"; + +const { domSymbolTree } = require("./internal-constants"); +const reportException = require("./runtime-script-errors"); + +const Event = require("../generated/Event"); +const idlUtils = require("../generated/utils"); +const MutationRecord = require("../generated/MutationRecord"); + +const MUTATION_TYPE = { + ATTRIBUTES: "attributes", + CHARACTER_DATA: "characterData", + CHILD_LIST: "childList" +}; + +// Note: +// Since jsdom doesn't currently implement the concept of "unit of related similar-origin browsing contexts" +// (https://html.spec.whatwg.org/multipage/browsers.html#unit-of-related-similar-origin-browsing-contexts) +// we will approximate that the following properties are global for now. + +// https://dom.spec.whatwg.org/#mutation-observer-compound-microtask-queued-flag +let mutationObserverMicrotaskQueueFlag = false; + +// Non-spec compliant: List of all the mutation observers with mutation records enqueued. It's a replacement for +// mutation observer list (https://dom.spec.whatwg.org/#mutation-observer-list) but without leaking since it's empty +// before notifying the mutation observers. +const activeMutationObservers = new Set(); + +// https://dom.spec.whatwg.org/#signal-slot-list +const signalSlotList = []; + +// https://dom.spec.whatwg.org/#queue-a-mutation-record +function queueMutationRecord( + type, + target, + name, + namespace, + oldValue, + addedNodes, + removedNodes, + previousSibling, + nextSibling +) { + const interestedObservers = new Map(); + + const nodes = domSymbolTree.ancestorsToArray(target); + + for (const node of nodes) { + for (const registered of node._registeredObserverList) { + const { options, observer: mo } = registered; + + if ( + !(node !== target && options.subtree === false) && + !(type === MUTATION_TYPE.ATTRIBUTES && options.attributes !== true) && + !(type === MUTATION_TYPE.ATTRIBUTES && options.attributeFilter && + !options.attributeFilter.some(value => value === name || value === namespace)) && + !(type === MUTATION_TYPE.CHARACTER_DATA && options.characterData !== true) && + !(type === MUTATION_TYPE.CHILD_LIST && options.childList === false) + ) { + if (!interestedObservers.has(mo)) { + interestedObservers.set(mo, null); + } + + if ( + (type === MUTATION_TYPE.ATTRIBUTES && options.attributeOldValue === true) || + (type === MUTATION_TYPE.CHARACTER_DATA && options.characterDataOldValue === true) + ) { + interestedObservers.set(mo, oldValue); + } + } + } + } + + for (const [observer, mappedOldValue] of interestedObservers.entries()) { + const record = MutationRecord.createImpl(target._globalObject, [], { + type, + target, + attributeName: name, + attributeNamespace: namespace, + oldValue: mappedOldValue, + addedNodes, + removedNodes, + previousSibling, + nextSibling + }); + + observer._recordQueue.push(record); + activeMutationObservers.add(observer); + } + + queueMutationObserverMicrotask(); +} + +// https://dom.spec.whatwg.org/#queue-a-tree-mutation-record +function queueTreeMutationRecord(target, addedNodes, removedNodes, previousSibling, nextSibling) { + queueMutationRecord( + MUTATION_TYPE.CHILD_LIST, + target, + null, + null, + null, + addedNodes, + removedNodes, + previousSibling, + nextSibling + ); +} + +// https://dom.spec.whatwg.org/#queue-an-attribute-mutation-record +function queueAttributeMutationRecord(target, name, namespace, oldValue) { + queueMutationRecord( + MUTATION_TYPE.ATTRIBUTES, + target, + name, + namespace, + oldValue, + [], + [], + null, + null + ); +} + +// https://dom.spec.whatwg.org/#queue-a-mutation-observer-compound-microtask +function queueMutationObserverMicrotask() { + if (mutationObserverMicrotaskQueueFlag) { + return; + } + + mutationObserverMicrotaskQueueFlag = true; + + Promise.resolve().then(() => { + notifyMutationObservers(); + }); +} + +// https://dom.spec.whatwg.org/#notify-mutation-observers +function notifyMutationObservers() { + mutationObserverMicrotaskQueueFlag = false; + + const notifyList = [...activeMutationObservers].sort((a, b) => a._id - b._id); + activeMutationObservers.clear(); + + const signalList = [...signalSlotList]; + signalSlotList.splice(0, signalSlotList.length); + + for (const mo of notifyList) { + const records = [...mo._recordQueue]; + mo._recordQueue = []; + + for (const node of mo._nodeList) { + node._registeredObserverList = node._registeredObserverList.filter(registeredObserver => { + return registeredObserver.source !== mo; + }); + } + + if (records.length > 0) { + try { + const moWrapper = idlUtils.wrapperForImpl(mo); + mo._callback.call( + moWrapper, + records.map(idlUtils.wrapperForImpl), + moWrapper + ); + } catch (e) { + const { target } = records[0]; + const window = target._ownerDocument._defaultView; + + reportException(window, e); + } + } + } + + for (const slot of signalList) { + const slotChangeEvent = Event.createImpl( + slot._globalObject, + [ + "slotchange", + { bubbles: true } + ], + { isTrusted: true } + ); + + slot._dispatch(slotChangeEvent); + } +} + +module.exports = { + MUTATION_TYPE, + + queueMutationRecord, + queueTreeMutationRecord, + queueAttributeMutationRecord, + + queueMutationObserverMicrotask, + + signalSlotList +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/namespaces.js b/node_modules/jsdom/lib/jsdom/living/helpers/namespaces.js new file mode 100644 index 0000000000000000000000000000000000000000..bf0611fdd9df249bdcb2118e99c012701685883c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/namespaces.js @@ -0,0 +1,16 @@ +"use strict"; +// Do not require generated files from here, as this file is shared with the Web IDL converter. + +// https://infra.spec.whatwg.org/#namespaces + +exports.HTML_NS = "http://www.w3.org/1999/xhtml"; + +exports.MATHML_NS = "http://www.w3.org/1998/Math/MathML"; + +exports.SVG_NS = "http://www.w3.org/2000/svg"; + +exports.XLINK_NS = "http://www.w3.org/1999/xlink"; + +exports.XML_NS = "http://www.w3.org/XML/1998/namespace"; + +exports.XMLNS_NS = "http://www.w3.org/2000/xmlns/"; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/node.js b/node_modules/jsdom/lib/jsdom/living/helpers/node.js new file mode 100644 index 0000000000000000000000000000000000000000..40e12bcb3084e11d8bbc30a624a47c3b01be71a7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/node.js @@ -0,0 +1,68 @@ +"use strict"; + +const NODE_TYPE = require("../node-type"); +const { domSymbolTree } = require("./internal-constants"); + +// https://dom.spec.whatwg.org/#concept-node-length +function nodeLength(node) { + switch (node.nodeType) { + case NODE_TYPE.DOCUMENT_TYPE_NODE: + return 0; + + case NODE_TYPE.TEXT_NODE: + case NODE_TYPE.PROCESSING_INSTRUCTION_NODE: + case NODE_TYPE.COMMENT_NODE: + return node.data.length; + + default: + return domSymbolTree.childrenCount(node); + } +} + +// https://dom.spec.whatwg.org/#concept-tree-root +function nodeRoot(node) { + while (domSymbolTree.parent(node)) { + node = domSymbolTree.parent(node); + } + + return node; +} + +// https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor +function isInclusiveAncestor(ancestorNode, node) { + while (node) { + if (ancestorNode === node) { + return true; + } + + node = domSymbolTree.parent(node); + } + + return false; +} + +// https://dom.spec.whatwg.org/#concept-tree-following +function isFollowing(nodeA, nodeB) { + if (nodeA === nodeB) { + return false; + } + + let current = nodeB; + while (current) { + if (current === nodeA) { + return true; + } + + current = domSymbolTree.following(current); + } + + return false; +} + +module.exports = { + nodeLength, + nodeRoot, + + isInclusiveAncestor, + isFollowing +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/number-and-date-inputs.js b/node_modules/jsdom/lib/jsdom/living/helpers/number-and-date-inputs.js new file mode 100644 index 0000000000000000000000000000000000000000..e29bc7428e7f93955a073347672b8a5ca52f2be5 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/number-and-date-inputs.js @@ -0,0 +1,195 @@ +"use strict"; +const { parseFloatingPointNumber } = require("./strings"); +const { + parseDateString, + parseLocalDateAndTimeString, + parseMonthString, + parseTimeString, + parseWeekString, + + serializeDate, + serializeMonth, + serializeNormalizedDateAndTime, + serializeTime, + serializeWeek, + parseDateAsWeek +} = require("./dates-and-times"); + +// Necessary because Date.UTC() treats year within [0, 99] as [1900, 1999]. +function getUTCMs(year, month = 1, day = 1, hour = 0, minute = 0, second = 0, millisecond = 0) { + if (year > 99 || year < 0) { + return Date.UTC(year, month - 1, day, hour, minute, second, millisecond); + } + const d = new Date(0); + d.setUTCFullYear(year); + d.setUTCMonth(month - 1); + d.setUTCDate(day); + d.setUTCHours(hour); + d.setUTCMinutes(minute); + d.setUTCSeconds(second, millisecond); + return d.valueOf(); +} + +const dayOfWeekRelMondayLUT = [-1, 0, 1, 2, 3, -3, -2]; + +exports.convertStringToNumberByType = { + // https://html.spec.whatwg.org/multipage/input.html#date-state-(type=date):concept-input-value-string-number + date(input) { + const date = parseDateString(input); + if (date === null) { + return null; + } + return getUTCMs(date.year, date.month, date.day); + }, + // https://html.spec.whatwg.org/multipage/input.html#month-state-(type=month):concept-input-value-string-number + month(input) { + const date = parseMonthString(input); + if (date === null) { + return null; + } + return (date.year - 1970) * 12 + (date.month - 1); + }, + // https://html.spec.whatwg.org/multipage/input.html#week-state-(type=week):concept-input-value-string-number + week(input) { + const date = parseWeekString(input); + if (date === null) { + return null; + } + const dateObj = new Date(getUTCMs(date.year)); + // An HTML week starts on Monday, while 0 represents Sunday. Account for such. + const dayOfWeekRelMonday = dayOfWeekRelMondayLUT[dateObj.getUTCDay()]; + return dateObj.setUTCDate(1 + 7 * (date.week - 1) - dayOfWeekRelMonday); + }, + // https://html.spec.whatwg.org/multipage/input.html#time-state-(type=time):concept-input-value-string-number + time(input) { + const time = parseTimeString(input); + if (time === null) { + return null; + } + return ((time.hour * 60 + time.minute) * 60 + time.second) * 1000 + time.millisecond; + }, + // https://html.spec.whatwg.org/multipage/input.html#local-date-and-time-state-(type=datetime-local):concept-input-value-string-number + "datetime-local"(input) { + const dateAndTime = parseLocalDateAndTimeString(input); + if (dateAndTime === null) { + return null; + } + const { date: { year, month, day }, time: { hour, minute, second, millisecond } } = dateAndTime; + // Doesn't quite matter whether or not UTC is used, since the offset from 1970-01-01 local time is returned. + return getUTCMs(year, month, day, hour, minute, second, millisecond); + }, + // https://html.spec.whatwg.org/multipage/input.html#number-state-(type=number):concept-input-value-string-number + number: parseFloatingPointNumber, + // https://html.spec.whatwg.org/multipage/input.html#range-state-(type=range):concept-input-value-string-number + range: parseFloatingPointNumber +}; + +exports.convertStringToDateByType = { + date(input) { + const parsedInput = exports.convertStringToNumberByType.date(input); + return parsedInput === null ? null : new Date(parsedInput); + }, + // https://html.spec.whatwg.org/multipage/input.html#month-state-(type=month):concept-input-value-string-number + month(input) { + const parsedMonthString = parseMonthString(input); + if (parsedMonthString === null) { + return null; + } + + const date = new Date(0); + date.setUTCFullYear(parsedMonthString.year); + date.setUTCMonth(parsedMonthString.month - 1); + return date; + }, + week(input) { + const parsedInput = exports.convertStringToNumberByType.week(input); + return parsedInput === null ? null : new Date(parsedInput); + }, + time(input) { + const parsedInput = exports.convertStringToNumberByType.time(input); + return parsedInput === null ? null : new Date(parsedInput); + }, + "datetime-local"(input) { + const parsedInput = exports.convertStringToNumberByType["datetime-local"](input); + return parsedInput === null ? null : new Date(parsedInput); + } +}; + +exports.serializeDateByType = { + date(input) { + return serializeDate({ + year: input.getUTCFullYear(), + month: input.getUTCMonth() + 1, + day: input.getUTCDate() + }); + }, + month(input) { + return serializeMonth({ + year: input.getUTCFullYear(), + month: input.getUTCMonth() + 1 + }); + }, + week(input) { + return serializeWeek(parseDateAsWeek(input)); + }, + time(input) { + return serializeTime({ + hour: input.getUTCHours(), + minute: input.getUTCMinutes(), + second: input.getUTCSeconds(), + millisecond: input.getUTCMilliseconds() + }); + }, + "datetime-local"(input) { + return serializeNormalizedDateAndTime({ + date: { + year: input.getUTCFullYear(), + month: input.getUTCMonth() + 1, + day: input.getUTCDate() + }, + time: { + hour: input.getUTCHours(), + minute: input.getUTCMinutes(), + second: input.getUTCSeconds(), + millisecond: input.getUTCMilliseconds() + } + }); + } +}; + +exports.convertNumberToStringByType = { + // https://html.spec.whatwg.org/multipage/input.html#date-state-(type=date):concept-input-value-string-number + date(input) { + return exports.serializeDateByType.date(new Date(input)); + }, + // https://html.spec.whatwg.org/multipage/input.html#month-state-(type=month):concept-input-value-string-date + month(input) { + const year = 1970 + Math.floor(input / 12); + const month = input % 12; + const date = new Date(0); + date.setUTCFullYear(year); + date.setUTCMonth(month); + + return exports.serializeDateByType.month(date); + }, + // https://html.spec.whatwg.org/multipage/input.html#week-state-(type=week):concept-input-value-string-date + week(input) { + return exports.serializeDateByType.week(new Date(input)); + }, + // https://html.spec.whatwg.org/multipage/input.html#time-state-(type=time):concept-input-value-string-date + time(input) { + return exports.serializeDateByType.time(new Date(input)); + }, + // https://html.spec.whatwg.org/multipage/input.html#local-date-and-time-state-(type=datetime-local):concept-input-value-number-string + "datetime-local"(input) { + return exports.serializeDateByType["datetime-local"](new Date(input)); + }, + // https://html.spec.whatwg.org/multipage/input.html#number-state-(type=number):concept-input-value-number-string + number(input) { + return input.toString(); + }, + // https://html.spec.whatwg.org/multipage/input.html#range-state-(type=range):concept-input-value-number-string + range(input) { + return input.toString(); + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/ordered-set.js b/node_modules/jsdom/lib/jsdom/living/helpers/ordered-set.js new file mode 100644 index 0000000000000000000000000000000000000000..d3e193209edc618256fda51729c92e59d08a7e1f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/ordered-set.js @@ -0,0 +1,104 @@ +"use strict"; + +// https://infra.spec.whatwg.org/#sets +// +// Only use this class if a Set cannot be used, e.g. when "replace" operation is needed, since there's no way to replace +// an element while keep the relative order using a Set, only remove and then add something at the end. + +module.exports = class OrderedSet { + constructor() { + this._items = []; + } + + append(item) { + if (!this.contains(item)) { + this._items.push(item); + } + } + + prepend(item) { + if (!this.contains(item)) { + this._items.unshift(item); + } + } + + replace(item, replacement) { + let seen = false; + for (let i = 0; i < this._items.length;) { + const isInstance = this._items[i] === item || this._items[i] === replacement; + if (seen && isInstance) { + this._items.splice(i, 1); + } else { + if (isInstance) { + this._items[i] = replacement; + seen = true; + } + i++; + } + } + } + + remove(...items) { + this.removePredicate(item => items.includes(item)); + } + + removePredicate(predicate) { + for (let i = 0; i < this._items.length;) { + if (predicate(this._items[i])) { + this._items.splice(i, 1); + } else { + i++; + } + } + } + + empty() { + this._items.length = 0; + } + + contains(item) { + return this._items.includes(item); + } + + get size() { + return this._items.length; + } + + isEmpty() { + return this._items.length === 0; + } + + // Useful for other parts of jsdom + + [Symbol.iterator]() { + return this._items[Symbol.iterator](); + } + + keys() { + return this._items.keys(); + } + + get(index) { + return this._items[index]; + } + + some(func) { + return this._items.some(func); + } + + // https://dom.spec.whatwg.org/#concept-ordered-set-parser + static parse(input) { + const tokens = new OrderedSet(); + for (const token of input.split(/[\t\n\f\r ]+/)) { + if (token) { + tokens.append(token); + } + } + return tokens; + } + + // https://dom.spec.whatwg.org/#concept-ordered-set-serializer + serialize() { + return this._items.join(" "); + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/page-transition-event.js b/node_modules/jsdom/lib/jsdom/living/helpers/page-transition-event.js new file mode 100644 index 0000000000000000000000000000000000000000..50c8be17052222c4b121cf573eaad3377d3de4d1 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/page-transition-event.js @@ -0,0 +1,9 @@ +"use strict"; +const PageTransitionEvent = require("../generated/PageTransitionEvent.js"); +const { fireAnEvent } = require("./events"); + +// https://html.spec.whatwg.org/multipage/browsing-the-web.html#fire-a-page-transition-event +exports.fireAPageTransitionEvent = (eventName, window, persisted) => { + const attributes = { persisted, cancelable: true, bubbles: true }; + fireAnEvent(eventName, window, PageTransitionEvent, attributes, true); +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js b/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js new file mode 100644 index 0000000000000000000000000000000000000000..98f5f9860ab5ddf8f7e8673e1e1036f34c9e8bd5 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js @@ -0,0 +1,75 @@ +"use strict"; +const util = require("util"); +const idlUtils = require("../generated/utils"); +const ErrorEvent = require("../generated/ErrorEvent"); +const { createAnEvent } = require("../helpers/events"); + +const errorReportingMode = Symbol("error reporting mode"); + +// https://html.spec.whatwg.org/multipage/webappapis.html#report-the-error +// Omits script parameter and any check for muted errors. +// Takes target as an EventTarget impl. +// Takes error object, message, and location as params, unlike the spec. +// Returns whether the event was handled or not. +function reportAnError(line, col, target, errorObject, message, location) { + if (target[errorReportingMode]) { + return false; + } + + target[errorReportingMode] = true; + + if (typeof message !== "string") { + message = "uncaught exception: " + util.inspect(errorObject); + } + + const event = createAnEvent("error", target._globalObject, ErrorEvent, { + cancelable: true, + message, + filename: location, + lineno: line, + colno: col, + error: errorObject + }); + + try { + target._dispatch(event); + } finally { + target[errorReportingMode] = false; + return event.defaultPrevented; + } +} + +module.exports = function reportException(window, error, filenameHint) { + // This function will give good results on real Error objects with stacks; poor ones otherwise + + const stack = error && error.stack; + const lines = stack && stack.split("\n"); + + // Find the first line that matches; important for multi-line messages + let pieces; + if (lines) { + for (let i = 1; i < lines.length && !pieces; ++i) { + pieces = lines[i].match(/at (?:(.+)\s+)?\(?(?:(.+?):(\d+):(\d+)|([^)]+))\)?/); + } + } + + const fileName = (pieces && pieces[2]) || filenameHint || window._document.URL; + const lineNumber = (pieces && parseInt(pieces[3])) || 0; + const columnNumber = (pieces && parseInt(pieces[4])) || 0; + + const windowImpl = idlUtils.implForWrapper(window); + + const handled = reportAnError(lineNumber, columnNumber, windowImpl, error, error && error.message, fileName); + + if (!handled) { + const errorString = shouldBeDisplayedAsError(error) ? `[${error.name}: ${error.message}]` : util.inspect(error); + const jsdomError = new Error(`Uncaught ${errorString}`, { cause: error }); + jsdomError.type = "unhandled-exception"; + + window._virtualConsole.emit("jsdomError", jsdomError); + } +}; + +function shouldBeDisplayedAsError(x) { + return x && x.name && x.message !== undefined && x.stack; +} diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/shadow-dom.js b/node_modules/jsdom/lib/jsdom/living/helpers/shadow-dom.js new file mode 100644 index 0000000000000000000000000000000000000000..a88a33ef3e618a8c33fc6d945611201f7c9ced02 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/shadow-dom.js @@ -0,0 +1,285 @@ +"use strict"; + +const NODE_TYPE = require("../node-type"); + +const { nodeRoot } = require("./node"); +const { HTML_NS } = require("./namespaces"); +const { domSymbolTree } = require("./internal-constants"); +const { signalSlotList, queueMutationObserverMicrotask } = require("./mutation-observers"); + +// Valid host element for ShadowRoot. +// Defined in: https://dom.spec.whatwg.org/#dom-element-attachshadow +const VALID_HOST_ELEMENT_NAME = new Set([ + "article", + "aside", + "blockquote", + "body", + "div", + "footer", + "h1", + "h2", + "h3", + "h4", + "h5", + "h6", + "header", + "main", + "nav", + "p", + "section", + "span" +]); + +function isValidHostElementName(name) { + return VALID_HOST_ELEMENT_NAME.has(name); +} + +// Use an approximation by checking the presence of nodeType instead of instead of using the isImpl from +// "../generated/Node" to avoid introduction of circular dependencies. +function isNode(nodeImpl) { + return Boolean(nodeImpl && "nodeType" in nodeImpl); +} + +// Use an approximation by checking the value of nodeType and presence of nodeType host instead of instead +// of using the isImpl from "../generated/ShadowRoot" to avoid introduction of circular dependencies. +function isShadowRoot(nodeImpl) { + return Boolean(nodeImpl && nodeImpl.nodeType === NODE_TYPE.DOCUMENT_FRAGMENT_NODE && "host" in nodeImpl); +} + +// https://dom.spec.whatwg.org/#concept-slotable +function isSlotable(nodeImpl) { + return nodeImpl && (nodeImpl.nodeType === NODE_TYPE.ELEMENT_NODE || nodeImpl.nodeType === NODE_TYPE.TEXT_NODE); +} + +function isSlot(nodeImpl) { + return nodeImpl && nodeImpl.localName === "slot" && nodeImpl._namespaceURI === HTML_NS; +} + +// https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-ancestor +function isShadowInclusiveAncestor(ancestor, node) { + while (isNode(node)) { + if (node === ancestor) { + return true; + } + + if (isShadowRoot(node)) { + node = node.host; + } else { + node = domSymbolTree.parent(node); + } + } + + return false; +} + +// https://dom.spec.whatwg.org/#retarget +function retarget(a, b) { + while (true) { + if (!isNode(a)) { + return a; + } + + const aRoot = nodeRoot(a); + if ( + !isShadowRoot(aRoot) || + (isNode(b) && isShadowInclusiveAncestor(aRoot, b)) + ) { + return a; + } + + a = nodeRoot(a).host; + } +} + +// https://dom.spec.whatwg.org/#get-the-parent +function getEventTargetParent(eventTarget, event) { + // _getTheParent will be missing for Window, since it doesn't have an impl class and we don't want to pollute the + // user-visible global scope with a _getTheParent value. TODO: remove this entire function and use _getTheParent + // directly, once Window gets split into impl/wrapper. + return eventTarget._getTheParent ? eventTarget._getTheParent(event) : null; +} + +// https://dom.spec.whatwg.org/#concept-shadow-including-root +function shadowIncludingRoot(node) { + const root = nodeRoot(node); + return isShadowRoot(root) ? shadowIncludingRoot(root.host) : root; +} + +// https://dom.spec.whatwg.org/#assign-a-slot +function assignSlot(slotable) { + const slot = findSlot(slotable); + + if (slot) { + assignSlotable(slot); + } +} + +// https://dom.spec.whatwg.org/#assign-slotables +function assignSlotable(slot) { + const slotables = findSlotable(slot); + + let shouldFireSlotChange = false; + + if (slotables.length !== slot._assignedNodes.length) { + shouldFireSlotChange = true; + } else { + for (let i = 0; i < slotables.length; i++) { + if (slotables[i] !== slot._assignedNodes[i]) { + shouldFireSlotChange = true; + break; + } + } + } + + if (shouldFireSlotChange) { + signalSlotChange(slot); + } + + slot._assignedNodes = slotables; + + for (const slotable of slotables) { + slotable._assignedSlot = slot; + } +} + +// https://dom.spec.whatwg.org/#assign-slotables-for-a-tree +function assignSlotableForTree(root) { + for (const slot of domSymbolTree.treeIterator(root)) { + if (isSlot(slot)) { + assignSlotable(slot); + } + } +} + +// https://dom.spec.whatwg.org/#find-slotables +function findSlotable(slot) { + const result = []; + + const root = nodeRoot(slot); + if (!isShadowRoot(root)) { + return result; + } + + for (const slotable of domSymbolTree.treeIterator(root.host)) { + const foundSlot = findSlot(slotable); + + if (foundSlot === slot) { + result.push(slotable); + } + } + + return result; +} + +// https://dom.spec.whatwg.org/#find-flattened-slotables +function findFlattenedSlotables(slot) { + const result = []; + + const root = nodeRoot(slot); + if (!isShadowRoot(root)) { + return result; + } + + const slotables = findSlotable(slot); + + if (slotables.length === 0) { + for (const child of domSymbolTree.childrenIterator(slot)) { + if (isSlotable(child)) { + slotables.push(child); + } + } + } + + for (const node of slotables) { + if (isSlot(node) && isShadowRoot(nodeRoot(node))) { + const temporaryResult = findFlattenedSlotables(node); + result.push(...temporaryResult); + } else { + result.push(node); + } + } + + return result; +} + +// https://dom.spec.whatwg.org/#find-a-slot +function findSlot(slotable, openFlag) { + const { parentNode: parent } = slotable; + + if (!parent) { + return null; + } + + const shadow = parent._shadowRoot; + + if (!shadow || (openFlag && shadow.mode !== "open")) { + return null; + } + + for (const child of domSymbolTree.treeIterator(shadow)) { + if (isSlot(child) && child.name === slotable._slotableName) { + return child; + } + } + + return null; +} + +// https://dom.spec.whatwg.org/#signal-a-slot-change +function signalSlotChange(slot) { + if (!signalSlotList.some(entry => entry === slot)) { + signalSlotList.push(slot); + } + + queueMutationObserverMicrotask(); +} + +// https://dom.spec.whatwg.org/#concept-shadow-including-descendant +function* shadowIncludingInclusiveDescendantsIterator(node) { + yield node; + + if (node._shadowRoot) { + yield* shadowIncludingInclusiveDescendantsIterator(node._shadowRoot); + } + + for (const child of domSymbolTree.childrenIterator(node)) { + yield* shadowIncludingInclusiveDescendantsIterator(child); + } +} + +// https://dom.spec.whatwg.org/#concept-shadow-including-descendant +function* shadowIncludingDescendantsIterator(node) { + if (node._shadowRoot) { + yield* shadowIncludingInclusiveDescendantsIterator(node._shadowRoot); + } + + for (const child of domSymbolTree.childrenIterator(node)) { + yield* shadowIncludingInclusiveDescendantsIterator(child); + } +} + +module.exports = { + isValidHostElementName, + + isNode, + isSlotable, + isSlot, + isShadowRoot, + + isShadowInclusiveAncestor, + retarget, + getEventTargetParent, + shadowIncludingRoot, + + assignSlot, + assignSlotable, + assignSlotableForTree, + + findSlot, + findFlattenedSlotables, + + signalSlotChange, + + shadowIncludingInclusiveDescendantsIterator, + shadowIncludingDescendantsIterator +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/strings.js b/node_modules/jsdom/lib/jsdom/living/helpers/strings.js new file mode 100644 index 0000000000000000000000000000000000000000..802b6699e926dc34614b0eab92bc3a9ab535092b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/strings.js @@ -0,0 +1,162 @@ +"use strict"; + +// https://infra.spec.whatwg.org/#ascii-whitespace +const asciiWhitespaceRe = /^[\t\n\f\r ]$/; +exports.asciiWhitespaceRe = asciiWhitespaceRe; + +// https://infra.spec.whatwg.org/#ascii-lowercase +exports.asciiLowercase = s => { + const len = s.length; + const out = new Array(len); + for (let i = 0; i < len; i++) { + const code = s.charCodeAt(i); + // If the character is between 'A' (65) and 'Z' (90), convert using bitwise OR with 32 + out[i] = code >= 65 && code <= 90 ? String.fromCharCode(code | 32) : s[i]; + } + return out.join(""); +}; + +// https://infra.spec.whatwg.org/#ascii-uppercase +exports.asciiUppercase = s => { + const len = s.length; + const out = new Array(len); + for (let i = 0; i < len; i++) { + const code = s.charCodeAt(i); + // If the character is between 'a' (97) and 'z' (122), convert using bitwise AND with ~32 + out[i] = code >= 97 && code <= 122 ? String.fromCharCode(code & ~32) : s[i]; + } + return out.join(""); +}; + +// https://infra.spec.whatwg.org/#strip-newlines +exports.stripNewlines = s => { + return s.replace(/[\n\r]+/g, ""); +}; + +// https://infra.spec.whatwg.org/#strip-leading-and-trailing-ascii-whitespace +exports.stripLeadingAndTrailingASCIIWhitespace = s => { + return s.replace(/^[ \t\n\f\r]+/, "").replace(/[ \t\n\f\r]+$/, ""); +}; + +// https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace +exports.stripAndCollapseASCIIWhitespace = s => { + return s.replace(/[ \t\n\f\r]+/g, " ").replace(/^[ \t\n\f\r]+/, "").replace(/[ \t\n\f\r]+$/, ""); +}; + +// https://html.spec.whatwg.org/multipage/infrastructure.html#valid-simple-colour +exports.isValidSimpleColor = s => { + return /^#[a-fA-F\d]{6}$/.test(s); +}; + +// https://infra.spec.whatwg.org/#ascii-case-insensitive +exports.asciiCaseInsensitiveMatch = (a, b) => { + if (a.length !== b.length) { + return false; + } + + for (let i = 0; i < a.length; ++i) { + if ((a.charCodeAt(i) | 32) !== (b.charCodeAt(i) | 32)) { + return false; + } + } + + return true; +}; + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-integers +// Error is represented as null. +const parseInteger = exports.parseInteger = input => { + // The implementation here is slightly different from the spec's. We want to use parseInt(), but parseInt() trims + // Unicode whitespace in addition to just ASCII ones, so we make sure that the trimmed prefix contains only ASCII + // whitespace ourselves. + const numWhitespace = input.length - input.trimStart().length; + if (/[^\t\n\f\r ]/.test(input.slice(0, numWhitespace))) { + return null; + } + // We don't allow hexadecimal numbers here. + // eslint-disable-next-line radix + const value = parseInt(input, 10); + if (Number.isNaN(value)) { + return null; + } + // parseInt() returns -0 for "-0". Normalize that here. + return value === 0 ? 0 : value; +}; + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-non-negative-integers +// Error is represented as null. +exports.parseNonNegativeInteger = input => { + const value = parseInteger(input); + if (value === null) { + return null; + } + if (value < 0) { + return null; + } + return value; +}; + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-floating-point-number +const floatingPointNumRe = /^-?(?:\d+|\d*\.\d+)(?:[eE][-+]?\d+)?$/; +exports.isValidFloatingPointNumber = str => floatingPointNumRe.test(str); + +// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-floating-point-number-values +// Error is represented as null. +exports.parseFloatingPointNumber = str => { + // The implementation here is slightly different from the spec's. We need to use parseFloat() in order to retain + // accuracy, but parseFloat() trims Unicode whitespace in addition to just ASCII ones, so we make sure that the + // trimmed prefix contains only ASCII whitespace ourselves. + const numWhitespace = str.length - str.trimStart().length; + if (/[^\t\n\f\r ]/.test(str.slice(0, numWhitespace))) { + return null; + } + const parsed = parseFloat(str); + return isFinite(parsed) ? parsed : null; +}; + +// https://infra.spec.whatwg.org/#split-on-ascii-whitespace +exports.splitOnASCIIWhitespace = str => { + let position = 0; + const tokens = []; + while (position < str.length && asciiWhitespaceRe.test(str[position])) { + position++; + } + if (position === str.length) { + return tokens; + } + while (position < str.length) { + const start = position; + while (position < str.length && !asciiWhitespaceRe.test(str[position])) { + position++; + } + tokens.push(str.slice(start, position)); + while (position < str.length && asciiWhitespaceRe.test(str[position])) { + position++; + } + } + return tokens; +}; + +// https://infra.spec.whatwg.org/#split-on-commas +exports.splitOnCommas = str => { + let position = 0; + const tokens = []; + while (position < str.length) { + let start = position; + while (position < str.length && str[position] !== ",") { + position++; + } + let end = position; + while (start < str.length && asciiWhitespaceRe.test(str[start])) { + start++; + } + while (end > start && asciiWhitespaceRe.test(str[end - 1])) { + end--; + } + tokens.push(str.slice(start, end)); + if (position < str.length) { + position++; + } + } + return tokens; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/style-rules.js b/node_modules/jsdom/lib/jsdom/living/helpers/style-rules.js new file mode 100644 index 0000000000000000000000000000000000000000..c28fc7e970eccdd98dbdfa188e4b778fdffb9a30 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/style-rules.js @@ -0,0 +1,319 @@ +"use strict"; +const cssom = require("rrweb-cssom"); +const path = require("path"); +const fs = require("fs"); +const { CSSStyleDeclaration } = require("cssstyle"); +const { getSpecifiedColor, getComputedOrUsedColor } = require("./colors"); +const { asciiLowercase } = require("./strings"); +const { deprecatedAliases, systemColors } = require("./system-colors"); + +const defaultStyleSheet = fs.readFileSync( + path.resolve(__dirname, "../../browser/default-stylesheet.css"), + { encoding: "utf-8" } +); + +const { forEach, indexOf } = Array.prototype; + +let parsedDefaultStyleSheet; + +// Properties for which getResolvedValue is implemented. This is less than +// every supported property. +// https://drafts.csswg.org/indexes/#properties +exports.propertiesWithResolvedValueImplemented = { + "__proto__": null, + + // https://drafts.csswg.org/css2/visufx.html#visibility + "visibility": { + inherited: true, + initial: "visible", + computedValue: "as-specified" + }, + // https://svgwg.org/svg2-draft/interact.html#PointerEventsProperty + "pointer-events": { + inherited: true, + initial: "auto", + computedValue: "as-specified" + }, + // https://drafts.csswg.org/css-backgrounds-3/#propdef-background-color + "background-color": { + inherited: false, + initial: "transparent", + computedValue: "computed-color" + }, + // https://drafts.csswg.org/css-logical-1/#propdef-border-block-end-color + "border-block-start-color": { + inherited: false, + initial: "currentcolor", + computedValue: "computed-color" + }, + "border-block-end-color": { + inherited: false, + initial: "currentcolor", + computedValue: "computed-color" + }, + "border-inline-start-color": { + inherited: false, + initial: "currentcolor", + computedValue: "computed-color" + }, + "border-inline-end-color": { + inherited: false, + initial: "currentcolor", + computedValue: "computed-color" + }, + // https://drafts.csswg.org/css-backgrounds-3/#propdef-border-bottom-color + "border-top-color": { + inherited: false, + initial: "currentcolor", + computedValue: "computed-color" + }, + "border-right-color": { + inherited: false, + initial: "currentcolor", + computedValue: "computed-color" + }, + "border-bottom-color": { + inherited: false, + initial: "currentcolor", + computedValue: "computed-color" + }, + "border-left-color": { + inherited: false, + initial: "currentcolor", + computedValue: "computed-color" + }, + // https://drafts.csswg.org/css-ui-4/#propdef-caret-color + "caret-color": { + inherited: true, + initial: "auto", + computedValue: "computed-color" + }, + // https://drafts.csswg.org/css-color-4/#propdef-color + "color": { + inherited: true, + initial: "canvastext", + computedValue: "computed-color" + }, + // https://drafts.csswg.org/css-ui-4/#propdef-outline-color + "outline-color": { + inherited: false, + initial: "invert", + computedValue: "computed-color" + }, + // https://drafts.csswg.org/css-display/#the-display-properties + // Currently only "as-specified" is supported as a computed value + "display": { + inherited: false, + initial: "inline", + computedValue: "as-specified" + } +}; + +function forEachMatchingSheetRuleOfElement(elementImpl, handleRule) { + function handleSheet(sheet) { + forEach.call(sheet.cssRules, rule => { + if (rule.media) { + if (indexOf.call(rule.media, "screen") !== -1) { + forEach.call(rule.cssRules, innerRule => { + if (matches(innerRule, elementImpl)) { + handleRule(innerRule); + } + }); + } + } else if (matches(rule, elementImpl)) { + handleRule(rule); + } + }); + } + + if (!parsedDefaultStyleSheet) { + parsedDefaultStyleSheet = cssom.parse(defaultStyleSheet); + } + + handleSheet(parsedDefaultStyleSheet); + forEach.call(elementImpl._ownerDocument.styleSheets._list, handleSheet); +} + +exports.invalidateStyleCache = elementImpl => { + if (elementImpl._attached) { + elementImpl._ownerDocument._styleCache = null; + } +}; + +exports.getDeclarationForElement = elementImpl => { + let styleCache = elementImpl._ownerDocument._styleCache; + if (!styleCache) { + styleCache = elementImpl._ownerDocument._styleCache = new WeakMap(); + } + + const cachedDeclaration = styleCache.get(elementImpl); + if (cachedDeclaration) { + return cachedDeclaration; + } + + const declaration = new CSSStyleDeclaration(); + + function handleProperty(style, property) { + const value = style.getPropertyValue(property); + // https://drafts.csswg.org/css-cascade-4/#valdef-all-unset + if (value === "unset") { + declaration.removeProperty(property); + } else { + declaration.setProperty( + property, + value, + style.getPropertyPriority(property) + ); + } + } + + forEachMatchingSheetRuleOfElement(elementImpl, rule => { + forEach.call(rule.style, property => { + handleProperty(rule.style, property); + }); + }); + + forEach.call(elementImpl.style, property => { + handleProperty(elementImpl.style, property); + }); + + styleCache.set(elementImpl, declaration); + + return declaration; +}; + +function matches(rule, elementImpl) { + try { + if (rule.selectorText) { + const domSelector = elementImpl._ownerDocument._domSelector; + // Workaround for cssstyle issue. + // https://github.com/jsdom/cssstyle/issues/193 + const selector = rule.selectorText.split(";").pop().trim(); + const { match, pseudoElement } = domSelector.check(selector, elementImpl); + // `pseudoElement` is a pseudo-element selector (e.g. `::before`). + // However, we do not support getComputedStyle(element, pseudoElement), so return `false`. + if (pseudoElement) { + return false; + } + return match; + } + } catch { + // fall through + } + return false; +} + +// Naive implementation of https://drafts.csswg.org/css-cascade-4/#cascading +// based on the previous jsdom implementation of getComputedStyle. +// Does not implement https://drafts.csswg.org/css-cascade-4/#cascade-specificity, +// or rather specificity is only implemented by the order in which the matching +// rules appear. The last rule is the most specific while the first rule is +// the least specific. +function getCascadedPropertyValue(element, property) { + return exports.getDeclarationForElement(element).getPropertyValue(property); +} + +// https://drafts.csswg.org/css-cascade-4/#specified-value +function getSpecifiedValue(element, property) { + const { initial, inherited, computedValue } = exports.propertiesWithResolvedValueImplemented[property]; + const cascade = getCascadedPropertyValue(element, property); + + if (cascade !== "") { + if (computedValue === "computed-color") { + return getSpecifiedColor(cascade); + } + + return cascade; + } + + // Defaulting + if (inherited && element.parentElement !== null) { + return getComputedValue(element.parentElement, property); + } + + // root element without parent element or inherited property + return initial; +} + +// https://drafts.csswg.org/css-cascade-4/#computed-value +function getComputedValue(element, property) { + const { computedValue, inherited, initial } = exports.propertiesWithResolvedValueImplemented[property]; + let specifiedValue = getSpecifiedValue(element, property); + // https://drafts.csswg.org/css-cascade/#defaulting-keywords + switch (specifiedValue) { + case "initial": { + specifiedValue = initial; + break; + } + case "inherit": { + if (element.parentElement !== null) { + specifiedValue = getComputedValue(element.parentElement, property); + } else { + specifiedValue = initial; + } + break; + } + case "unset": { + if (inherited && element.parentElement !== null) { + specifiedValue = getComputedValue(element.parentElement, property); + } else { + specifiedValue = initial; + } + break; + } + // TODO: https://drafts.csswg.org/css-cascade-5/#revert-layer + case "revert-layer": { + break; + } + // TODO: https://drafts.csswg.org/css-cascade-5/#default + case "revert": { + break; + } + default: { + // fall through; specifiedValue is not a CSS-wide keyword. + } + } + if (computedValue === "as-specified") { + return specifiedValue; + } else if (computedValue === "computed-color") { + let value = asciiLowercase(specifiedValue); + // https://drafts.csswg.org/css-color-4/#resolving-other-colors + if (specifiedValue === "currentcolor") { + if (property === "color") { + if (element.parentElement !== null) { + return getComputedValue(element.parentElement, "color"); + } + value = initial; + } else { + return getComputedValue(element, "color"); + } + } + if (systemColors.has(value) || deprecatedAliases.has(value)) { + let key = value; + if (deprecatedAliases.has(value)) { + key = deprecatedAliases.get(value); + } + const { light, dark } = systemColors.get(key); + const colorScheme = getCascadedPropertyValue(element, "color-scheme"); + if (colorScheme === "dark") { + return dark; + } + return light; + } + return getComputedOrUsedColor(specifiedValue); + } + + throw new TypeError(`Internal error: unrecognized computed value instruction '${computedValue}'`); +} + +// https://drafts.csswg.org/cssom/#resolved-value +// Only implements the properties that are defined in propertiesWithResolvedValueImplemented. +exports.getResolvedValue = (element, property) => { + // We can always use the computed value with the current set of propertiesWithResolvedValueImplemented: + // * Color properties end up with the used value, but we don't implement any actual differences between used and + // computed that https://drafts.csswg.org/css-cascade-5/#used-value gestures at. + // * The other properties fall back to the "any other property: The resolved value is the computed value." case. + return getComputedValue(element, property); +}; + +exports.SHADOW_DOM_PSEUDO_REGEXP = /^::(?:part|slotted)\(/i; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/stylesheets.js b/node_modules/jsdom/lib/jsdom/living/helpers/stylesheets.js new file mode 100644 index 0000000000000000000000000000000000000000..454e355b2ff77459c8ec9716e09a319546f04b65 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/stylesheets.js @@ -0,0 +1,129 @@ +"use strict"; +const cssom = require("rrweb-cssom"); +const whatwgEncoding = require("whatwg-encoding"); +const whatwgURL = require("whatwg-url"); +const { invalidateStyleCache } = require("./style-rules"); + +// TODO: this should really implement https://html.spec.whatwg.org/multipage/links.html#link-type-stylesheet +// It (and the things it calls) is nowhere close right now. +exports.fetchStylesheet = (elementImpl, urlString) => { + const document = elementImpl._ownerDocument; + let defaultEncoding = document._encoding; + const resourceLoader = document._resourceLoader; + + if (elementImpl.localName === "link" && elementImpl.hasAttributeNS(null, "charset")) { + defaultEncoding = whatwgEncoding.labelToName(elementImpl.getAttributeNS(null, "charset")); + } + + function onStylesheetLoad(data) { + // if the element was detached before the load could finish, don't process the data + if (!elementImpl._attached) { + return; + } + + const css = whatwgEncoding.decode(data, defaultEncoding); + + // TODO: MIME type checking? + if (elementImpl.sheet) { + exports.removeStylesheet(elementImpl.sheet, elementImpl); + } + exports.createStylesheet(css, elementImpl, urlString); + } + + resourceLoader.fetch(urlString, { + element: elementImpl, + onLoad: onStylesheetLoad + }); +}; + +// https://drafts.csswg.org/cssom/#remove-a-css-style-sheet +exports.removeStylesheet = (sheet, elementImpl) => { + const { styleSheets } = elementImpl._ownerDocument; + styleSheets._remove(sheet); + + // Remove the association explicitly; in the spec it's implicit so this step doesn't exist. + elementImpl.sheet = null; + + invalidateStyleCache(elementImpl); + + // TODO: "Set the CSS style sheet’s parent CSS style sheet, owner node and owner CSS rule to null." + // Probably when we have a real CSSOM implementation. +}; + +// https://drafts.csswg.org/cssom/#create-a-css-style-sheet kinda: +// - Parsing failures are not handled gracefully like they should be +// - The import rules stuff seems out of place, and probably should affect the load event... +exports.createStylesheet = (sheetText, elementImpl, baseURLString) => { + let sheet; + try { + sheet = cssom.parse(sheetText); + } catch (cause) { + if (elementImpl._ownerDocument._defaultView) { + const error = new Error("Could not parse CSS stylesheet", { cause }); + error.sheetText = sheetText; + error.type = "css-parsing"; + + elementImpl._ownerDocument._defaultView._virtualConsole.emit("jsdomError", error); + } + return; + } + + scanForImportRules(elementImpl, sheet.cssRules, baseURLString); + + addStylesheet(sheet, elementImpl); +}; + +// https://drafts.csswg.org/cssom/#add-a-css-style-sheet +function addStylesheet(sheet, elementImpl) { + elementImpl._ownerDocument.styleSheets._add(sheet); + + // Set the association explicitly; in the spec it's implicit. + elementImpl.sheet = sheet; + + invalidateStyleCache(elementImpl); + + // TODO: title and disabled stuff +} + +// TODO this is actually really messed up and overwrites the sheet on elementImpl +// Tracking in https://github.com/jsdom/jsdom/issues/2124 +function scanForImportRules(elementImpl, cssRules, baseURLString) { + if (!cssRules) { + return; + } + + for (let i = 0; i < cssRules.length; ++i) { + if (cssRules[i].cssRules) { + // @media rule: keep searching inside it. + scanForImportRules(elementImpl, cssRules[i].cssRules, baseURLString); + } else if (cssRules[i].href) { + // @import rule: fetch the resource and evaluate it. + // See http://dev.w3.org/csswg/cssom/#css-import-rule + // If loading of the style sheet fails its cssRules list is simply + // empty. I.e. an @import rule always has an associated style sheet. + + // Use whatwgURL.URL instead of whatwgURL.parseURL so that we get an error we can use as the cause if the URL + // doesn't parse. + let parsed; + try { + parsed = new whatwgURL.URL(cssRules[i].href, baseURLString); + } catch (cause) { + const window = elementImpl._ownerDocument._defaultView; + if (window) { + // Synthetic cause to ensure that all resource loading errors have causes. + const error = new Error( + `Could not parse CSS @import URL "${cssRules[i].href}" relative to base URL "${baseURLString}"`, + { cause } + ); + error.type = "resource-loading"; + error.url = cssRules[i].href; + window._virtualConsole.emit("jsdomError", error); + } + } + + if (parsed) { + exports.fetchStylesheet(elementImpl, parsed.href); + } + } + } +} diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/svg/basic-types.js b/node_modules/jsdom/lib/jsdom/living/helpers/svg/basic-types.js new file mode 100644 index 0000000000000000000000000000000000000000..16d0dc1c2a0c88dbdd9926d653fa32aff791b409 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/svg/basic-types.js @@ -0,0 +1,41 @@ +"use strict"; + +// https://svgwg.org/svg2-draft/types.html#TermDetach +function detach(value) { + if (typeof value === "string") { + return; + } + + throw new TypeError(`jsdom internal error: detaching object of wrong type ${value}`); +} +exports.detach = detach; + +// https://svgwg.org/svg2-draft/types.html#TermAttach +// listObject corresponds to the parameter taken by the algorithm in the spec, but is currently unused because only +// DOMString type is supported by jsdom (and this function) right now. +// eslint-disable-next-line no-unused-vars +function attach(value, listObject) { + if (typeof value === "string") { + return; + } + + throw new TypeError(`jsdom internal error: attaching object of wrong type ${value}`); +} +exports.attach = attach; + +// https://svgwg.org/svg2-draft/types.html#TermReserialize for DOMString. +function reserializeSpaceSeparatedTokens(elements) { + return elements.join(" "); +} +exports.reserializeSpaceSeparatedTokens = reserializeSpaceSeparatedTokens; + +// Used for systemLanguage attribute, whose value is a set of comma-separated tokens: +// https://svgwg.org/svg2-draft/struct.html#SystemLanguageAttribute +// SVG 2 spec (https://svgwg.org/svg2-draft/types.html#TermReserialize) says any SVGStringList should reserialize the +// same way, as space-separated tokens, but doing so for systemLanguage is illogical and contradicts the Firefox +// behavior. +// I cannot find a description of reserialization of SVGStringList in the SVG 1.1 spec. +function reserializeCommaSeparatedTokens(elements) { + return elements.join(", "); +} +exports.reserializeCommaSeparatedTokens = reserializeCommaSeparatedTokens; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/svg/render.js b/node_modules/jsdom/lib/jsdom/living/helpers/svg/render.js new file mode 100644 index 0000000000000000000000000000000000000000..651568daa8b089afff9b08f84028f2c21705520b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/svg/render.js @@ -0,0 +1,46 @@ +"use strict"; +const { SVG_NS } = require("../namespaces"); + +// https://svgwg.org/svg2-draft/render.html#TermNeverRenderedElement +const neverRenderedElements = new Set([ + "clipPath", + "defs", + "desc", + "linearGradient", + "marker", + "mask", + "metadata", + "pattern", + "radialGradient", + "script", + "style", + "title", + "symbol" +]); + +// https://svgwg.org/svg2-draft/render.html#Rendered-vs-NonRendered +exports.isRenderedElement = elImpl => { + if (neverRenderedElements.has(elImpl._localName)) { + return false; + } + + // This does not check for elements excluded because of conditional processing attributes or ‘switch’ structures, + // because conditional processing is not implemented. + // https://svgwg.org/svg2-draft/struct.html#ConditionalProcessing + + // This does not check for computed style of display being none, since that is not yet implemented for HTML + // focusability either (and there are no tests yet). + + if (!elImpl.isConnected) { + return false; + } + + // The spec is unclear about how to deal with non-SVG parents, so we only perform this check for SVG-namespace + // parents. + if (elImpl.parentElement && elImpl.parentElement._namespaceURI === SVG_NS && + !exports.isRenderedElement(elImpl.parentNode)) { + return false; + } + + return true; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/system-colors.js b/node_modules/jsdom/lib/jsdom/living/helpers/system-colors.js new file mode 100644 index 0000000000000000000000000000000000000000..6791c8ea07e491b0df7b2c5201a6bb8a7f53e474 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/system-colors.js @@ -0,0 +1,147 @@ +"use strict"; + +// https://drafts.csswg.org/css-color-4/#css-system-colors +module.exports.systemColors = new Map([ + [ + "accentcolor", { + light: "rgb(0, 153, 255)", + dark: "rgb(0, 51, 255)" + } + ], + [ + "accentcolortext", { + light: "rgb(0, 0, 0)", + dark: "rgb(255, 255, 255)" + } + ], + [ + "activetext", { + light: "rgb(255, 0, 0)", + dark: "rgb(255, 102, 102)" + } + ], + [ + "buttonborder", { + light: "rgb(51, 51, 51)", + dark: "rgb(204, 204, 204)" + } + ], + [ + "buttonface", { + light: "rgb(204, 204, 204)", + dark: "rgb(51, 51, 51)" + } + ], + [ + "buttontext", { + light: "rgb(0, 0, 0)", + dark: "rgb(255, 255, 155)" + } + ], + [ + "canvas", { + light: "rgb(255, 255, 255)", + dark: "rgb(0, 0, 0)" + } + ], + [ + "canvastext", { + light: "rgb(0, 0, 0)", + dark: "rgb(255, 255, 255)" + } + ], + [ + "field", { + light: "rgb(255, 255, 255)", + dark: "rgb(0, 0, 0)" + } + ], + [ + "fieldtext", { + light: "rgb(0, 0, 0)", + dark: "rgb(255, 255, 255)" + } + ], + [ + "graytext", { + light: "rgb(102, 102, 102)", + dark: "rgb(153, 153, 153)" + } + ], + [ + "highlight", { + light: "rgb(0, 153, 255)", + dark: "rgb(0, 51, 255)" + } + ], + [ + "highlighttext", { + light: "rgb(255, 255, 255)", + dark: "rgb(0, 0, 0)" + } + ], + [ + "linktext", { + light: "rgb(0, 0, 255)", + dark: "rgb(0, 204, 255)" + } + ], + [ + "mark", { + light: "rgb(255, 255, 0)", + dark: "rgb(204, 0, 153)" + } + ], + [ + "marktext", { + light: "rgb(0, 0, 0)", + dark: "rgb(255, 255, 255)" + } + ], + [ + "selecteditem", { + light: "rgb(0, 153, 255)", + dark: "rgb(0, 51, 255)" + } + ], + [ + "selecteditemtext", { + light: "rgb(255, 255, 255)", + dark: "rgb(0, 0, 0)" + } + ], + [ + "visitedtext", { + light: "rgb(128, 0, 128)", + dark: "rgb(255, 51, 255)" + } + ] +]); + +// Deprecated system colors +// https://drafts.csswg.org/css-color-4/#deprecated-system-colors +module.exports.deprecatedAliases = new Map([ + ["activeborder", "buttonborder"], + ["activecaption", "canvas"], + ["appworkspace", "canvas"], + ["background", "canvas"], + ["buttonhighlight", "buttonface"], + ["buttonshadow", "buttonface"], + ["captiontext", "canvastext"], + ["inactiveborder", "buttonborder"], + ["inactivecaption", "canvas"], + ["inactivecaptiontext", "graytext"], + ["infobackground", "canvas"], + ["infotext", "canvastext"], + ["menu", "canvas"], + ["menutext", "canvastext"], + ["scrollbar", "canvas"], + ["threeddarkshadow", "buttonborder"], + ["threedface", "buttonface"], + ["threedhighlight", "buttonborder"], + ["threedlightshadow", "buttonborder"], + ["threedshadow", "buttonborder"], + ["window", "canvas"], + ["windowframe", "buttonborder"], + ["windowtext", "canvastext"] +]); diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/text.js b/node_modules/jsdom/lib/jsdom/living/helpers/text.js new file mode 100644 index 0000000000000000000000000000000000000000..632c0e5628b99313d935281a3f443a40dae6717d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/text.js @@ -0,0 +1,19 @@ +"use strict"; +const { domSymbolTree } = require("./internal-constants"); +const { CDATA_SECTION_NODE, TEXT_NODE } = require("../node-type"); + +// +// https://dom.spec.whatwg.org/#concept-child-text-content +// +exports.childTextContent = node => { + let result = ""; + const iterator = domSymbolTree.childrenIterator(node); + for (const child of iterator) { + if (child.nodeType === TEXT_NODE || + // The CDataSection extends Text. + child.nodeType === CDATA_SECTION_NODE) { + result += child.data; + } + } + return result; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/traversal.js b/node_modules/jsdom/lib/jsdom/living/helpers/traversal.js new file mode 100644 index 0000000000000000000000000000000000000000..91f7148059069cbfcff5c5601855fd2210461735 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/traversal.js @@ -0,0 +1,72 @@ +"use strict"; +const { domSymbolTree } = require("./internal-constants"); +const { HTML_NS } = require("./namespaces"); + +// All these operate on and return impls, not wrappers! + +exports.closest = (e, localName, namespace = HTML_NS) => { + while (e) { + if (e.localName === localName && e.namespaceURI === namespace) { + return e; + } + e = domSymbolTree.parent(e); + } + + return null; +}; + +exports.childrenByLocalName = (parent, localName, namespace = HTML_NS) => { + return domSymbolTree.childrenToArray(parent, { filter(node) { + return node._localName === localName && node._namespaceURI === namespace; + } }); +}; + +exports.descendantsByLocalName = (parent, localName, namespace = HTML_NS) => { + return domSymbolTree.treeToArray(parent, { filter(node) { + return node._localName === localName && node._namespaceURI === namespace && node !== parent; + } }); +}; + +exports.childrenByLocalNames = (parent, localNamesSet, namespace = HTML_NS) => { + return domSymbolTree.childrenToArray(parent, { filter(node) { + return localNamesSet.has(node._localName) && node._namespaceURI === namespace; + } }); +}; + +exports.descendantsByLocalNames = (parent, localNamesSet, namespace = HTML_NS) => { + return domSymbolTree.treeToArray(parent, { filter(node) { + return localNamesSet.has(node._localName) && + node._namespaceURI === namespace && + node !== parent; + } }); +}; + +exports.firstChildWithLocalName = (parent, localName, namespace = HTML_NS) => { + const iterator = domSymbolTree.childrenIterator(parent); + for (const child of iterator) { + if (child._localName === localName && child._namespaceURI === namespace) { + return child; + } + } + return null; +}; + +exports.firstChildWithLocalNames = (parent, localNamesSet, namespace = HTML_NS) => { + const iterator = domSymbolTree.childrenIterator(parent); + for (const child of iterator) { + if (localNamesSet.has(child._localName) && child._namespaceURI === namespace) { + return child; + } + } + return null; +}; + +exports.firstDescendantWithLocalName = (parent, localName, namespace = HTML_NS) => { + const iterator = domSymbolTree.treeIterator(parent); + for (const descendant of iterator) { + if (descendant._localName === localName && descendant._namespaceURI === namespace) { + return descendant; + } + } + return null; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/helpers/validate-names.js b/node_modules/jsdom/lib/jsdom/living/helpers/validate-names.js new file mode 100644 index 0000000000000000000000000000000000000000..878cadd3d98aaae1fdb7f4571a22568135cf659b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/helpers/validate-names.js @@ -0,0 +1,65 @@ +"use strict"; +const xnv = require("xml-name-validator"); +const DOMException = require("../generated/DOMException"); +const { XML_NS, XMLNS_NS } = require("../helpers/namespaces"); + +// https://dom.spec.whatwg.org/#validate + +exports.name = (globalObject, name) => { + if (!xnv.name(name)) { + throw DOMException.create(globalObject, [`"${name}" did not match the Name production`, "InvalidCharacterError"]); + } +}; + +exports.qname = (globalObject, qname) => { + if (!xnv.qname(qname)) { + throw DOMException.create(globalObject, [`"${qname}" did not match the QName production`, "InvalidCharacterError"]); + } +}; + +exports.validateAndExtract = (globalObject, namespace, qualifiedName) => { + if (namespace === "") { + namespace = null; + } + + exports.qname(globalObject, qualifiedName); + + let prefix = null; + let localName = qualifiedName; + + const colonIndex = qualifiedName.indexOf(":"); + if (colonIndex !== -1) { + prefix = qualifiedName.substring(0, colonIndex); + localName = qualifiedName.substring(colonIndex + 1); + } + + if (prefix !== null && namespace === null) { + throw DOMException.create(globalObject, [ + "A namespace was given but a prefix was also extracted from the qualifiedName", + "NamespaceError" + ]); + } + + if (prefix === "xml" && namespace !== XML_NS) { + throw DOMException.create(globalObject, [ + "A prefix of \"xml\" was given but the namespace was not the XML namespace", + "NamespaceError" + ]); + } + + if ((qualifiedName === "xmlns" || prefix === "xmlns") && namespace !== XMLNS_NS) { + throw DOMException.create(globalObject, [ + "A prefix or qualifiedName of \"xmlns\" was given but the namespace was not the XMLNS namespace", + "NamespaceError" + ]); + } + + if (namespace === XMLNS_NS && qualifiedName !== "xmlns" && prefix !== "xmlns") { + throw DOMException.create(globalObject, [ + "The XMLNS namespace was given but neither the prefix nor qualifiedName was \"xmlns\"", + "NamespaceError" + ]); + } + + return { namespace, prefix, localName }; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/hr-time/Performance-impl.js b/node_modules/jsdom/lib/jsdom/living/hr-time/Performance-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..023931c73452bdf36426d9b2d71fb9e64b5390f5 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/hr-time/Performance-impl.js @@ -0,0 +1,22 @@ +"use strict"; + +const EventTargetImpl = require("../events/EventTarget-impl").implementation; + +class PerformanceImpl extends EventTargetImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this.timeOrigin = privateData.timeOrigin; + this._nowAtTimeOrigin = privateData.nowAtTimeOrigin; + } + + now() { + return performance.now() - this._nowAtTimeOrigin; + } + + toJSON() { + return { timeOrigin: this.timeOrigin }; + } +} + +exports.implementation = PerformanceImpl; diff --git a/node_modules/jsdom/lib/jsdom/living/interfaces.js b/node_modules/jsdom/lib/jsdom/living/interfaces.js new file mode 100644 index 0000000000000000000000000000000000000000..6fbee8e1ea3c73d98c7deafe27fdd924ce962c0a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/interfaces.js @@ -0,0 +1,249 @@ +"use strict"; + +const style = require("../level2/style"); +const xpath = require("../level3/xpath"); + +// This object defines the mapping between the interface name and the generated interface wrapper code. +// Note: The mapping needs to stay as-is in order due to interface evaluation. +// We cannot "refactor" this to something less duplicative because that would break bundlers which depend on static +// analysis of require()s. +const generatedInterfaces = { + DOMException: require("./generated/DOMException.js"), + + URL: require("whatwg-url/webidl2js-wrapper").URL, + URLSearchParams: require("whatwg-url/webidl2js-wrapper").URLSearchParams, + + EventTarget: require("./generated/EventTarget"), + + NamedNodeMap: require("./generated/NamedNodeMap"), + Node: require("./generated/Node"), + Attr: require("./generated/Attr"), + Element: require("./generated/Element"), + DocumentFragment: require("./generated/DocumentFragment"), + DOMImplementation: require("./generated/DOMImplementation"), + Document: require("./generated/Document"), + XMLDocument: require("./generated/XMLDocument"), + CharacterData: require("./generated/CharacterData"), + Text: require("./generated/Text"), + CDATASection: require("./generated/CDATASection"), + ProcessingInstruction: require("./generated/ProcessingInstruction"), + Comment: require("./generated/Comment"), + DocumentType: require("./generated/DocumentType"), + NodeList: require("./generated/NodeList"), + RadioNodeList: require("./generated/RadioNodeList"), + HTMLCollection: require("./generated/HTMLCollection"), + HTMLOptionsCollection: require("./generated/HTMLOptionsCollection"), + DOMStringMap: require("./generated/DOMStringMap"), + DOMTokenList: require("./generated/DOMTokenList"), + + StyleSheetList: require("./generated/StyleSheetList.js"), + + HTMLElement: require("./generated/HTMLElement.js"), + HTMLHeadElement: require("./generated/HTMLHeadElement.js"), + HTMLTitleElement: require("./generated/HTMLTitleElement.js"), + HTMLBaseElement: require("./generated/HTMLBaseElement.js"), + HTMLLinkElement: require("./generated/HTMLLinkElement.js"), + HTMLMetaElement: require("./generated/HTMLMetaElement.js"), + HTMLStyleElement: require("./generated/HTMLStyleElement.js"), + HTMLBodyElement: require("./generated/HTMLBodyElement.js"), + HTMLHeadingElement: require("./generated/HTMLHeadingElement.js"), + HTMLParagraphElement: require("./generated/HTMLParagraphElement.js"), + HTMLHRElement: require("./generated/HTMLHRElement.js"), + HTMLPreElement: require("./generated/HTMLPreElement.js"), + HTMLUListElement: require("./generated/HTMLUListElement.js"), + HTMLOListElement: require("./generated/HTMLOListElement.js"), + HTMLLIElement: require("./generated/HTMLLIElement.js"), + HTMLMenuElement: require("./generated/HTMLMenuElement.js"), + HTMLDListElement: require("./generated/HTMLDListElement.js"), + HTMLDivElement: require("./generated/HTMLDivElement.js"), + HTMLAnchorElement: require("./generated/HTMLAnchorElement.js"), + HTMLAreaElement: require("./generated/HTMLAreaElement.js"), + HTMLBRElement: require("./generated/HTMLBRElement.js"), + HTMLButtonElement: require("./generated/HTMLButtonElement.js"), + HTMLCanvasElement: require("./generated/HTMLCanvasElement.js"), + HTMLDataElement: require("./generated/HTMLDataElement.js"), + HTMLDataListElement: require("./generated/HTMLDataListElement.js"), + HTMLDetailsElement: require("./generated/HTMLDetailsElement.js"), + HTMLDialogElement: require("./generated/HTMLDialogElement.js"), + HTMLDirectoryElement: require("./generated/HTMLDirectoryElement.js"), + HTMLFieldSetElement: require("./generated/HTMLFieldSetElement.js"), + HTMLFontElement: require("./generated/HTMLFontElement.js"), + HTMLFormElement: require("./generated/HTMLFormElement.js"), + HTMLHtmlElement: require("./generated/HTMLHtmlElement.js"), + HTMLImageElement: require("./generated/HTMLImageElement.js"), + HTMLInputElement: require("./generated/HTMLInputElement.js"), + HTMLLabelElement: require("./generated/HTMLLabelElement.js"), + HTMLLegendElement: require("./generated/HTMLLegendElement.js"), + HTMLMapElement: require("./generated/HTMLMapElement.js"), + HTMLMarqueeElement: require("./generated/HTMLMarqueeElement.js"), + HTMLMediaElement: require("./generated/HTMLMediaElement.js"), + HTMLMeterElement: require("./generated/HTMLMeterElement.js"), + HTMLModElement: require("./generated/HTMLModElement.js"), + HTMLOptGroupElement: require("./generated/HTMLOptGroupElement.js"), + HTMLOptionElement: require("./generated/HTMLOptionElement.js"), + HTMLOutputElement: require("./generated/HTMLOutputElement.js"), + HTMLPictureElement: require("./generated/HTMLPictureElement.js"), + HTMLProgressElement: require("./generated/HTMLProgressElement.js"), + HTMLQuoteElement: require("./generated/HTMLQuoteElement.js"), + HTMLScriptElement: require("./generated/HTMLScriptElement.js"), + HTMLSelectElement: require("./generated/HTMLSelectElement.js"), + HTMLSlotElement: require("./generated/HTMLSlotElement.js"), + HTMLSourceElement: require("./generated/HTMLSourceElement.js"), + HTMLSpanElement: require("./generated/HTMLSpanElement.js"), + HTMLTableCaptionElement: require("./generated/HTMLTableCaptionElement.js"), + HTMLTableCellElement: require("./generated/HTMLTableCellElement.js"), + HTMLTableColElement: require("./generated/HTMLTableColElement.js"), + HTMLTableElement: require("./generated/HTMLTableElement.js"), + HTMLTimeElement: require("./generated/HTMLTimeElement.js"), + HTMLTableRowElement: require("./generated/HTMLTableRowElement.js"), + HTMLTableSectionElement: require("./generated/HTMLTableSectionElement.js"), + HTMLTemplateElement: require("./generated/HTMLTemplateElement.js"), + HTMLTextAreaElement: require("./generated/HTMLTextAreaElement.js"), + HTMLUnknownElement: require("./generated/HTMLUnknownElement.js"), + HTMLFrameElement: require("./generated/HTMLFrameElement.js"), + HTMLFrameSetElement: require("./generated/HTMLFrameSetElement.js"), + HTMLIFrameElement: require("./generated/HTMLIFrameElement.js"), + HTMLEmbedElement: require("./generated/HTMLEmbedElement.js"), + HTMLObjectElement: require("./generated/HTMLObjectElement.js"), + HTMLParamElement: require("./generated/HTMLParamElement.js"), + HTMLVideoElement: require("./generated/HTMLVideoElement.js"), + HTMLAudioElement: require("./generated/HTMLAudioElement.js"), + HTMLTrackElement: require("./generated/HTMLTrackElement.js"), + HTMLFormControlsCollection: require("./generated/HTMLFormControlsCollection.js"), + + SVGElement: require("./generated/SVGElement.js"), + SVGGraphicsElement: require("./generated/SVGGraphicsElement.js"), + SVGSVGElement: require("./generated/SVGSVGElement.js"), + SVGGElement: require("./generated/SVGGElement.js"), + SVGDefsElement: require("./generated/SVGDefsElement.js"), + SVGDescElement: require("./generated/SVGDescElement.js"), + SVGMetadataElement: require("./generated/SVGMetadataElement.js"), + SVGTitleElement: require("./generated/SVGTitleElement.js"), + SVGSymbolElement: require("./generated/SVGSymbolElement.js"), + SVGSwitchElement: require("./generated/SVGSwitchElement.js"), + + SVGAnimatedPreserveAspectRatio: require("./generated/SVGAnimatedPreserveAspectRatio"), + SVGAnimatedRect: require("./generated/SVGAnimatedRect"), + SVGAnimatedString: require("./generated/SVGAnimatedString"), + SVGNumber: require("./generated/SVGNumber"), + SVGPreserveAspectRatio: require("./generated/SVGPreserveAspectRatio"), + SVGRect: require("./generated/SVGRect"), + SVGStringList: require("./generated/SVGStringList"), + + Event: require("./generated/Event"), + BeforeUnloadEvent: require("./generated/BeforeUnloadEvent"), + BlobEvent: require("./generated/BlobEvent"), + CloseEvent: require("./generated/CloseEvent"), + CustomEvent: require("./generated/CustomEvent"), + DeviceOrientationEvent: require("./generated/DeviceOrientationEvent"), + DeviceMotionEvent: require("./generated/DeviceMotionEvent"), + ErrorEvent: require("./generated/ErrorEvent"), + HashChangeEvent: require("./generated/HashChangeEvent"), + MessageEvent: require("./generated/MessageEvent"), + PageTransitionEvent: require("./generated/PageTransitionEvent"), + PopStateEvent: require("./generated/PopStateEvent"), + PromiseRejectionEvent: require("./generated/PromiseRejectionEvent"), + ProgressEvent: require("./generated/ProgressEvent"), + StorageEvent: require("./generated/StorageEvent"), + SubmitEvent: require("./generated/SubmitEvent"), + TransitionEvent: require("./generated/TransitionEvent"), + + UIEvent: require("./generated/UIEvent"), + FocusEvent: require("./generated/FocusEvent"), + InputEvent: require("./generated/InputEvent"), + MouseEvent: require("./generated/MouseEvent"), + PointerEvent: require("./generated/PointerEvent"), + KeyboardEvent: require("./generated/KeyboardEvent"), + TouchEvent: require("./generated/TouchEvent"), + CompositionEvent: require("./generated/CompositionEvent"), + WheelEvent: require("./generated/WheelEvent"), + + BarProp: require("./generated/BarProp"), + External: require("./generated/External"), + Location: require("./generated/Location"), + History: require("./generated/History"), + Screen: require("./generated/Screen"), + Performance: require("./generated/Performance"), + Navigator: require("./generated/Navigator"), + + Crypto: require("./generated/Crypto"), + + PluginArray: require("./generated/PluginArray"), + MimeTypeArray: require("./generated/MimeTypeArray"), + Plugin: require("./generated/Plugin"), + MimeType: require("./generated/MimeType"), + + FileReader: require("./generated/FileReader"), + Blob: require("./generated/Blob"), + File: require("./generated/File"), + FileList: require("./generated/FileList"), + ValidityState: require("./generated/ValidityState"), + + DOMParser: require("./generated/DOMParser"), + XMLSerializer: require("./generated/XMLSerializer"), + + FormData: require("./generated/FormData"), + XMLHttpRequestEventTarget: require("./generated/XMLHttpRequestEventTarget"), + XMLHttpRequestUpload: require("./generated/XMLHttpRequestUpload"), + XMLHttpRequest: require("./generated/XMLHttpRequest"), + WebSocket: require("./generated/WebSocket"), + + NodeFilter: require("./generated/NodeFilter"), + NodeIterator: require("./generated/NodeIterator"), + TreeWalker: require("./generated/TreeWalker"), + + AbstractRange: require("./generated/AbstractRange"), + Range: require("./generated/Range"), + StaticRange: require("./generated/StaticRange"), + Selection: require("./generated/Selection"), + + Storage: require("./generated/Storage"), + + CustomElementRegistry: require("./generated/CustomElementRegistry"), + ElementInternals: require("./generated/ElementInternals"), + ShadowRoot: require("./generated/ShadowRoot"), + + MutationObserver: require("./generated/MutationObserver"), + MutationRecord: require("./generated/MutationRecord"), + + Headers: require("./generated/Headers"), + AbortController: require("./generated/AbortController"), + AbortSignal: require("./generated/AbortSignal"), + + DeviceMotionEventAcceleration: require("./generated/DeviceMotionEventAcceleration"), + DeviceMotionEventRotationRate: require("./generated/DeviceMotionEventRotationRate"), + + DOMRectReadOnly: require("./generated/DOMRectReadOnly"), + DOMRect: require("./generated/DOMRect") +}; + +function install(window, name, interfaceConstructor) { + Object.defineProperty(window, name, { + configurable: true, + writable: true, + value: interfaceConstructor + }); +} + +exports.installInterfaces = (window, globalNames) => { + // Install generated interface. + for (const generatedInterface of Object.values(generatedInterfaces)) { + generatedInterface.install(window, globalNames); + } + + // Install legacy HTMLDocument interface + // https://html.spec.whatwg.org/#htmldocument + install(window, "HTMLDocument", window.Document); + + // https://webidl.spec.whatwg.org/#es-DOMException-specialness + Object.setPrototypeOf(window.DOMException.prototype, window.Error.prototype); + + // These need to be cleaned up... + style.addToCore(window); + xpath(window); +}; + +// Returns an interface webidl2js wrapper given its an interface name. +exports.getInterfaceWrapper = name => { + return generatedInterfaces[name]; +}; diff --git a/node_modules/jsdom/lib/jsdom/living/mutation-observer/MutationObserver-impl.js b/node_modules/jsdom/lib/jsdom/living/mutation-observer/MutationObserver-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..3057da8ca8c5d5cb39a73d3fb9683161a8af7c17 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/mutation-observer/MutationObserver-impl.js @@ -0,0 +1,95 @@ +"use strict"; + +const { wrapperForImpl } = require("../generated/utils"); + +// If we were to implement the MutationObserver by spec, the MutationObservers will not be collected by the GC because +// all the MO are kept in a mutation observer list (https://github.com/jsdom/jsdom/pull/2398/files#r238123889). The +// mutation observer list is primarily used to invoke the mutation observer callback in the same order than the +// mutation observer creation. +// In order to get around this issue, we will assign an increasing id for each mutation observer, this way we would be +// able to invoke the callback in the creation order without having to keep a list of all the mutation observers. +let mutationObserverId = 0; + +// https://dom.spec.whatwg.org/#mutationobserver +class MutationObserverImpl { + // https://dom.spec.whatwg.org/#dom-mutationobserver-mutationobserver + constructor(globalObject, args) { + const [callback] = args; + + this._callback = callback; + this._nodeList = []; + this._recordQueue = []; + + this._id = ++mutationObserverId; + } + + // https://dom.spec.whatwg.org/#dom-mutationobserver-observe + observe(target, options) { + if (("attributeOldValue" in options || "attributeFilter" in options) && !("attributes" in options)) { + options.attributes = true; + } + + if ("characterDataOldValue" in options & !("characterData" in options)) { + options.characterData = true; + } + + if (!options.childList && !options.attributes && !options.characterData) { + throw new TypeError("The options object must set at least one of 'attributes', 'characterData', or 'childList' " + + "to true."); + } else if (options.attributeOldValue && !options.attributes) { + throw new TypeError("The options object may only set 'attributeOldValue' to true when 'attributes' is true or " + + "not present."); + } else if (("attributeFilter" in options) && !options.attributes) { + throw new TypeError("The options object may only set 'attributeFilter' when 'attributes' is true or not " + + "present."); + } else if (options.characterDataOldValue && !options.characterData) { + throw new TypeError("The options object may only set 'characterDataOldValue' to true when 'characterData' is " + + "true or not present."); + } + + const existingRegisteredObserver = target._registeredObserverList.find(registeredObserver => { + return registeredObserver.observer === this; + }); + + if (existingRegisteredObserver) { + for (const node of this._nodeList) { + node._registeredObserverList = node._registeredObserverList.filter(registeredObserver => { + return registeredObserver.source !== existingRegisteredObserver; + }); + } + + existingRegisteredObserver.options = options; + } else { + target._registeredObserverList.push({ + observer: this, + options + }); + + this._nodeList.push(target); + } + } + + // https://dom.spec.whatwg.org/#dom-mutationobserver-disconnect + disconnect() { + for (const node of this._nodeList) { + node._registeredObserverList = node._registeredObserverList.filter(registeredObserver => { + return registeredObserver.observer !== this; + }); + } + + this._recordQueue = []; + } + + // https://dom.spec.whatwg.org/#dom-mutationobserver-takerecords + takeRecords() { + // TODO: revisit if https://github.com/jsdom/webidl2js/pull/108 gets fixed. + const records = this._recordQueue.map(wrapperForImpl); + this._recordQueue = []; + + return records; + } +} + +module.exports = { + implementation: MutationObserverImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/mutation-observer/MutationRecord-impl.js b/node_modules/jsdom/lib/jsdom/living/mutation-observer/MutationRecord-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..fc16f3b55a5d7b331e4c78407c66eefca252adda --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/mutation-observer/MutationRecord-impl.js @@ -0,0 +1,37 @@ +"use strict"; + +const NodeList = require("../generated/NodeList"); + +// https://dom.spec.whatwg.org/#mutationrecord +class MutationRecordImpl { + constructor(globalObject, args, privateData) { + this._globalObject = globalObject; + + this.type = privateData.type; + this.target = privateData.target; + this.previousSibling = privateData.previousSibling; + this.nextSibling = privateData.nextSibling; + this.attributeName = privateData.attributeName; + this.attributeNamespace = privateData.attributeNamespace; + this.oldValue = privateData.oldValue; + + this._addedNodes = privateData.addedNodes; + this._removedNodes = privateData.removedNodes; + } + + get addedNodes() { + return NodeList.createImpl(this._globalObject, [], { + nodes: this._addedNodes + }); + } + + get removedNodes() { + return NodeList.createImpl(this._globalObject, [], { + nodes: this._removedNodes + }); + } +} + +module.exports = { + implementation: MutationRecordImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/navigator/MimeType-impl.js b/node_modules/jsdom/lib/jsdom/living/navigator/MimeType-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..e251c2a1535696167759b3727e9b0ddff05fac6a --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/navigator/MimeType-impl.js @@ -0,0 +1,3 @@ +"use strict"; + +exports.implementation = class MimeType {}; diff --git a/node_modules/jsdom/lib/jsdom/living/navigator/MimeTypeArray-impl.js b/node_modules/jsdom/lib/jsdom/living/navigator/MimeTypeArray-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..321ee51627a0be09468171a7bc7d1340ec4a734f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/navigator/MimeTypeArray-impl.js @@ -0,0 +1,21 @@ +"use strict"; + +const idlUtils = require("../generated/utils"); + +exports.implementation = class MimeTypeArray { + get length() { + return 0; + } + + item() { + return null; + } + + namedItem() { + return null; + } + + get [idlUtils.supportedPropertyIndices]() { + return []; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/navigator/Navigator-impl.js b/node_modules/jsdom/lib/jsdom/living/navigator/Navigator-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..3cc6a2eb14dbc6a87c484a5bb1def4f2e9267eed --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/navigator/Navigator-impl.js @@ -0,0 +1,29 @@ +"use strict"; +const { mixin } = require("../../utils"); +const PluginArray = require("../generated/PluginArray"); +const MimeTypeArray = require("../generated/MimeTypeArray"); +const NavigatorIDImpl = require("./NavigatorID-impl").implementation; +const NavigatorLanguageImpl = require("./NavigatorLanguage-impl").implementation; +const NavigatorOnLineImpl = require("./NavigatorOnLine-impl").implementation; +const NavigatorCookiesImpl = require("./NavigatorCookies-impl").implementation; +const NavigatorPluginsImpl = require("./NavigatorPlugins-impl").implementation; +const NavigatorConcurrentHardwareImpl = require("./NavigatorConcurrentHardware-impl").implementation; + +class NavigatorImpl { + constructor(globalObject, args, privateData) { + this._globalObject = globalObject; + this.userAgent = privateData.userAgent; + this.languages = Object.freeze(["en-US", "en"]); + this.plugins = PluginArray.create(this._globalObject); + this.mimeTypes = MimeTypeArray.create(this._globalObject); + } +} + +mixin(NavigatorImpl.prototype, NavigatorIDImpl.prototype); +mixin(NavigatorImpl.prototype, NavigatorLanguageImpl.prototype); +mixin(NavigatorImpl.prototype, NavigatorOnLineImpl.prototype); +mixin(NavigatorImpl.prototype, NavigatorCookiesImpl.prototype); +mixin(NavigatorImpl.prototype, NavigatorPluginsImpl.prototype); +mixin(NavigatorImpl.prototype, NavigatorConcurrentHardwareImpl.prototype); + +exports.implementation = NavigatorImpl; diff --git a/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorConcurrentHardware-impl.js b/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorConcurrentHardware-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..4fd29ad61e3eaac8542bb8446d468b5f822219bc --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorConcurrentHardware-impl.js @@ -0,0 +1,8 @@ +"use strict"; +const os = require("os"); + +exports.implementation = class NavigatorConcurrentHardwareImpl { + get hardwareConcurrency() { + return os.cpus().length; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorCookies-impl.js b/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorCookies-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..a66f677a68099e7655ea0f9e28254a54735869ce --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorCookies-impl.js @@ -0,0 +1,7 @@ +"use strict"; + +exports.implementation = class NavigatorCookiesImpl { + get cookieEnabled() { + return true; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorID-impl.js b/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorID-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..50aac664d0eec17af5a3c2ed30b7850a5fb9c3f2 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorID-impl.js @@ -0,0 +1,37 @@ +"use strict"; + +exports.implementation = class NavigatorIDImpl { + get appCodeName() { + return "Mozilla"; + } + + get appName() { + return "Netscape"; + } + + get appVersion() { + return "4.0"; + } + + get platform() { + return ""; + } + + get product() { + return "Gecko"; + } + + get productSub() { + return "20030107"; + } + + // see Navigator constructor for userAgent + + get vendor() { + return "Apple Computer, Inc."; + } + + get vendorSub() { + return ""; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorLanguage-impl.js b/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorLanguage-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..136a3fd74bf1359058a81d4bdd43106a29bcad4b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorLanguage-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +exports.implementation = class NavigatorLanguageImpl { + get language() { + return "en-US"; + } + + // See Navigator constructor for languages +}; diff --git a/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorOnLine-impl.js b/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorOnLine-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..44a977953768509347fe457b143aa052e6283030 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorOnLine-impl.js @@ -0,0 +1,7 @@ +"use strict"; + +exports.implementation = class NavigatorOnLineImpl { + get onLine() { + return true; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorPlugins-impl.js b/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorPlugins-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..4763ae61499f55de6f9cf9a1bbbee50aad7d81ea --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/navigator/NavigatorPlugins-impl.js @@ -0,0 +1,8 @@ +"use strict"; + +exports.implementation = class NavigatorPluginsImpl { + // plugins and mimeTypes are implemented in Navigator-impl.js + javaEnabled() { + return false; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/navigator/Plugin-impl.js b/node_modules/jsdom/lib/jsdom/living/navigator/Plugin-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..eff02fe9f143fbf3e4d2759f744580fac78ebadc --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/navigator/Plugin-impl.js @@ -0,0 +1,3 @@ +"use strict"; + +exports.implementation = class Plugin {}; diff --git a/node_modules/jsdom/lib/jsdom/living/navigator/PluginArray-impl.js b/node_modules/jsdom/lib/jsdom/living/navigator/PluginArray-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..9e72642cda7df77d32810bf0d687f2dbbb450e79 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/navigator/PluginArray-impl.js @@ -0,0 +1,23 @@ +"use strict"; + +const idlUtils = require("../generated/utils"); + +exports.implementation = class PluginArray { + refresh() {} + + get length() { + return 0; + } + + item() { + return null; + } + + namedItem() { + return null; + } + + get [idlUtils.supportedPropertyIndices]() { + return []; + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/node-document-position.js b/node_modules/jsdom/lib/jsdom/living/node-document-position.js new file mode 100644 index 0000000000000000000000000000000000000000..06485c014f7f7ea63de2c5cfb6984cfa91ffd37c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/node-document-position.js @@ -0,0 +1,10 @@ +"use strict"; + +module.exports = Object.freeze({ + DOCUMENT_POSITION_DISCONNECTED: 1, + DOCUMENT_POSITION_PRECEDING: 2, + DOCUMENT_POSITION_FOLLOWING: 4, + DOCUMENT_POSITION_CONTAINS: 8, + DOCUMENT_POSITION_CONTAINED_BY: 16, + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: 32 +}); diff --git a/node_modules/jsdom/lib/jsdom/living/node-type.js b/node_modules/jsdom/lib/jsdom/living/node-type.js new file mode 100644 index 0000000000000000000000000000000000000000..96f34051ab9a13fc1e2f435ab8ccd8385c1cdcb9 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/node-type.js @@ -0,0 +1,16 @@ +"use strict"; + +module.exports = Object.freeze({ + ELEMENT_NODE: 1, + ATTRIBUTE_NODE: 2, + TEXT_NODE: 3, + CDATA_SECTION_NODE: 4, // historical + ENTITY_REFERENCE_NODE: 5, // historical + ENTITY_NODE: 6, // historical + PROCESSING_INSTRUCTION_NODE: 7, + COMMENT_NODE: 8, + DOCUMENT_NODE: 9, + DOCUMENT_TYPE_NODE: 10, + DOCUMENT_FRAGMENT_NODE: 11, + NOTATION_NODE: 12 // historical +}); diff --git a/node_modules/jsdom/lib/jsdom/living/node.js b/node_modules/jsdom/lib/jsdom/living/node.js new file mode 100644 index 0000000000000000000000000000000000000000..a0e41c056d59cfff2d4bdde551eae9a3f6dbd65e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/node.js @@ -0,0 +1,331 @@ +"use strict"; +const { appendAttribute } = require("./attributes"); +const NODE_TYPE = require("./node-type"); + +const orderedSetParse = require("./helpers/ordered-set").parse; +const { createElement } = require("./helpers/create-element"); +const { HTML_NS, XMLNS_NS } = require("./helpers/namespaces"); +const { cloningSteps, domSymbolTree } = require("./helpers/internal-constants"); +const { asciiCaseInsensitiveMatch, asciiLowercase } = require("./helpers/strings"); + +const HTMLCollection = require("./generated/HTMLCollection"); + +exports.clone = (node, document, cloneChildren) => { + if (document === undefined) { + document = node._ownerDocument; + } + + let copy; + switch (node.nodeType) { + case NODE_TYPE.DOCUMENT_NODE: + // Can't use a simple `Document.createImpl` because of circular dependency issues :-/ + copy = node._cloneDocument(); + break; + + case NODE_TYPE.DOCUMENT_TYPE_NODE: + copy = document.implementation.createDocumentType(node.name, node.publicId, node.systemId); + break; + + case NODE_TYPE.ELEMENT_NODE: + copy = createElement( + document, + node._localName, + node._namespaceURI, + node._prefix, + node._isValue, + false + ); + + for (const attribute of node._attributeList) { + appendAttribute(copy, exports.clone(attribute, document)); + } + break; + + case NODE_TYPE.ATTRIBUTE_NODE: + copy = document._createAttribute({ + namespace: node._namespace, + namespacePrefix: node._namespacePrefix, + localName: node._localName, + value: node._value + }); + break; + + case NODE_TYPE.TEXT_NODE: + copy = document.createTextNode(node._data); + break; + + case NODE_TYPE.CDATA_SECTION_NODE: + copy = document.createCDATASection(node._data); + break; + + case NODE_TYPE.COMMENT_NODE: + copy = document.createComment(node._data); + break; + + case NODE_TYPE.PROCESSING_INSTRUCTION_NODE: + copy = document.createProcessingInstruction(node.target, node._data); + break; + + case NODE_TYPE.DOCUMENT_FRAGMENT_NODE: + copy = document.createDocumentFragment(); + break; + } + + if (node[cloningSteps]) { + node[cloningSteps](copy, node, document, cloneChildren); + } + + if (cloneChildren) { + for (const child of domSymbolTree.childrenIterator(node)) { + const childCopy = exports.clone(child, document, true); + copy._append(childCopy); + } + } + + return copy; +}; + +// For the following, memoization is not applied here since the memoized results are stored on `this`. + +exports.listOfElementsWithClassNames = (classNames, root) => { + // https://dom.spec.whatwg.org/#concept-getElementsByClassName + + const classes = orderedSetParse(classNames); + + if (classes.size === 0) { + return HTMLCollection.createImpl(root._globalObject, [], { element: root, query: () => [] }); + } + + return HTMLCollection.createImpl(root._globalObject, [], { + element: root, + query: () => { + const isQuirksMode = root._ownerDocument.compatMode === "BackCompat"; + + return domSymbolTree.treeToArray(root, { filter(node) { + if (node.nodeType !== NODE_TYPE.ELEMENT_NODE || node === root) { + return false; + } + + const { classList } = node; + if (isQuirksMode) { + for (const className of classes) { + if (!classList.tokenSet.some(cur => asciiCaseInsensitiveMatch(cur, className))) { + return false; + } + } + } else { + for (const className of classes) { + if (!classList.tokenSet.contains(className)) { + return false; + } + } + } + + return true; + } }); + } + }); +}; + +exports.listOfElementsWithQualifiedName = (qualifiedName, root) => { + // https://dom.spec.whatwg.org/#concept-getelementsbytagname + + if (qualifiedName === "*") { + return HTMLCollection.createImpl(root._globalObject, [], { + element: root, + query: () => domSymbolTree.treeToArray(root, { + filter: node => node.nodeType === NODE_TYPE.ELEMENT_NODE && node !== root + }) + }); + } + + if (root._ownerDocument._parsingMode === "html") { + const lowerQualifiedName = asciiLowercase(qualifiedName); + + return HTMLCollection.createImpl(root._globalObject, [], { + element: root, + query: () => domSymbolTree.treeToArray(root, { + filter(node) { + if (node.nodeType !== NODE_TYPE.ELEMENT_NODE || node === root) { + return false; + } + + if (node._namespaceURI === HTML_NS) { + return node._qualifiedName === lowerQualifiedName; + } + + return node._qualifiedName === qualifiedName; + } + }) + }); + } + + return HTMLCollection.createImpl(root._globalObject, [], { + element: root, + query: () => domSymbolTree.treeToArray(root, { + filter(node) { + if (node.nodeType !== NODE_TYPE.ELEMENT_NODE || node === root) { + return false; + } + + return node._qualifiedName === qualifiedName; + } + }) + }); +}; + +exports.listOfElementsWithNamespaceAndLocalName = (namespace, localName, root) => { + // https://dom.spec.whatwg.org/#concept-getelementsbytagnamens + + if (namespace === "") { + namespace = null; + } + + if (namespace === "*" && localName === "*") { + return HTMLCollection.createImpl(root._globalObject, [], { + element: root, + query: () => domSymbolTree.treeToArray(root, { + filter: node => node.nodeType === NODE_TYPE.ELEMENT_NODE && node !== root + }) + }); + } + + if (namespace === "*") { + return HTMLCollection.createImpl(root._globalObject, [], { + element: root, + query: () => domSymbolTree.treeToArray(root, { + filter(node) { + if (node.nodeType !== NODE_TYPE.ELEMENT_NODE || node === root) { + return false; + } + + return node._localName === localName; + } + }) + }); + } + + if (localName === "*") { + return HTMLCollection.createImpl(root._globalObject, [], { + element: root, + query: () => domSymbolTree.treeToArray(root, { + filter(node) { + if (node.nodeType !== NODE_TYPE.ELEMENT_NODE || node === root) { + return false; + } + + return node._namespaceURI === namespace; + } + }) + }); + } + + return HTMLCollection.createImpl(root._globalObject, [], { + element: root, + query: () => domSymbolTree.treeToArray(root, { + filter(node) { + if (node.nodeType !== NODE_TYPE.ELEMENT_NODE || node === root) { + return false; + } + + return node._localName === localName && node._namespaceURI === namespace; + } + }) + }); +}; + +// https://dom.spec.whatwg.org/#converting-nodes-into-a-node +// create a fragment (or just return a node for one item) +exports.convertNodesIntoNode = (document, nodes) => { + if (nodes.length === 1) { // note: I'd prefer to check instanceof Node rather than string + return typeof nodes[0] === "string" ? document.createTextNode(nodes[0]) : nodes[0]; + } + const fragment = document.createDocumentFragment(); + for (let i = 0; i < nodes.length; i++) { + fragment._append(typeof nodes[i] === "string" ? document.createTextNode(nodes[i]) : nodes[i]); + } + return fragment; +}; + +// https://dom.spec.whatwg.org/#locate-a-namespace-prefix +exports.locateNamespacePrefix = (element, namespace) => { + if (element._namespaceURI === namespace && element._prefix !== null) { + return element._prefix; + } + + for (const attribute of element._attributeList) { + if (attribute._namespacePrefix === "xmlns" && attribute._value === namespace) { + return attribute._localName; + } + } + + if (element.parentElement !== null) { + return exports.locateNamespacePrefix(element.parentElement, namespace); + } + + return null; +}; + +// https://dom.spec.whatwg.org/#locate-a-namespace +exports.locateNamespace = (node, prefix) => { + switch (node.nodeType) { + case NODE_TYPE.ELEMENT_NODE: { + if (node._namespaceURI !== null && node._prefix === prefix) { + return node._namespaceURI; + } + + if (prefix === null) { + for (const attribute of node._attributeList) { + if (attribute._namespace === XMLNS_NS && + attribute._namespacePrefix === null && + attribute._localName === "xmlns") { + return attribute._value !== "" ? attribute._value : null; + } + } + } else { + for (const attribute of node._attributeList) { + if (attribute._namespace === XMLNS_NS && + attribute._namespacePrefix === "xmlns" && + attribute._localName === prefix) { + return attribute._value !== "" ? attribute._value : null; + } + } + } + + if (node.parentElement === null) { + return null; + } + + return exports.locateNamespace(node.parentElement, prefix); + } + + case NODE_TYPE.DOCUMENT_NODE: { + if (node.documentElement === null) { + return null; + } + + return exports.locateNamespace(node.documentElement, prefix); + } + + case NODE_TYPE.DOCUMENT_TYPE_NODE: + case NODE_TYPE.DOCUMENT_FRAGMENT_NODE: { + return null; + } + + case NODE_TYPE.ATTRIBUTE_NODE: { + if (node._element === null) { + return null; + } + + return exports.locateNamespace(node._element, prefix); + } + + default: { + if (node.parentElement === null) { + return null; + } + + return exports.locateNamespace(node.parentElement, prefix); + } + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/CDATASection-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/CDATASection-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..d9e62481a1bee4998e4b72dce0842e4d85c3452b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/CDATASection-impl.js @@ -0,0 +1,16 @@ +"use strict"; + +const TextImpl = require("./Text-impl").implementation; +const NODE_TYPE = require("../node-type"); + +class CDATASectionImpl extends TextImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this.nodeType = NODE_TYPE.CDATA_SECTION_NODE; + } +} + +module.exports = { + implementation: CDATASectionImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/CharacterData-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/CharacterData-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..1d036df492c68f6ea6abaced8bef23808508a139 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/CharacterData-impl.js @@ -0,0 +1,118 @@ +"use strict"; + +const DOMException = require("../generated/DOMException"); + +const { mixin } = require("../../utils"); +const NodeImpl = require("./Node-impl").implementation; +const ChildNodeImpl = require("./ChildNode-impl").implementation; +const NonDocumentTypeChildNodeImpl = require("./NonDocumentTypeChildNode-impl").implementation; + +const { TEXT_NODE } = require("../node-type"); +const { MUTATION_TYPE, queueMutationRecord } = require("../helpers/mutation-observers"); + +// https://dom.spec.whatwg.org/#characterdata +class CharacterDataImpl extends NodeImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this._data = privateData.data; + } + + // https://dom.spec.whatwg.org/#dom-characterdata-data + get data() { + return this._data; + } + set data(data) { + this.replaceData(0, this.length, data); + } + + // https://dom.spec.whatwg.org/#dom-characterdata-length + get length() { + return this._data.length; + } + + // https://dom.spec.whatwg.org/#dom-characterdata-substringdata + // https://dom.spec.whatwg.org/#concept-cd-substring + substringData(offset, count) { + const { length } = this; + + if (offset > length) { + throw DOMException.create(this._globalObject, ["The index is not in the allowed range.", "IndexSizeError"]); + } + + if (offset + count > length) { + return this._data.slice(offset); + } + + return this._data.slice(offset, offset + count); + } + + // https://dom.spec.whatwg.org/#dom-characterdata-appenddata + appendData(data) { + this.replaceData(this.length, 0, data); + } + + // https://dom.spec.whatwg.org/#dom-characterdata-insertdata + insertData(offset, data) { + this.replaceData(offset, 0, data); + } + + // https://dom.spec.whatwg.org/#dom-characterdata-deletedata + deleteData(offset, count) { + this.replaceData(offset, count, ""); + } + + // https://dom.spec.whatwg.org/#dom-characterdata-replacedata + // https://dom.spec.whatwg.org/#concept-cd-replace + replaceData(offset, count, data) { + const { length } = this; + + if (offset > length) { + throw DOMException.create(this._globalObject, [ + "The index is not in the allowed range.", + "IndexSizeError" + ]); + } + + if (offset + count > length) { + count = length - offset; + } + + queueMutationRecord(MUTATION_TYPE.CHARACTER_DATA, this, null, null, this._data, [], [], null, null); + + const start = this._data.slice(0, offset); + const end = this._data.slice(offset + count); + this._data = start + data + end; + + for (const range of this._referencedRanges) { + const { _start, _end } = range; + + if (_start.node === this && _start.offset > offset && _start.offset <= offset + count) { + range._setLiveRangeStart(this, offset); + } + + if (_end.node === this && _end.offset > offset && _end.offset <= offset + count) { + range._setLiveRangeEnd(this, offset); + } + + if (_start.node === this && _start.offset > offset + count) { + range._setLiveRangeStart(this, _start.offset + data.length - count); + } + + if (_end.node === this && _end.offset > offset + count) { + range._setLiveRangeEnd(this, _end.offset + data.length - count); + } + } + + if (this.nodeType === TEXT_NODE && this.parentNode) { + this.parentNode._childTextContentChangeSteps(); + } + } +} + +mixin(CharacterDataImpl.prototype, NonDocumentTypeChildNodeImpl.prototype); +mixin(CharacterDataImpl.prototype, ChildNodeImpl.prototype); + +module.exports = { + implementation: CharacterDataImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/ChildNode-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/ChildNode-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..799e44fe4b1071ba0fbc4db8a9c2603b799017c8 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/ChildNode-impl.js @@ -0,0 +1,80 @@ +"use strict"; + +const { convertNodesIntoNode } = require("../node"); + +class ChildNodeImpl { + remove() { + if (!this.parentNode) { + return; + } + + this.parentNode._remove(this); + } + + after(...nodes) { + const parent = this.parentNode; + if (parent) { + let viableNextSibling = this.nextSibling; + let idx = viableNextSibling ? nodes.indexOf(viableNextSibling) : -1; + + while (idx !== -1) { + viableNextSibling = viableNextSibling.nextSibling; + if (!viableNextSibling) { + break; + } + idx = nodes.indexOf(viableNextSibling); + } + + parent._preInsert(convertNodesIntoNode(this._ownerDocument, nodes), viableNextSibling); + } + } + + before(...nodes) { + const parent = this.parentNode; + if (parent) { + let viablePreviousSibling = this.previousSibling; + let idx = viablePreviousSibling ? nodes.indexOf(viablePreviousSibling) : -1; + + while (idx !== -1) { + viablePreviousSibling = viablePreviousSibling.previousSibling; + if (!viablePreviousSibling) { + break; + } + idx = nodes.indexOf(viablePreviousSibling); + } + + parent._preInsert( + convertNodesIntoNode(this._ownerDocument, nodes), + viablePreviousSibling ? viablePreviousSibling.nextSibling : parent.firstChild + ); + } + } + + replaceWith(...nodes) { + const parent = this.parentNode; + if (parent) { + let viableNextSibling = this.nextSibling; + let idx = viableNextSibling ? nodes.indexOf(viableNextSibling) : -1; + + while (idx !== -1) { + viableNextSibling = viableNextSibling.nextSibling; + if (!viableNextSibling) { + break; + } + idx = nodes.indexOf(viableNextSibling); + } + + const node = convertNodesIntoNode(this._ownerDocument, nodes); + + if (this.parentNode === parent) { + parent._replace(node, this); + } else { + parent._preInsert(node, viableNextSibling); + } + } + } +} + +module.exports = { + implementation: ChildNodeImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/Comment-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/Comment-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..b0ab40edebd6295edc66d1a25cb7a01154b1c294 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/Comment-impl.js @@ -0,0 +1,20 @@ +"use strict"; +const CharacterDataImpl = require("./CharacterData-impl").implementation; +const idlUtils = require("../generated/utils"); +const NODE_TYPE = require("../node-type"); + +class CommentImpl extends CharacterDataImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, { + data: args[0], + ownerDocument: idlUtils.implForWrapper(globalObject._document), + ...privateData + }); + + this.nodeType = NODE_TYPE.COMMENT_NODE; + } +} + +module.exports = { + implementation: CommentImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/DOMImplementation-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/DOMImplementation-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..e65255cbefda8dc3cb174ef41df2eed3b6d100cf --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/DOMImplementation-impl.js @@ -0,0 +1,120 @@ +"use strict"; + +const validateNames = require("../helpers/validate-names"); +const { HTML_NS, SVG_NS } = require("../helpers/namespaces"); +const { createElement, internalCreateElementNSSteps } = require("../helpers/create-element"); +const DocumentType = require("../generated/DocumentType"); +const documents = require("../documents.js"); + +class DOMImplementationImpl { + constructor(globalObject, args, privateData) { + this._globalObject = globalObject; + this._ownerDocument = privateData.ownerDocument; + } + + hasFeature() { + return true; + } + + createDocumentType(qualifiedName, publicId, systemId) { + validateNames.qname(this._globalObject, qualifiedName); + + return DocumentType.createImpl(this._globalObject, [], { + ownerDocument: this._ownerDocument, + name: qualifiedName, + publicId, + systemId + }); + } + + // https://dom.spec.whatwg.org/#dom-domimplementation-createdocument + createDocument(namespace, qualifiedName, doctype) { + let contentType = "application/xml"; + + if (namespace === HTML_NS) { + contentType = "application/xhtml+xml"; + } else if (namespace === SVG_NS) { + contentType = "image/svg+xml"; + } + + const document = documents.createImpl(this._globalObject, { + contentType, + parsingMode: "xml", + encoding: "UTF-8" + }); + + let element = null; + if (qualifiedName !== "") { + element = internalCreateElementNSSteps(document, namespace, qualifiedName, {}); + } + + if (doctype !== null) { + document.appendChild(doctype); + } + + if (element !== null) { + document.appendChild(element); + } + + document._origin = this._ownerDocument._origin; + + return document; + } + + // https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument + createHTMLDocument(title) { + // Let doc be a new document that is an HTML document. + // Set doc's content type to "text/html". + const document = documents.createImpl(this._globalObject, { + parsingMode: "html", + encoding: "UTF-8" + }); + + // Create a doctype, with "html" as its name and with its node document set + // to doc. Append the newly created node to doc. + const doctype = DocumentType.createImpl(this._globalObject, [], { + ownerDocument: document, + name: "html", + publicId: "", + systemId: "" + }); + + document.appendChild(doctype); + + // Create an html element in the HTML namespace, and append it to doc. + const htmlElement = createElement(document, "html", HTML_NS); + document.appendChild(htmlElement); + + // Create a head element in the HTML namespace, and append it to the html + // element created in the previous step. + const headElement = createElement(document, "head", HTML_NS); + htmlElement.appendChild(headElement); + + // If the title argument is not omitted: + if (title !== undefined) { + // Create a title element in the HTML namespace, and append it to the head + // element created in the previous step. + const titleElement = createElement(document, "title", HTML_NS); + headElement.appendChild(titleElement); + + // Create a Text node, set its data to title (which could be the empty + // string), and append it to the title element created in the previous step. + titleElement.appendChild(document.createTextNode(title)); + } + + // Create a body element in the HTML namespace, and append it to the html + // element created in the earlier step. + const bodyElement = createElement(document, "body", HTML_NS); + htmlElement.appendChild(bodyElement); + + // doc's origin is an alias to the origin of the context object's associated + // document, and doc's effective script origin is an alias to the effective + // script origin of the context object's associated document. + + return document; + } +} + +module.exports = { + implementation: DOMImplementationImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/DOMStringMap-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/DOMStringMap-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..58a86b2f355fe06be4b92cdd232c6f608e3c3c9b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/DOMStringMap-impl.js @@ -0,0 +1,64 @@ +"use strict"; + +const idlUtils = require("../generated/utils.js"); +const { setAttributeValue, removeAttributeByName } = require("../attributes"); +const validateName = require("../helpers/validate-names").name; +const DOMException = require("../generated/DOMException"); + +const dataAttrRe = /^data-([^A-Z]*)$/; + +function attrCamelCase(name) { + return name.replace(/-([a-z])/g, (match, alpha) => alpha.toUpperCase()); +} + +function attrSnakeCase(name) { + return name.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`); +} + +exports.implementation = class DOMStringMapImpl { + constructor(globalObject, args, privateData) { + this._globalObject = globalObject; + this._element = privateData.element; + } + get [idlUtils.supportedPropertyNames]() { + const result = new Set(); + const { attributes } = this._element; + for (let i = 0; i < attributes.length; i++) { + const attr = attributes.item(i); + const matches = dataAttrRe.exec(attr.localName); + if (matches) { + result.add(attrCamelCase(matches[1])); + } + } + return result; + } + [idlUtils.namedGet](name) { + const { attributes } = this._element; + for (let i = 0; i < attributes.length; i++) { + const attr = attributes.item(i); + const matches = dataAttrRe.exec(attr.localName); + if (matches && attrCamelCase(matches[1]) === name) { + return attr.value; + } + } + return undefined; + } + [idlUtils.namedSetNew](name, value) { + if (/-[a-z]/.test(name)) { + throw DOMException.create(this._globalObject, [ + `'${name}' is not a valid property name`, + "SyntaxError" + ]); + } + name = `data-${attrSnakeCase(name)}`; + validateName(this._globalObject, name); + setAttributeValue(this._element, name, value); + } + [idlUtils.namedSetExisting](name, value) { + this[idlUtils.namedSetNew](name, value); + } + [idlUtils.namedDelete](name) { + name = `data-${attrSnakeCase(name)}`; + removeAttributeByName(this._element, name); + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/DOMTokenList-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/DOMTokenList-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..d6fb02d81e980478267026630da68c0e2b8ae0a7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/DOMTokenList-impl.js @@ -0,0 +1,171 @@ +"use strict"; + +const DOMException = require("../generated/DOMException"); +const OrderedSet = require("../helpers/ordered-set.js"); +const { asciiLowercase } = require("../helpers/strings.js"); +const idlUtils = require("../generated/utils.js"); + +const { getAttributeValue, setAttributeValue, hasAttributeByName } = require("../attributes.js"); + +function validateTokens(globalObject, ...tokens) { + for (const token of tokens) { + if (token === "") { + throw DOMException.create(globalObject, ["The token provided must not be empty.", "SyntaxError"]); + } + } + for (const token of tokens) { + if (/[\t\n\f\r ]/.test(token)) { + throw DOMException.create(globalObject, [ + "The token provided contains HTML space characters, which are not valid in tokens.", + "InvalidCharacterError" + ]); + } + } +} + +// https://dom.spec.whatwg.org/#domtokenlist +class DOMTokenListImpl { + constructor(globalObject, args, privateData) { + this._globalObject = globalObject; + + // _syncWithElement() must always be called before any _tokenSet access. + this._tokenSet = new OrderedSet(); + this._element = privateData.element; + this._attributeLocalName = privateData.attributeLocalName; + this._supportedTokens = privateData.supportedTokens; + + // Needs synchronization with element if token set is to be accessed. + this._dirty = true; + } + + attrModified() { + this._dirty = true; + } + + _syncWithElement() { + if (!this._dirty) { + return; + } + + const val = getAttributeValue(this._element, this._attributeLocalName); + if (val === null) { + this._tokenSet.empty(); + } else { + this._tokenSet = OrderedSet.parse(val); + } + + this._dirty = false; + } + + _validationSteps(token) { + if (!this._supportedTokens) { + throw new TypeError(`${this._attributeLocalName} attribute has no supported tokens`); + } + const lowerToken = asciiLowercase(token); + return this._supportedTokens.has(lowerToken); + } + + _updateSteps() { + if (!hasAttributeByName(this._element, this._attributeLocalName) && this._tokenSet.isEmpty()) { + return; + } + setAttributeValue(this._element, this._attributeLocalName, this._tokenSet.serialize()); + } + + _serializeSteps() { + return getAttributeValue(this._element, this._attributeLocalName); + } + + // Used by other parts of jsdom + get tokenSet() { + this._syncWithElement(); + return this._tokenSet; + } + + get length() { + this._syncWithElement(); + return this._tokenSet.size; + } + + get [idlUtils.supportedPropertyIndices]() { + this._syncWithElement(); + return this._tokenSet.keys(); + } + + item(index) { + this._syncWithElement(); + if (index >= this._tokenSet.size) { + return null; + } + return this._tokenSet.get(index); + } + + contains(token) { + this._syncWithElement(); + return this._tokenSet.contains(token); + } + + add(...tokens) { + for (const token of tokens) { + validateTokens(this._globalObject, token); + } + this._syncWithElement(); + for (const token of tokens) { + this._tokenSet.append(token); + } + this._updateSteps(); + } + + remove(...tokens) { + for (const token of tokens) { + validateTokens(this._globalObject, token); + } + this._syncWithElement(); + this._tokenSet.remove(...tokens); + this._updateSteps(); + } + + toggle(token, force = undefined) { + validateTokens(this._globalObject, token); + this._syncWithElement(); + if (this._tokenSet.contains(token)) { + if (force === undefined || force === false) { + this._tokenSet.remove(token); + this._updateSteps(); + return false; + } + return true; + } + if (force === undefined || force === true) { + this._tokenSet.append(token); + this._updateSteps(); + return true; + } + return false; + } + + replace(token, newToken) { + validateTokens(this._globalObject, token, newToken); + this._syncWithElement(); + if (!this._tokenSet.contains(token)) { + return false; + } + this._tokenSet.replace(token, newToken); + this._updateSteps(); + return true; + } + + supports(token) { + return this._validationSteps(token); + } + + get value() { + return this._serializeSteps(); + } + + set value(V) { + setAttributeValue(this._element, this._attributeLocalName, V); + } +} + +exports.implementation = DOMTokenListImpl; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..7377646eccd75def5e43c67d313f1108edd48bbc --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js @@ -0,0 +1,1014 @@ +"use strict"; + +const { CookieJar } = require("tough-cookie"); +const { DOMSelector } = require("@asamuzakjp/dom-selector"); + +const NodeImpl = require("./Node-impl").implementation; +const idlUtils = require("../generated/utils"); +const NODE_TYPE = require("../node-type"); +const { mixin, memoizeQuery } = require("../../utils"); +const { firstChildWithLocalName, firstChildWithLocalNames, firstDescendantWithLocalName } = + require("../helpers/traversal"); +const whatwgURL = require("whatwg-url"); +const StyleSheetList = require("../generated/StyleSheetList.js"); +const { domSymbolTree } = require("../helpers/internal-constants"); +const eventAccessors = require("../helpers/create-event-accessor"); +const { asciiLowercase, stripAndCollapseASCIIWhitespace } = require("../helpers/strings"); +const { childTextContent } = require("../helpers/text"); +const { HTML_NS, SVG_NS } = require("../helpers/namespaces"); +const DOMException = require("../generated/DOMException"); +const { parseIntoDocument } = require("../../browser/parser"); +const History = require("../generated/History"); +const Location = require("../generated/Location"); +const HTMLCollection = require("../generated/HTMLCollection"); +const NodeList = require("../generated/NodeList"); +const validateName = require("../helpers/validate-names").name; +const { validateAndExtract } = require("../helpers/validate-names"); +const { fireAnEvent } = require("../helpers/events"); +const { shadowIncludingInclusiveDescendantsIterator } = require("../helpers/shadow-dom"); +const { enqueueCECallbackReaction } = require("../helpers/custom-elements"); +const { createElement, internalCreateElementNSSteps } = require("../helpers/create-element"); +const IterableWeakSet = require("../helpers/iterable-weak-set"); + +const DocumentOrShadowRootImpl = require("./DocumentOrShadowRoot-impl").implementation; +const GlobalEventHandlersImpl = require("./GlobalEventHandlers-impl").implementation; +const NonElementParentNodeImpl = require("./NonElementParentNode-impl").implementation; +const ParentNodeImpl = require("./ParentNode-impl").implementation; + +const { clone, listOfElementsWithQualifiedName, listOfElementsWithNamespaceAndLocalName, + listOfElementsWithClassNames } = require("../node"); +const generatedAttr = require("../generated/Attr"); +const Comment = require("../generated/Comment"); +const ProcessingInstruction = require("../generated/ProcessingInstruction"); +const CDATASection = require("../generated/CDATASection"); +const Text = require("../generated/Text"); +const DocumentFragment = require("../generated/DocumentFragment"); +const DOMImplementation = require("../generated/DOMImplementation"); +const TreeWalker = require("../generated/TreeWalker"); +const NodeIterator = require("../generated/NodeIterator"); +const ShadowRoot = require("../generated/ShadowRoot"); +const Range = require("../generated/Range"); +const documents = require("../documents.js"); + +const BeforeUnloadEvent = require("../generated/BeforeUnloadEvent"); +const CompositionEvent = require("../generated/CompositionEvent"); +const CustomEvent = require("../generated/CustomEvent"); +const DeviceMotionEvent = require("../generated/DeviceMotionEvent"); +const DeviceOrientationEvent = require("../generated/DeviceOrientationEvent"); +const Event = require("../generated/Event"); +const FocusEvent = require("../generated/FocusEvent"); +const HashChangeEvent = require("../generated/HashChangeEvent"); +const KeyboardEvent = require("../generated/KeyboardEvent"); +const MessageEvent = require("../generated/MessageEvent"); +const MouseEvent = require("../generated/MouseEvent"); +const StorageEvent = require("../generated/StorageEvent"); +const TouchEvent = require("../generated/TouchEvent"); +const UIEvent = require("../generated/UIEvent"); + +const RequestManager = require("../../browser/resources/request-manager"); +const AsyncResourceQueue = require("../../browser/resources/async-resource-queue"); +const ResourceQueue = require("../../browser/resources/resource-queue"); +const PerDocumentResourceLoader = require("../../browser/resources/per-document-resource-loader"); + +function clearChildNodes(node) { + for (let child = domSymbolTree.firstChild(node); child; child = domSymbolTree.firstChild(node)) { + node.removeChild(child); + } +} + +function pad(number) { + if (number < 10) { + return "0" + number; + } + return number; +} + +function toLastModifiedString(date) { + return pad(date.getMonth() + 1) + + "/" + pad(date.getDate()) + + "/" + date.getFullYear() + + " " + pad(date.getHours()) + + ":" + pad(date.getMinutes()) + + ":" + pad(date.getSeconds()); +} + +const eventInterfaceTable = { + beforeunloadevent: BeforeUnloadEvent, + compositionevent: CompositionEvent, + customevent: CustomEvent, + devicemotionevent: DeviceMotionEvent, + deviceorientationevent: DeviceOrientationEvent, + event: Event, + events: Event, + focusevent: FocusEvent, + hashchangeevent: HashChangeEvent, + htmlevents: Event, + keyboardevent: KeyboardEvent, + messageevent: MessageEvent, + mouseevent: MouseEvent, + mouseevents: MouseEvent, + storageevent: StorageEvent, + svgevents: Event, + touchevent: TouchEvent, + uievent: UIEvent, + uievents: UIEvent +}; + +class DocumentImpl extends NodeImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this._initGlobalEvents(); + + this._ownerDocument = this; + this.nodeType = NODE_TYPE.DOCUMENT_NODE; + if (!privateData.options) { + privateData.options = {}; + } + if (!privateData.options.parsingMode) { + privateData.options.parsingMode = "xml"; + } + if (!privateData.options.encoding) { + privateData.options.encoding = "UTF-8"; + } + if (!privateData.options.contentType) { + privateData.options.contentType = privateData.options.parsingMode === "xml" ? "application/xml" : "text/html"; + } + + this._parsingMode = privateData.options.parsingMode; + + this._implementation = DOMImplementation.createImpl(this._globalObject, [], { + ownerDocument: this + }); + + this._defaultView = privateData.options.defaultView || null; + this._global = privateData.options.global; + this._ids = Object.create(null); + this._attached = true; + this._currentScript = null; + this._pageShowingFlag = false; + this._cookieJar = privateData.options.cookieJar; + this._parseOptions = privateData.options.parseOptions || {}; + this._scriptingDisabled = privateData.options.scriptingDisabled; + if (this._cookieJar === undefined) { + this._cookieJar = new CookieJar(null, { looseMode: true }); + } + + if (this._scriptingDisabled) { + this._parseOptions.scriptingEnabled = false; + } + + this.contentType = privateData.options.contentType; + this._encoding = privateData.options.encoding; + + const urlOption = privateData.options.url === undefined ? "about:blank" : privateData.options.url; + const parsed = whatwgURL.parseURL(urlOption); + if (parsed === null) { + throw new TypeError(`Could not parse "${urlOption}" as a URL`); + } + + this._URL = parsed; + this._origin = urlOption === "about:blank" && privateData.options.parentOrigin ? + privateData.options.parentOrigin : + whatwgURL.serializeURLOrigin(this._URL); + + this._location = Location.createImpl(this._globalObject, [], { relevantDocument: this }); + this._history = History.createImpl(this._globalObject, [], { + window: this._defaultView, + document: this, + actAsIfLocationReloadCalled: () => this._location.reload() + }); + + this._workingNodeIterators = new IterableWeakSet(); + + this._referrer = privateData.options.referrer || ""; + this._lastModified = toLastModifiedString(privateData.options.lastModified || new Date()); + this._asyncQueue = new AsyncResourceQueue(); + this._queue = new ResourceQueue({ asyncQueue: this._asyncQueue, paused: false }); + this._deferQueue = new ResourceQueue({ paused: true }); + this._requestManager = new RequestManager(); + this._currentDocumentReadiness = privateData.options.readyState || "loading"; + + this._lastFocusedElement = null; + + this._resourceLoader = new PerDocumentResourceLoader(this); + + // Each Document in a browsing context can also have a latest entry. This is the entry for that Document + // to which the browsing context's session history was most recently traversed. When a Document is created, + // it initially has no latest entry. + this._latestEntry = null; + + // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#throw-on-dynamic-markup-insertion-counter + this._throwOnDynamicMarkupInsertionCounter = 0; + + // Create DOMSelector instance + this._domSelector = new DOMSelector(this._globalObject, this._ownerDocument, { + domSymbolTree, + idlUtils + }); + + // Cache of computed element styles + this._styleCache = null; + + // Cache of document base URL + this._baseURLCache = null; + this._baseURLSerializedCache = null; + } + + _clearBaseURLCache() { + this._baseURLCache = null; + this._baseURLSerializedCache = null; + } + + // https://html.spec.whatwg.org/multipage/infrastructure.html#document-base-url + baseURL() { + if (this._baseURLCache) { + return this._baseURLCache; + } + + const firstBase = this.querySelector("base[href]"); + + this._baseURLCache = firstBase === null ? + this._fallbackBaseURL() : + this._frozenBaseURL(firstBase, this._fallbackBaseURL()); + return this._baseURLCache; + } + + baseURLSerialized() { + if (this._baseURLSerializedCache) { + return this._baseURLSerializedCache; + } + + const result = whatwgURL.serializeURL(this.baseURL()); + this._baseURLSerializedCache = result; + return result; + } + + // https://html.spec.whatwg.org/#resolve-a-url + encodingParseAURL(url) { + // TODO account for encoding (once whatwg-url supports that) + return whatwgURL.parseURL(url, { baseURL: this.baseURL() }); + } + + // https://html.spec.whatwg.org/#frozen-base-url + _frozenBaseURL(baseElement, fallbackBaseURL) { + // The spec is eager (setting the frozen base URL when things change); we are lazy (getting it when we need to). + // + // There is a slight difference, which is when history.pushState() is involved. The frozen base URL does not get + // updated in response to history.pushState() per spec, but since we're lazy, it will get updated. + // + // The test in to-port-to-wpts/history.js checks for the current jsdom behavior (which is incorrect). + // We could make it pass by not invalidating the base URL cache, actually. But that would just make the fallback + // base URL case use the stale base URL. + // + // TODO: implement, with tests for all code paths, the spec's behavior. + + const baseHrefAttribute = baseElement.getAttributeNS(null, "href"); + const result = whatwgURL.parseURL(baseHrefAttribute, { baseURL: fallbackBaseURL }); + return result === null ? fallbackBaseURL : result; + } + + // https://html.spec.whatwg.org/#fallback-base-url + _fallbackBaseURL() { + if (this.URL === "about:blank" && this._defaultView && + this._defaultView._parent !== this._defaultView) { + const parentDocument = idlUtils.implForWrapper(this._defaultView._parent._document); + return parentDocument.baseURL(); + } + + return this._URL; + } + + _getTheParent(event) { + if (event.type === "load" || !this._defaultView) { + return null; + } + + return idlUtils.implForWrapper(this._defaultView); + } + + get compatMode() { + return this._parsingMode === "xml" || this.doctype ? "CSS1Compat" : "BackCompat"; + } + get charset() { + return this._encoding; + } + get characterSet() { + return this._encoding; + } + get inputEncoding() { + return this._encoding; + } + get doctype() { + for (const childNode of domSymbolTree.childrenIterator(this)) { + if (childNode.nodeType === NODE_TYPE.DOCUMENT_TYPE_NODE) { + return childNode; + } + } + return null; + } + get URL() { + return whatwgURL.serializeURL(this._URL); + } + get documentURI() { + return whatwgURL.serializeURL(this._URL); + } + get location() { + return this._defaultView ? this._location : null; + } + + // https://dom.spec.whatwg.org/#dom-document-documentelement + get documentElement() { + for (const childNode of domSymbolTree.childrenIterator(this)) { + if (childNode.nodeType === NODE_TYPE.ELEMENT_NODE) { + return childNode; + } + } + + return null; + } + + get implementation() { + return this._implementation; + } + set implementation(implementation) { + this._implementation = implementation; + } + + get defaultView() { + return this._defaultView; + } + + get currentScript() { + return this._currentScript; + } + + get readyState() { + return this._currentDocumentReadiness; + } + + set readyState(state) { + this._currentDocumentReadiness = state; + fireAnEvent("readystatechange", this); + } + + hasFocus() { + return Boolean(this._lastFocusedElement); + } + + _descendantRemoved(parent, child) { + if (child.tagName === "STYLE") { + this.styleSheets._remove(child.sheet); + } + + super._descendantRemoved(parent, child); + } + + write(...args) { + let text = ""; + for (let i = 0; i < args.length; ++i) { + text += args[i]; + } + + if (this._parsingMode === "xml") { + throw DOMException.create(this._globalObject, [ + "Cannot use document.write on XML documents", + "InvalidStateError" + ]); + } + + if (this._throwOnDynamicMarkupInsertionCounter > 0) { + throw DOMException.create(this._globalObject, [ + "Cannot use document.write while a custom element upgrades", + "InvalidStateError" + ]); + } + + if (this._writeAfterElement) { + // If called from an script element directly (during the first tick), + // the new elements are inserted right after that element. + const tempDiv = this.createElement("div"); + tempDiv.innerHTML = text; + + let child = tempDiv.firstChild; + let previous = this._writeAfterElement; + const parent = this._writeAfterElement.parentNode; + + while (child) { + const node = child; + child = child.nextSibling; + + node._isMovingDueToDocumentWrite = true; // hack for script execution + parent.insertBefore(node, previous.nextSibling); + node._isMovingDueToDocumentWrite = false; + + previous = node; + } + } else if (this.readyState === "loading") { + // During page loading, document.write appends to the current element + // Find the last child that has been added to the document. + if (this.lastChild) { + let node = this; + while (node.lastChild && node.lastChild.nodeType === NODE_TYPE.ELEMENT_NODE) { + node = node.lastChild; + } + node.innerHTML = text; + } else { + clearChildNodes(this); + parseIntoDocument(text, this); + } + } else if (text) { + clearChildNodes(this); + parseIntoDocument(text, this); + } + } + + writeln(...args) { + this.write(...args, "\n"); + } + + // This is implemented separately for Document (which has a _ids cache) and DocumentFragment (which does not). + getElementById(id) { + if (!this._ids[id]) { + return null; + } + + // Let's find the first element with where it's root is the document. + const matchElement = this._ids[id].find(candidate => { + let root = candidate; + while (domSymbolTree.parent(root)) { + root = domSymbolTree.parent(root); + } + + return root === this; + }); + + return matchElement || null; + } + + get referrer() { + return this._referrer || ""; + } + get lastModified() { + return this._lastModified; + } + get images() { + return this.getElementsByTagName("IMG"); + } + get embeds() { + return this.getElementsByTagName("EMBED"); + } + get plugins() { + return this.embeds; + } + get links() { + return HTMLCollection.createImpl(this._globalObject, [], { + element: this, + query: () => domSymbolTree.treeToArray(this, { + filter: node => (node._localName === "a" || node._localName === "area") && + node.hasAttributeNS(null, "href") && + node._namespaceURI === HTML_NS + }) + }); + } + get forms() { + return this.getElementsByTagName("FORM"); + } + get scripts() { + return this.getElementsByTagName("SCRIPT"); + } + get anchors() { + return HTMLCollection.createImpl(this._globalObject, [], { + element: this, + query: () => domSymbolTree.treeToArray(this, { + filter: node => node._localName === "a" && + node.hasAttributeNS(null, "name") && + node._namespaceURI === HTML_NS + }) + }); + } + + // The applets attribute must return an + // HTMLCollection rooted at the Document node, + // whose filter matches nothing. + // (It exists for historical reasons.) + get applets() { + return HTMLCollection.createImpl(this._globalObject, [], { + element: this, + query: () => [] + }); + } + + open() { + let child = domSymbolTree.firstChild(this); + while (child) { + this.removeChild(child); + child = domSymbolTree.firstChild(this); + } + this._modified(); + return this; + } + close(noQueue) { + // In some cases like when creating an empty iframe, I want to emit the + // events right away to avoid problems if later I asign the property src. + if (noQueue) { + this.readyState = "complete"; + + fireAnEvent("DOMContentLoaded", this, undefined, { bubbles: true }); + fireAnEvent("load", this); + + return; + } + this._queue.resume(); + + const dummyPromise = Promise.resolve(); + + const onDOMContentLoad = () => { + const doc = this; + function dispatchEvent() { + // https://html.spec.whatwg.org/#the-end + doc.readyState = "interactive"; + fireAnEvent("DOMContentLoaded", doc, undefined, { bubbles: true }); + } + + return new Promise(resolve => { + if (!this._deferQueue.tail) { + dispatchEvent(); + resolve(); + return; + } + + this._deferQueue.setListener(() => { + dispatchEvent(); + resolve(); + }); + + this._deferQueue.resume(); + }); + }; + + const onLoad = () => { + const doc = this; + function dispatchEvent() { + doc.readyState = "complete"; + fireAnEvent("load", doc); + } + + return new Promise(resolve => { + if (this._asyncQueue.count() === 0) { + dispatchEvent(); + resolve(); + return; + } + + this._asyncQueue.setListener(() => { + dispatchEvent(); + resolve(); + }); + }); + }; + + this._queue.push(dummyPromise, onDOMContentLoad, null); + // Set the readyState to 'complete' once all resources are loaded. + // As a side-effect the document's load-event will be dispatched. + this._queue.push(dummyPromise, onLoad, null, true); + } + + getElementsByName(elementName) { + return NodeList.createImpl(this._globalObject, [], { + element: this, + query: () => domSymbolTree.treeToArray(this, { + filter: node => node.getAttributeNS && node.getAttributeNS(null, "name") === elementName + }) + }); + } + + get title() { + const { documentElement } = this; + let value = ""; + + if (documentElement && documentElement._localName === "svg") { + const svgTitleElement = firstChildWithLocalName(documentElement, "title", SVG_NS); + + if (svgTitleElement) { + value = childTextContent(svgTitleElement); + } + } else { + const titleElement = firstDescendantWithLocalName(this, "title"); + + if (titleElement) { + value = childTextContent(titleElement); + } + } + + value = stripAndCollapseASCIIWhitespace(value); + + return value; + } + + set title(value) { + const { documentElement } = this; + let element; + + if (documentElement && documentElement._localName === "svg") { + element = firstChildWithLocalName(documentElement, "title", SVG_NS); + + if (!element) { + element = this.createElementNS(SVG_NS, "title"); + + this._insert(element, documentElement.firstChild); + } + + element.textContent = value; + } else if (documentElement && documentElement._namespaceURI === HTML_NS) { + const titleElement = firstDescendantWithLocalName(this, "title"); + const headElement = this.head; + + if (titleElement === null && headElement === null) { + return; + } + + if (titleElement !== null) { + element = titleElement; + } else { + element = this.createElement("title"); + headElement._append(element); + } + + element.textContent = value; + } + } + + get dir() { + return this.documentElement ? this.documentElement.dir : ""; + } + set dir(value) { + if (this.documentElement) { + this.documentElement.dir = value; + } + } + + get head() { + return this.documentElement ? firstChildWithLocalName(this.documentElement, "head") : null; + } + + get body() { + const { documentElement } = this; + if (!documentElement || documentElement._localName !== "html" || + documentElement._namespaceURI !== HTML_NS) { + return null; + } + + return firstChildWithLocalNames(this.documentElement, new Set(["body", "frameset"])); + } + + set body(value) { + if (value === null || + value._namespaceURI !== HTML_NS || + (value._localName !== "body" && value._localName !== "frameset")) { + throw DOMException.create(this._globalObject, [ + "Cannot set the body to null or a non-body/frameset element", + "HierarchyRequestError" + ]); + } + + const bodyElement = this.body; + if (value === bodyElement) { + return; + } + + if (bodyElement !== null) { + bodyElement.parentNode._replace(value, bodyElement); + return; + } + + const { documentElement } = this; + if (documentElement === null) { + throw DOMException.create(this._globalObject, [ + "Cannot set the body when there is no document element", + "HierarchyRequestError" + ]); + } + + documentElement._append(value); + } + + _runPreRemovingSteps(oldNode) { + // https://html.spec.whatwg.org/#focus-fixup-rule + if (oldNode === this.activeElement) { + this._lastFocusedElement = this.body; + } + for (const activeNodeIterator of this._workingNodeIterators) { + activeNodeIterator._preRemovingSteps(oldNode); + } + } + + createEvent(type) { + const typeLower = type.toLowerCase(); + const eventWrapper = eventInterfaceTable[typeLower] || null; + + if (!eventWrapper) { + throw DOMException.create(this._globalObject, [ + "The provided event type (\"" + type + "\") is invalid", + "NotSupportedError" + ]); + } + + const impl = eventWrapper.createImpl(this._globalObject, [""]); + impl._initializedFlag = false; + return impl; + } + + createRange() { + return Range.createImpl(this._globalObject, [], { + start: { node: this, offset: 0 }, + end: { node: this, offset: 0 } + }); + } + + createProcessingInstruction(target, data) { + validateName(this._globalObject, target); + + if (data.includes("?>")) { + throw DOMException.create(this._globalObject, [ + "Processing instruction data cannot contain the string \"?>\"", + "InvalidCharacterError" + ]); + } + + return ProcessingInstruction.createImpl(this._globalObject, [], { + ownerDocument: this, + target, + data + }); + } + + // https://dom.spec.whatwg.org/#dom-document-createcdatasection + createCDATASection(data) { + if (this._parsingMode === "html") { + throw DOMException.create(this._globalObject, [ + "Cannot create CDATA sections in HTML documents", + "NotSupportedError" + ]); + } + + if (data.includes("]]>")) { + throw DOMException.create(this._globalObject, [ + "CDATA section data cannot contain the string \"]]>\"", + "InvalidCharacterError" + ]); + } + + return CDATASection.createImpl(this._globalObject, [], { + ownerDocument: this, + data + }); + } + + createTextNode(data) { + return Text.createImpl(this._globalObject, [], { + ownerDocument: this, + data + }); + } + + createComment(data) { + return Comment.createImpl(this._globalObject, [], { + ownerDocument: this, + data + }); + } + + // https://dom.spec.whatwg.org/#dom-document-createelement + createElement(localName, options) { + validateName(this._globalObject, localName); + + if (this._parsingMode === "html") { + localName = asciiLowercase(localName); + } + + let isValue = null; + if (options && options.is !== undefined) { + isValue = options.is; + } + + const namespace = this._parsingMode === "html" || this.contentType === "application/xhtml+xml" ? HTML_NS : null; + + return createElement(this, localName, namespace, null, isValue, true); + } + + // https://dom.spec.whatwg.org/#dom-document-createelementns + createElementNS(namespace, qualifiedName, options) { + return internalCreateElementNSSteps(this, namespace, qualifiedName, options); + } + + createDocumentFragment() { + return DocumentFragment.createImpl(this._globalObject, [], { ownerDocument: this }); + } + + createAttribute(localName) { + validateName(this._globalObject, localName); + + if (this._parsingMode === "html") { + localName = asciiLowercase(localName); + } + + return this._createAttribute({ localName }); + } + + createAttributeNS(namespace, name) { + if (namespace === undefined) { + namespace = null; + } + namespace = namespace !== null ? String(namespace) : namespace; + + const extracted = validateAndExtract(this._globalObject, namespace, name); + return this._createAttribute({ + namespace: extracted.namespace, + namespacePrefix: extracted.prefix, + localName: extracted.localName + }); + } + + // Using this helper function rather than directly calling generatedAttr.createImpl may be preferred in some files, + // to avoid introducing a potentially cyclic dependency on generated/Attr.js. + _createAttribute({ + localName, + value, + namespace, + namespacePrefix + }) { + return generatedAttr.createImpl(this._globalObject, [], { + localName, + value, + namespace, + namespacePrefix, + ownerDocument: this + }); + } + + createTreeWalker(root, whatToShow, filter) { + return TreeWalker.createImpl(this._globalObject, [], { root, whatToShow, filter }); + } + + createNodeIterator(root, whatToShow, filter) { + const nodeIterator = NodeIterator.createImpl(this._globalObject, [], { root, whatToShow, filter }); + this._workingNodeIterators.add(nodeIterator); + return nodeIterator; + } + + importNode(node, deep) { + if (node.nodeType === NODE_TYPE.DOCUMENT_NODE) { + throw DOMException.create(this._globalObject, [ + "Cannot import a document node", + "NotSupportedError" + ]); + } else if (ShadowRoot.isImpl(node)) { + throw DOMException.create(this._globalObject, [ + "Cannot adopt a shadow root", + "NotSupportedError" + ]); + } + + return clone(node, this, deep); + } + + // https://dom.spec.whatwg.org/#dom-document-adoptnode + adoptNode(node) { + if (node.nodeType === NODE_TYPE.DOCUMENT_NODE) { + throw DOMException.create(this._globalObject, [ + "Cannot adopt a document node", + "NotSupportedError" + ]); + } else if (ShadowRoot.isImpl(node)) { + throw DOMException.create(this._globalObject, [ + "Cannot adopt a shadow root", + "HierarchyRequestError" + ]); + } + + this._adoptNode(node); + + return node; + } + + // https://dom.spec.whatwg.org/#concept-node-adopt + _adoptNode(node) { + const newDocument = this; + const oldDocument = node._ownerDocument; + + const parent = domSymbolTree.parent(node); + if (parent) { + parent._remove(node); + } + + if (oldDocument !== newDocument) { + for (const inclusiveDescendant of shadowIncludingInclusiveDescendantsIterator(node)) { + inclusiveDescendant._ownerDocument = newDocument; + } + + for (const inclusiveDescendant of shadowIncludingInclusiveDescendantsIterator(node)) { + if (inclusiveDescendant._ceState === "custom") { + enqueueCECallbackReaction(inclusiveDescendant, "adoptedCallback", [ + idlUtils.wrapperForImpl(oldDocument), + idlUtils.wrapperForImpl(newDocument) + ]); + } + } + + for (const inclusiveDescendant of shadowIncludingInclusiveDescendantsIterator(node)) { + if (inclusiveDescendant._adoptingSteps) { + inclusiveDescendant._adoptingSteps(oldDocument); + } + } + } + } + + get cookie() { + return this._cookieJar.getCookieStringSync(this.URL, { http: false }); + } + set cookie(cookieStr) { + cookieStr = String(cookieStr); + this._cookieJar.setCookieSync(cookieStr, this.URL, { + http: false, + ignoreError: true + }); + } + + // The clear(), captureEvents(), and releaseEvents() methods must do nothing + clear() {} + + captureEvents() {} + + releaseEvents() {} + + get styleSheets() { + if (!this._styleSheets) { + this._styleSheets = StyleSheetList.createImpl(this._globalObject); + } + + // TODO: each style and link element should register its sheet on creation + // and remove it on removal. + return this._styleSheets; + } + + get hidden() { + if (this._defaultView && this._defaultView._pretendToBeVisual) { + return false; + } + + return true; + } + + get visibilityState() { + if (this._defaultView && this._defaultView._pretendToBeVisual) { + return "visible"; + } + + return "prerender"; + } + + // https://w3c.github.io/selection-api/#extensions-to-document-interface + getSelection() { + return this._defaultView ? this._defaultView._selection : null; + } + + // Needed to ensure that the resulting document has the correct prototype chain: + // https://dom.spec.whatwg.org/#concept-node-clone says "that implements the same interfaces as node". + _cloneDocument() { + const copy = documents.createImpl( + this._globalObject, + { + contentType: this.contentType, + encoding: this._encoding, + parsingMode: this._parsingMode + } + ); + + copy._URL = this._URL; + copy._origin = this._origin; + return copy; + } +} + +eventAccessors.createEventAccessor(DocumentImpl.prototype, "readystatechange"); +mixin(DocumentImpl.prototype, DocumentOrShadowRootImpl.prototype); +mixin(DocumentImpl.prototype, GlobalEventHandlersImpl.prototype); +mixin(DocumentImpl.prototype, NonElementParentNodeImpl.prototype); +mixin(DocumentImpl.prototype, ParentNodeImpl.prototype); + +DocumentImpl.prototype.getElementsByTagName = memoizeQuery(function (qualifiedName) { + return listOfElementsWithQualifiedName(qualifiedName, this); +}); + +DocumentImpl.prototype.getElementsByTagNameNS = memoizeQuery(function (namespace, localName) { + return listOfElementsWithNamespaceAndLocalName(namespace, localName, this); +}); + +DocumentImpl.prototype.getElementsByClassName = memoizeQuery(function getElementsByClassName(classNames) { + return listOfElementsWithClassNames(classNames, this); +}); + +module.exports = { + implementation: DocumentImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/DocumentFragment-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/DocumentFragment-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..a2a3870d83e23a331a497a65c9c6585577a8b2f5 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/DocumentFragment-impl.js @@ -0,0 +1,44 @@ +"use strict"; +const { mixin } = require("../../utils"); +const { domSymbolTree } = require("../helpers/internal-constants"); +const NODE_TYPE = require("../node-type"); +const NodeImpl = require("./Node-impl").implementation; +const NonElementParentNodeImpl = require("./NonElementParentNode-impl").implementation; +const ParentNodeImpl = require("./ParentNode-impl").implementation; +const idlUtils = require("../generated/utils"); + +class DocumentFragmentImpl extends NodeImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, { + ownerDocument: idlUtils.implForWrapper(globalObject._document), + ...privateData + }); + + const { host } = privateData; + this._host = host; + + this.nodeType = NODE_TYPE.DOCUMENT_FRAGMENT_NODE; + } + + // This is implemented separately for Document (which has a _ids cache) and DocumentFragment (which does not). + getElementById(id) { + if (id === "") { + return null; + } + + for (const descendant of domSymbolTree.treeIterator(this)) { + if (descendant.nodeType === NODE_TYPE.ELEMENT_NODE && descendant.getAttributeNS(null, "id") === id) { + return descendant; + } + } + + return null; + } +} + +mixin(DocumentFragmentImpl.prototype, NonElementParentNodeImpl.prototype); +mixin(DocumentFragmentImpl.prototype, ParentNodeImpl.prototype); + +module.exports = { + implementation: DocumentFragmentImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/DocumentOrShadowRoot-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/DocumentOrShadowRoot-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..4f854958d63a6d1efe5614692e41caca4b047f4e --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/DocumentOrShadowRoot-impl.js @@ -0,0 +1,28 @@ +"use strict"; +const NODE_TYPE = require("../node-type"); +const { nodeRoot } = require("../helpers/node"); +const { retarget } = require("../helpers/shadow-dom"); + +class DocumentOrShadowRootImpl { + get activeElement() { + let candidate = this._ownerDocument._lastFocusedElement || this._ownerDocument.body; + if (!candidate) { + return null; + } + candidate = retarget(candidate, this); + if (nodeRoot(candidate) !== this) { + return null; + } + if (candidate.nodeType !== NODE_TYPE.DOCUMENT_NODE) { + return candidate; + } + if (candidate.body !== null) { + return candidate.body; + } + return candidate.documentElement; + } +} + +module.exports = { + implementation: DocumentOrShadowRootImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/DocumentType-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/DocumentType-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..77767be9d0da4443578b60c07f2f4f9fbdbf8347 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/DocumentType-impl.js @@ -0,0 +1,24 @@ +"use strict"; +const { mixin } = require("../../utils"); +const NodeImpl = require("./Node-impl").implementation; +const ChildNodeImpl = require("./ChildNode-impl").implementation; + +const NODE_TYPE = require("../node-type"); + +class DocumentTypeImpl extends NodeImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this.nodeType = NODE_TYPE.DOCUMENT_TYPE_NODE; + + this.name = privateData.name; + this.publicId = privateData.publicId; + this.systemId = privateData.systemId; + } +} + +mixin(DocumentTypeImpl.prototype, ChildNodeImpl.prototype); + +module.exports = { + implementation: DocumentTypeImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/Element-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/Element-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..279fceec3112d71ceacb1fe1fdf83dd66828efb6 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/Element-impl.js @@ -0,0 +1,608 @@ +"use strict"; +const { HTML_NS } = require("../helpers/namespaces"); +const { mixin, memoizeQuery } = require("../../utils"); +const NodeImpl = require("./Node-impl").implementation; +const ParentNodeImpl = require("./ParentNode-impl").implementation; +const ChildNodeImpl = require("./ChildNode-impl").implementation; +const attributes = require("../attributes"); +const windowProperties = require("../window-properties"); +const NODE_TYPE = require("../node-type"); +const { parseFragment } = require("../../browser/parser"); +const InnerHTMLImpl = require("../domparsing/InnerHTML-impl").implementation; +const { fragmentSerialization } = require("../domparsing/serialization"); +const { domSymbolTree } = require("../helpers/internal-constants"); +const DOMException = require("../generated/DOMException"); +const DOMTokenList = require("../generated/DOMTokenList"); +const NamedNodeMap = require("../generated/NamedNodeMap"); +const validateNames = require("../helpers/validate-names"); +const { asciiLowercase, asciiUppercase } = require("../helpers/strings"); +const { listOfElementsWithQualifiedName, listOfElementsWithNamespaceAndLocalName, + listOfElementsWithClassNames } = require("../node"); +const SlotableMixinImpl = require("./Slotable-impl").implementation; +const NonDocumentTypeChildNode = require("./NonDocumentTypeChildNode-impl").implementation; +const ShadowRoot = require("../generated/ShadowRoot"); +const Text = require("../generated/Text"); +const { isValidHostElementName } = require("../helpers/shadow-dom"); +const { isValidCustomElementName, lookupCEDefinition } = require("../helpers/custom-elements"); + +function attachId(id, elm, doc) { + if (id && elm && doc) { + if (!doc._ids[id]) { + doc._ids[id] = []; + } + doc._ids[id].push(elm); + } +} + +function detachId(id, elm, doc) { + if (id && elm && doc) { + if (doc._ids && doc._ids[id]) { + const elms = doc._ids[id]; + for (let i = 0; i < elms.length; i++) { + if (elms[i] === elm) { + elms.splice(i, 1); + --i; + } + } + if (elms.length === 0) { + delete doc._ids[id]; + } + } + } +} + +class ElementImpl extends NodeImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this._initSlotableMixin(); + + this._namespaceURI = privateData.namespace; + this._prefix = privateData.prefix; + this._localName = privateData.localName; + this._ceState = privateData.ceState; + this._ceDefinition = privateData.ceDefinition; + this._isValue = privateData.isValue; + + this._shadowRoot = null; + this._ceReactionQueue = []; + + this.nodeType = NODE_TYPE.ELEMENT_NODE; + this.scrollTop = 0; + this.scrollLeft = 0; + + this._attributeList = []; + // Used for caching. + this._attributesByNameMap = new Map(); + this._attributes = null; + + this._cachedTagName = null; + } + + _attach() { + windowProperties.elementAttached(this); + + const id = this.getAttributeNS(null, "id"); + if (id) { + attachId(id, this, this._ownerDocument); + } + + // If the element is initially in an HTML document but is later + // inserted in another type of document, the tagName should no + // longer be uppercase. Therefore the cached tagName is reset. + this._cachedTagName = null; + super._attach(); + } + + _detach() { + super._detach(); + + windowProperties.elementDetached(this); + + const id = this.getAttributeNS(null, "id"); + if (id) { + detachId(id, this, this._ownerDocument); + } + } + + _attrModified(name, value, oldValue) { + this._modified(); + + windowProperties.elementAttributeModified(this, name, value, oldValue); + + if (name === "id" && this._attached) { + const doc = this._ownerDocument; + detachId(oldValue, this, doc); + attachId(value, this, doc); + } + + // update classList + if (name === "class" && this._classList !== undefined) { + this._classList.attrModified(); + } + + // clear domSelector cached results on class change + if (name === "class") { + this._ownerDocument._domSelector.clear(); + } + + this._attrModifiedSlotableMixin(name, value, oldValue); + } + + get namespaceURI() { + return this._namespaceURI; + } + get prefix() { + return this._prefix; + } + get localName() { + return this._localName; + } + get _qualifiedName() { + return this._prefix !== null ? this._prefix + ":" + this._localName : this._localName; + } + get tagName() { + // This getter can be a hotpath in getComputedStyle. + // All these are invariants during the instance lifetime so we can safely cache the computed tagName. + // We could create it during construction but since we already identified this as potentially slow we do it lazily. + if (this._cachedTagName === null) { + if (this._namespaceURI === HTML_NS && this._ownerDocument._parsingMode === "html") { + this._cachedTagName = asciiUppercase(this._qualifiedName); + } else { + this._cachedTagName = this._qualifiedName; + } + } + return this._cachedTagName; + } + + get attributes() { + if (!this._attributes) { + this._attributes = NamedNodeMap.createImpl(this._globalObject, [], { + element: this + }); + } + + return this._attributes; + } + + // https://w3c.github.io/DOM-Parsing/#dom-element-outerhtml + get outerHTML() { + return fragmentSerialization(this, { + outer: true, + requireWellFormed: true, + globalObject: this._globalObject + }); + } + set outerHTML(markup) { + let parent = domSymbolTree.parent(this); + const document = this._ownerDocument; + + if (!parent) { + return; + } + + if (parent.nodeType === NODE_TYPE.DOCUMENT_NODE) { + throw DOMException.create(this._globalObject, [ + "Modifications are not allowed for this document", + "NoModificationAllowedError" + ]); + } + + if (parent.nodeType === NODE_TYPE.DOCUMENT_FRAGMENT_NODE) { + parent = document.createElementNS(HTML_NS, "body"); + } + + const fragment = parseFragment(markup, parent); + + const contextObjectParent = domSymbolTree.parent(this); + contextObjectParent._replace(fragment, this); + } + + get classList() { + if (this._classList === undefined) { + this._classList = DOMTokenList.createImpl(this._globalObject, [], { + element: this, + attributeLocalName: "class" + }); + } + return this._classList; + } + + hasAttributes() { + return attributes.hasAttributes(this); + } + + getAttributeNames() { + return attributes.attributeNames(this); + } + + getAttribute(name) { + const attr = attributes.getAttributeByName(this, name); + if (!attr) { + return null; + } + return attr._value; + } + + getAttributeNS(namespace, localName) { + const attr = attributes.getAttributeByNameNS(this, namespace, localName); + if (!attr) { + return null; + } + return attr._value; + } + + setAttribute(name, value) { + validateNames.name(this._globalObject, name); + + if (this._namespaceURI === HTML_NS && this._ownerDocument._parsingMode === "html") { + name = asciiLowercase(name); + } + + const attribute = attributes.getAttributeByName(this, name); + + if (attribute === null) { + const newAttr = this._ownerDocument._createAttribute({ + localName: name, + value + }); + attributes.appendAttribute(this, newAttr); + return; + } + + attributes.changeAttribute(this, attribute, value); + } + + setAttributeNS(namespace, name, value) { + const extracted = validateNames.validateAndExtract(this._globalObject, namespace, name); + + // Because of widespread use of this method internally, e.g. to manually implement attribute/content reflection, we + // centralize the conversion to a string here, so that all call sites don't have to do it. + value = `${value}`; + + attributes.setAttributeValue(this, extracted.localName, value, extracted.prefix, extracted.namespace); + } + + removeAttribute(name) { + attributes.removeAttributeByName(this, name); + } + + removeAttributeNS(namespace, localName) { + attributes.removeAttributeByNameNS(this, namespace, localName); + } + + toggleAttribute(qualifiedName, force) { + validateNames.name(this._globalObject, qualifiedName); + + if (this._namespaceURI === HTML_NS && this._ownerDocument._parsingMode === "html") { + qualifiedName = asciiLowercase(qualifiedName); + } + + const attribute = attributes.getAttributeByName(this, qualifiedName); + + if (attribute === null) { + if (force === undefined || force === true) { + const newAttr = this._ownerDocument._createAttribute({ + localName: qualifiedName, + value: "" + }); + attributes.appendAttribute(this, newAttr); + return true; + } + return false; + } + + if (force === undefined || force === false) { + attributes.removeAttributeByName(this, qualifiedName); + return false; + } + + return true; + } + + hasAttribute(name) { + if (this._namespaceURI === HTML_NS && this._ownerDocument._parsingMode === "html") { + name = asciiLowercase(name); + } + + return attributes.hasAttributeByName(this, name); + } + + hasAttributeNS(namespace, localName) { + if (namespace === "") { + namespace = null; + } + + return attributes.hasAttributeByNameNS(this, namespace, localName); + } + + getAttributeNode(name) { + return attributes.getAttributeByName(this, name); + } + + getAttributeNodeNS(namespace, localName) { + return attributes.getAttributeByNameNS(this, namespace, localName); + } + + setAttributeNode(attr) { + // eslint-disable-next-line no-restricted-properties + return attributes.setAttribute(this, attr); + } + + setAttributeNodeNS(attr) { + // eslint-disable-next-line no-restricted-properties + return attributes.setAttribute(this, attr); + } + + removeAttributeNode(attr) { + // eslint-disable-next-line no-restricted-properties + if (!attributes.hasAttribute(this, attr)) { + throw DOMException.create(this._globalObject, [ + "Tried to remove an attribute that was not present", + "NotFoundError" + ]); + } + + // eslint-disable-next-line no-restricted-properties + attributes.removeAttribute(this, attr); + + return attr; + } + + getBoundingClientRect() { + return { + x: 0, + y: 0, + bottom: 0, + height: 0, + left: 0, + right: 0, + top: 0, + width: 0 + }; + } + + getClientRects() { + return []; + } + + get scrollWidth() { + return 0; + } + + get scrollHeight() { + return 0; + } + + get clientTop() { + return 0; + } + + get clientLeft() { + return 0; + } + + get clientWidth() { + return 0; + } + + get clientHeight() { + return 0; + } + + // https://dom.spec.whatwg.org/#dom-element-attachshadow + attachShadow(init) { + const { _ownerDocument, _namespaceURI, _localName, _isValue } = this; + + if (this.namespaceURI !== HTML_NS) { + throw DOMException.create(this._globalObject, [ + "This element does not support attachShadow. This element is not part of the HTML namespace.", + "NotSupportedError" + ]); + } + + if (!isValidHostElementName(_localName) && !isValidCustomElementName(_localName)) { + const message = "This element does not support attachShadow. This element is not a custom element nor " + + "a standard element supporting a shadow root."; + throw DOMException.create(this._globalObject, [message, "NotSupportedError"]); + } + + if (isValidCustomElementName(_localName) || _isValue) { + const definition = lookupCEDefinition(_ownerDocument, _namespaceURI, _localName, _isValue); + + if (definition && definition.disableShadow) { + throw DOMException.create(this._globalObject, [ + "Shadow root cannot be create on a custom element with disabled shadow", + "NotSupportedError" + ]); + } + } + + if (this._shadowRoot !== null) { + throw DOMException.create(this._globalObject, [ + "Shadow root cannot be created on a host which already hosts a shadow tree.", + "NotSupportedError" + ]); + } + + const shadow = ShadowRoot.createImpl(this._globalObject, [], { + ownerDocument: this.ownerDocument, + mode: init.mode, + host: this + }); + + if (this._ceState === "precustomized" || this._ceState === "custom") { + shadow._availableToElementInternals = true; + } + + this._shadowRoot = shadow; + + return shadow; + } + + // https://dom.spec.whatwg.org/#dom-element-shadowroot + get shadowRoot() { + const shadow = this._shadowRoot; + + if (shadow === null || shadow.mode === "closed") { + return null; + } + + return shadow; + } + + // https://dom.spec.whatwg.org/#insert-adjacent + _insertAdjacent(element, where, node) { + where = asciiLowercase(where); + + if (where === "beforebegin") { + if (element.parentNode === null) { + return null; + } + return element.parentNode._preInsert(node, element); + } + if (where === "afterbegin") { + return element._preInsert(node, element.firstChild); + } + if (where === "beforeend") { + return element._preInsert(node, null); + } + if (where === "afterend") { + if (element.parentNode === null) { + return null; + } + return element.parentNode._preInsert(node, element.nextSibling); + } + + throw DOMException.create(this._globalObject, [ + 'Must provide one of "beforebegin", "afterbegin", "beforeend", or "afterend".', + "SyntaxError" + ]); + } + + insertAdjacentElement(where, element) { + return this._insertAdjacent(this, where, element); + } + + insertAdjacentText(where, data) { + const text = Text.createImpl(this._globalObject, [], { data, ownerDocument: this._ownerDocument }); + + this._insertAdjacent(this, where, text); + } + + // https://w3c.github.io/DOM-Parsing/#dom-element-insertadjacenthtml + insertAdjacentHTML(position, text) { + position = asciiLowercase(position); + + let context; + switch (position) { + case "beforebegin": + case "afterend": { + context = this.parentNode; + if (context === null || context.nodeType === NODE_TYPE.DOCUMENT_NODE) { + throw DOMException.create(this._globalObject, [ + "Cannot insert HTML adjacent to parent-less nodes or children of document nodes.", + "NoModificationAllowedError" + ]); + } + break; + } + case "afterbegin": + case "beforeend": { + context = this; + break; + } + default: { + throw DOMException.create(this._globalObject, [ + 'Must provide one of "beforebegin", "afterbegin", "beforeend", or "afterend".', + "SyntaxError" + ]); + } + } + + if ( + context.nodeType !== NODE_TYPE.ELEMENT_NODE || + ( + context._ownerDocument._parsingMode === "html" && + context._localName === "html" && + context._namespaceURI === HTML_NS + ) + ) { + context = context._ownerDocument.createElement("body"); + } + + const fragment = parseFragment(text, context); + + switch (position) { + case "beforebegin": { + this.parentNode._insert(fragment, this); + break; + } + case "afterbegin": { + this._insert(fragment, this.firstChild); + break; + } + case "beforeend": { + this._append(fragment); + break; + } + case "afterend": { + this.parentNode._insert(fragment, this.nextSibling); + break; + } + } + } + + closest(selectors) { + const domSelector = this._ownerDocument._domSelector; + return domSelector.closest(selectors, this); + } + + matches(selectors) { + const domSelector = this._ownerDocument._domSelector; + return domSelector.matches(selectors, this); + } + + webkitMatchesSelector(selectors) { + return this.matches(selectors); + } + + // https://html.spec.whatwg.org/#reflecting-content-attributes-in-idl-attributes + _reflectGetTheElement() { + return this; + } + + _reflectGetTheContentAttribute(reflectedContentAttributeName) { + return this.getAttributeNS(null, reflectedContentAttributeName); + } + + _reflectSetTheContentAttribute(reflectedContentAttributeName, value) { + this.setAttributeNS(null, reflectedContentAttributeName, value); + } + + _reflectDeleteTheContentAttribute(reflectedContentAttributeName) { + this.removeAttributeNS(null, reflectedContentAttributeName); + } +} + +mixin(ElementImpl.prototype, NonDocumentTypeChildNode.prototype); +mixin(ElementImpl.prototype, ParentNodeImpl.prototype); +mixin(ElementImpl.prototype, ChildNodeImpl.prototype); +mixin(ElementImpl.prototype, SlotableMixinImpl.prototype); +mixin(ElementImpl.prototype, InnerHTMLImpl.prototype); + +ElementImpl.prototype.getElementsByTagName = memoizeQuery(function (qualifiedName) { + return listOfElementsWithQualifiedName(qualifiedName, this); +}); + +ElementImpl.prototype.getElementsByTagNameNS = memoizeQuery(function (namespace, localName) { + return listOfElementsWithNamespaceAndLocalName(namespace, localName, this); +}); + +ElementImpl.prototype.getElementsByClassName = memoizeQuery(function (classNames) { + return listOfElementsWithClassNames(classNames, this); +}); + +module.exports = { + implementation: ElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/ElementCSSInlineStyle-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/ElementCSSInlineStyle-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..b9dedb43af093d39b8c2584ac0095604d80e6de3 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/ElementCSSInlineStyle-impl.js @@ -0,0 +1,22 @@ +"use strict"; +const cssstyle = require("cssstyle"); + +class ElementCSSInlineStyle { + _initElementCSSInlineStyle() { + this._settingCssText = false; + this._style = new cssstyle.CSSStyleDeclaration(newCssText => { + if (!this._settingCssText) { + this._settingCssText = true; + this.setAttributeNS(null, "style", newCssText); + this._settingCssText = false; + } + }); + } + get style() { + return this._style; + } +} + +module.exports = { + implementation: ElementCSSInlineStyle +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/ElementContentEditable-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/ElementContentEditable-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..8523c9cfc02195e84a913fc1f7aa0b3159a2e8d9 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/ElementContentEditable-impl.js @@ -0,0 +1,7 @@ +"use strict"; + +class ElementContentEditableImpl { } + +module.exports = { + implementation: ElementContentEditableImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/GlobalEventHandlers-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/GlobalEventHandlers-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..eb131af5b27afafe38804c7106da2f82cb580e93 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/GlobalEventHandlers-impl.js @@ -0,0 +1,157 @@ +"use strict"; + +const { appendHandler, createEventAccessor } = require("../helpers/create-event-accessor"); + +// Must be kept in sync with GlobalEventHandlers.webidl. +const events = new Set([ + "abort", + "auxclick", + "beforeinput", + "beforematch", + "beforetoggle", + "blur", + "cancel", + "canplay", + "canplaythrough", + "change", + "click", + "close", + "contextlost", + "contextmenu", + "contextrestored", + "copy", + "cuechange", + "cut", + "dblclick", + "drag", + "dragend", + "dragenter", + "dragleave", + "dragover", + "dragstart", + "drop", + "durationchange", + "emptied", + "ended", + "error", + "focus", + "formdata", + "input", + "invalid", + "keydown", + "keypress", + "keyup", + "load", + "loadeddata", + "loadedmetadata", + "loadstart", + "mousedown", + "mouseenter", + "mouseleave", + "mousemove", + "mouseout", + "mouseover", + "mouseup", + "paste", + "pause", + "play", + "playing", + "progress", + "ratechange", + "reset", + "resize", + "scroll", + "scrollend", + "securitypolicyviolation", + "seeked", + "seeking", + "select", + "slotchange", + "stalled", + "submit", + "suspend", + "timeupdate", + "toggle", + "volumechange", + "waiting", + "webkitanimationend", + "webkitanimationiteration", + "webkitanimationstart", + "webkittransitionend", + "wheel", + "touchstart", + "touchend", + "touchmove", + "touchcancel", + "pointerover", + "pointerenter", + "pointerdown", + "pointermove", + "pointerrawupdate", + "pointerup", + "pointercancel", + "pointerout", + "pointerleave", + "gotpointercapture", + "lostpointercapture" +]); + +class GlobalEventHandlersImpl { + _initGlobalEvents() { + this._registeredHandlers = new Set(); + this._eventHandlers = Object.create(null); + } + + _getEventHandlerTarget() { + return this; + } + + _getEventHandlerFor(event) { + const target = this._getEventHandlerTarget(event); + if (!target) { + return null; + } + + return target._eventHandlers[event]; + } + + _setEventHandlerFor(event, handler) { + const target = this._getEventHandlerTarget(event); + if (!target) { + return; + } + + if (!target._registeredHandlers.has(event) && handler !== null) { + target._registeredHandlers.add(event); + appendHandler(target, event); + } + target._eventHandlers[event] = handler; + } + + _globalEventChanged(event) { + const propName = "on" + event; + if (!(propName in this)) { + return; + } + + // Only translate attribute changes into properties when runScripts: "dangerously" is set. + // Documents without a browsing context (i.e. without a _defaultView) never run scripts. + const runScripts = "_runScripts" in this ? this._runScripts : (this._ownerDocument._defaultView || {})._runScripts; + if (runScripts !== "dangerously") { + return; + } + + const val = this.getAttributeNS(null, propName); + const handler = val === null ? null : { body: val }; + this._setEventHandlerFor(event, handler); + } +} + +for (const event of events) { + createEventAccessor(GlobalEventHandlersImpl.prototype, event); +} + +module.exports = { + implementation: GlobalEventHandlersImpl, + events +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLAnchorElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLAnchorElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..73b6943ab401e49ce33b26e30dafd023de9febfa --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLAnchorElement-impl.js @@ -0,0 +1,50 @@ +"use strict"; +const { mixin } = require("../../utils"); +const DOMTokenList = require("../generated/DOMTokenList"); +const HTMLElementImpl = require("./HTMLElement-impl").implementation; +const HTMLHyperlinkElementUtilsImpl = require("./HTMLHyperlinkElementUtils-impl").implementation; + +class HTMLAnchorElementImpl extends HTMLElementImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this._htmlHyperlinkElementUtilsSetup(); + + this._hasActivationBehavior = true; + } + + _activationBehavior() { + this._followAHyperlink(); + } + + get relList() { + if (this._relList === undefined) { + this._relList = DOMTokenList.createImpl(this._globalObject, [], { + element: this, + attributeLocalName: "rel" + }); + } + return this._relList; + } + + get text() { + return this.textContent; + } + set text(v) { + this.textContent = v; + } + + _attrModified(name, value, oldValue) { + super._attrModified(name, value, oldValue); + + if (name === "rel" && this._relList !== undefined) { + this._relList.attrModified(); + } + } +} + +mixin(HTMLAnchorElementImpl.prototype, HTMLHyperlinkElementUtilsImpl.prototype); + +module.exports = { + implementation: HTMLAnchorElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLAreaElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLAreaElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..58d5fe11575a03daaf3dcbf7dfe143cb7d25c14f --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLAreaElement-impl.js @@ -0,0 +1,43 @@ +"use strict"; +const { mixin } = require("../../utils"); +const DOMTokenList = require("../generated/DOMTokenList"); +const HTMLElementImpl = require("./HTMLElement-impl").implementation; +const HTMLHyperlinkElementUtilsImpl = require("./HTMLHyperlinkElementUtils-impl").implementation; + +class HTMLAreaElementImpl extends HTMLElementImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this._htmlHyperlinkElementUtilsSetup(); + + this._hasActivationBehavior = true; + } + + _activationBehavior() { + this._followAHyperlink(); + } + + get relList() { + if (this._relList === undefined) { + this._relList = DOMTokenList.createImpl(this._globalObject, [], { + element: this, + attributeLocalName: "rel" + }); + } + return this._relList; + } + + _attrModified(name, value, oldValue) { + super._attrModified(name, value, oldValue); + + if (name === "rel" && this._relList !== undefined) { + this._relList.attrModified(); + } + } +} + +mixin(HTMLAreaElementImpl.prototype, HTMLHyperlinkElementUtilsImpl.prototype); + +module.exports = { + implementation: HTMLAreaElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLAudioElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLAudioElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..ad65ff5f0918b561a587ad9b784af8e0093d2c7c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLAudioElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLMediaElementImpl = require("./HTMLMediaElement-impl").implementation; + +class HTMLAudioElementImpl extends HTMLMediaElementImpl { } + +module.exports = { + implementation: HTMLAudioElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLBRElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLBRElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..c921613c793f76b252643c9235ffc6a1178e111c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLBRElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLBRElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLBRElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLBaseElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLBaseElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..cc5a0647e7e5ecbd3fbaaeec288c81a9a6d91d77 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLBaseElement-impl.js @@ -0,0 +1,44 @@ +"use strict"; +const whatwgURL = require("whatwg-url"); +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLBaseElementImpl extends HTMLElementImpl { + get href() { + const document = this._ownerDocument; + + const url = this.hasAttributeNS(null, "href") ? this.getAttributeNS(null, "href") : ""; + const parsed = whatwgURL.parseURL(url, { baseURL: document._fallbackBaseURL() }); + + if (parsed === null) { + return url; + } + + return whatwgURL.serializeURL(parsed); + } + + set href(value) { + this.setAttributeNS(null, "href", value); + } + + _attrModified(name, value, oldValue) { + super._attrModified(name, value, oldValue); + + if (name === "href") { + this._ownerDocument._clearBaseURLCache(); + } + } + + _attach() { + super._attach(); + this._ownerDocument._clearBaseURLCache(); + } + + _detach() { + super._detach(); + this._ownerDocument._clearBaseURLCache(); + } +} + +module.exports = { + implementation: HTMLBaseElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLBodyElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLBodyElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..1ebd0ea2049f74840455913206434c6c383ada68 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLBodyElement-impl.js @@ -0,0 +1,17 @@ +"use strict"; +const { mixin } = require("../../utils"); +const HTMLElementImpl = require("./HTMLElement-impl").implementation; +const WindowEventHandlersImpl = require("./WindowEventHandlers-impl").implementation; + +class HTMLBodyElementImpl extends HTMLElementImpl { + constructor(...args) { + super(...args); + this._proxyWindowEventsToWindow(); + } +} + +mixin(HTMLBodyElementImpl.prototype, WindowEventHandlersImpl.prototype); + +module.exports = { + implementation: HTMLBodyElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLButtonElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLButtonElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..0bd1c81e4d0c08c6f8b33cf34d0eefbe3a30a4c4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLButtonElement-impl.js @@ -0,0 +1,79 @@ +"use strict"; +const HTMLElementImpl = require("./HTMLElement-impl").implementation; +const DefaultConstraintValidationImpl = + require("../constraint-validation/DefaultConstraintValidation-impl").implementation; +const { mixin } = require("../../utils"); +const { isDisabled, formOwner, getLabelsForLabelable } = require("../helpers/form-controls"); +const { asciiLowercase } = require("../helpers/strings"); + +class HTMLButtonElementImpl extends HTMLElementImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this._customValidityErrorMessage = ""; + this._labels = null; + + this._hasActivationBehavior = true; + } + + _activationBehavior() { + const { form } = this; + if (form && !isDisabled(this)) { + if (this.type === "submit") { + form._doRequestSubmit(this); + } + if (this.type === "reset") { + form._doReset(); + } + } + } + + _getValue() { + const valueAttr = this.getAttributeNS(null, "value"); + return valueAttr === null ? "" : valueAttr; + } + + get labels() { + return getLabelsForLabelable(this); + } + + get form() { + return formOwner(this); + } + + get type() { + const typeAttr = asciiLowercase(this.getAttributeNS(null, "type") || ""); + switch (typeAttr) { + case "submit": + case "reset": + case "button": + return typeAttr; + default: + return "submit"; + } + } + + set type(v) { + v = asciiLowercase(String(v)); + switch (v) { + case "submit": + case "reset": + case "button": + this.setAttributeNS(null, "type", v); + break; + default: + this.setAttributeNS(null, "type", "submit"); + break; + } + } + + _barredFromConstraintValidationSpecialization() { + return this.type === "reset" || this.type === "button"; + } +} + +mixin(HTMLButtonElementImpl.prototype, DefaultConstraintValidationImpl.prototype); + +module.exports = { + implementation: HTMLButtonElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCanvasElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCanvasElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..099438d26c1a41cf348de5e8d1dc07bb12a23c72 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCanvasElement-impl.js @@ -0,0 +1,136 @@ +"use strict"; +const HTMLElementImpl = require("./HTMLElement-impl").implementation; +const { notImplementedMethod } = require("../../browser/not-implemented"); +const idlUtils = require("../generated/utils"); +const { Canvas } = require("../../utils"); + +class HTMLCanvasElementImpl extends HTMLElementImpl { + _attrModified(name, value, oldValue) { + if (this._canvas && (name === "width" || name === "height")) { + this._canvas[name] = parseInt(value); + } + + super._attrModified(name, value, oldValue); + } + + _getCanvas() { + if (Canvas && !this._canvas) { + this._canvas = Canvas.createCanvas(this.width, this.height); + } + return this._canvas; + } + + getContext(contextId) { + const canvas = this._getCanvas(); + if (canvas) { + if (!this._context) { + this._context = canvas.getContext(contextId) || null; + if (this._context) { + // Override the native canvas reference with our wrapper. This is the + // reason why we need to locally cache _context, since each call to + // canvas.getContext(contextId) would replace this reference again. + // Perhaps in the longer term, a better solution would be to create a + // full wrapper for the Context object as well. + this._context.canvas = idlUtils.wrapperForImpl(this); + wrapNodeCanvasMethod(this._context, "createPattern"); + wrapNodeCanvasMethod(this._context, "drawImage"); + } + } + return this._context; + } + + notImplementedMethod( + this._ownerDocument._defaultView, + "HTMLCanvasElement", + "getContext", + "without installing the canvas npm package" + ); + return null; + } + + toDataURL(...args) { + const canvas = this._getCanvas(); + if (canvas) { + return canvas.toDataURL(...args); + } + + notImplementedMethod( + this._ownerDocument._defaultView, + "HTMLCanvasElement", + "toDataURL", + "without installing the canvas npm package" + ); + return null; + } + + toBlob(callback, type, qualityArgument) { + const window = this._ownerDocument._defaultView; + const canvas = this._getCanvas(); + if (canvas) { + const options = {}; + switch (type) { + case "image/jpg": + case "image/jpeg": + type = "image/jpeg"; + options.quality = qualityArgument; + break; + default: + type = "image/png"; + } + canvas.toBuffer((err, buff) => { + if (err) { + throw err; + } + callback(new window.Blob([buff], { type })); + }, type, options); + } else { + notImplementedMethod( + this._ownerDocument._defaultView, + "HTMLCanvasElement", + "toBlob", + "without installing the canvas npm package" + ); + } + } + + get width() { + const parsed = parseInt(this.getAttributeNS(null, "width")); + return isNaN(parsed) || parsed < 0 || parsed > 2147483647 ? 300 : parsed; + } + + set width(v) { + v = v > 2147483647 ? 300 : v; + this.setAttributeNS(null, "width", String(v)); + } + + get height() { + const parsed = parseInt(this.getAttributeNS(null, "height")); + return isNaN(parsed) || parsed < 0 || parsed > 2147483647 ? 150 : parsed; + } + + set height(v) { + v = v > 2147483647 ? 150 : v; + this.setAttributeNS(null, "height", String(v)); + } +} + +// We need to wrap the methods that receive an image or canvas object +// (luckily, always as the first argument), so that these objects can be +// unwrapped an the expected types passed. +function wrapNodeCanvasMethod(ctx, name) { + const prev = ctx[name]; + ctx[name] = function (image, ...rest) { + const impl = idlUtils.implForWrapper(image); + if (impl) { + if (impl instanceof HTMLCanvasElementImpl && !impl._canvas) { + impl._getCanvas(); + } + image = impl._image || impl._canvas; + } + return prev.call(ctx, image, ...rest); + }; +} + +module.exports = { + implementation: HTMLCanvasElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCollection-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCollection-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..980ebd261f58b0380a0c433489ef941fedcb87a1 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCollection-impl.js @@ -0,0 +1,96 @@ +"use strict"; + +const idlUtils = require("../generated/utils.js"); +const { HTML_NS } = require("../helpers/namespaces"); + +exports.implementation = class HTMLCollectionImpl { + constructor(globalObject, args, privateData) { + this._list = []; + this._version = -1; + this._element = privateData.element; + this._query = privateData.query; + + this._globalObject = globalObject; + + this._update(); + } + get length() { + this._update(); + return this._list.length; + } + item(index) { + this._update(); + return this._list[index] || null; + } + namedItem(key) { + if (key === "") { + return null; + } + this._update(); + for (const element of this._list) { + if (element.getAttributeNS(null, "id") === key) { + return element; + } + if (element._namespaceURI === HTML_NS) { + const name = element.getAttributeNS(null, "name"); + if (name === key) { + return element; + } + } + } + return null; + } + _update() { + if (this._version < this._element._version) { + const snapshot = this._query(); + for (let i = 0; i < snapshot.length; i++) { + this._list[i] = snapshot[i]; + } + this._list.length = snapshot.length; + this._version = this._element._version; + } + } + get [idlUtils.supportedPropertyIndices]() { + this._update(); + return this._list.keys(); + } + get [idlUtils.supportedPropertyNames]() { + this._update(); + const result = new Set(); + for (const element of this._list) { + const id = element.getAttributeNS(null, "id"); + if (id) { + result.add(id); + } + if (element._namespaceURI === HTML_NS) { + const name = element.getAttributeNS(null, "name"); + if (name) { + result.add(name); + } + } + } + return result; + } + + // Inherit some useful functions from Array. + [Symbol.iterator]() { + this._update(); + return this._list[Symbol.iterator](); + } + entries() { + this._update(); + return this._list.entries(); + } + filter(...args) { + this._update(); + return this._list.filter(...args); + } + map(...args) { + this._update(); + return this._list.map(...args); + } + indexOf(...args) { + this._update(); + return this._list.indexOf(...args); + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDListElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDListElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..22ee9bd846323e9aa1bbd23d3c6c1efc100ef870 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDListElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLDListElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLDListElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDataElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDataElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..2d75abc214e5aa3760b389cd777774fac7c1a54d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDataElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLDataElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLDataElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDataListElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDataListElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..ccd2c4c9bfc57ed5e4b30d7c791fc294b611a388 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDataListElement-impl.js @@ -0,0 +1,20 @@ +"use strict"; + +const HTMLCollection = require("../generated/HTMLCollection"); +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +const { descendantsByLocalName } = require("../helpers/traversal"); + +class HTMLDataListElementImpl extends HTMLElementImpl { + // https://html.spec.whatwg.org/multipage/form-elements.html#dom-datalist-options + get options() { + return HTMLCollection.createImpl(this._globalObject, [], { + element: this, + query: () => descendantsByLocalName(this, "option") + }); + } +} + +module.exports = { + implementation: HTMLDataListElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDetailsElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDetailsElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..7a934b444b49cbff74b7b07bafb0a479d2f16bfd --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDetailsElement-impl.js @@ -0,0 +1,35 @@ +"use strict"; + +const { fireAnEvent } = require("../helpers/events"); + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLDetailsElementImpl extends HTMLElementImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this._taskQueue = null; + } + + _dispatchToggleEvent() { + this._taskQueue = null; + + fireAnEvent("toggle", this); + } + + _attrModified(name, value, oldValue) { + super._attrModified(name, value, oldValue); + + if (name === "open" && this._taskQueue === null) { + // Check that the attribute is added or removed, not merely changed + if ((value !== oldValue && value !== null && oldValue === null) || + (value === null && oldValue !== null)) { + this._taskQueue = setTimeout(this._dispatchToggleEvent.bind(this), 0); + } + } + } +} + +module.exports = { + implementation: HTMLDetailsElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDialogElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDialogElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..d020e3cfd0b8ccb49faa1e7840dc4854ba0e66b7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDialogElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLDialogElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLDialogElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDirectoryElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDirectoryElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..ea05eb3b71aff74e98917e9fb656792844ccc2cc --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDirectoryElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLDirectoryElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLDirectoryElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDivElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDivElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..b81a714e5ca05cfa040ebf35922d29277ced567c --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLDivElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLDivElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLDivElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..efa121f51ad10e88a9d592b89e1cd9ba2e8e6395 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js @@ -0,0 +1,211 @@ +"use strict"; +const { mixin } = require("../../utils"); +const ElementImpl = require("./Element-impl").implementation; +const DOMException = require("../generated/DOMException"); +const PointerEvent = require("../generated/PointerEvent"); +const ElementInternals = require("../generated/ElementInternals"); +const ElementCSSInlineStyleImpl = require("./ElementCSSInlineStyle-impl").implementation; +const GlobalEventHandlersImpl = require("./GlobalEventHandlers-impl").implementation; +const HTMLOrSVGElementImpl = require("./HTMLOrSVGElement-impl").implementation; +const { firstChildWithLocalName } = require("../helpers/traversal"); +const { isDisabled } = require("../helpers/form-controls"); +const { fireAnEvent } = require("../helpers/events"); +const { asciiLowercase } = require("../helpers/strings"); +const { lookupCEDefinition } = require("../helpers/custom-elements"); + +class HTMLElementImpl extends ElementImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + this._initHTMLOrSVGElement(); + this._initElementCSSInlineStyle(); + this._initGlobalEvents(); + + this._clickInProgress = false; + + // uses HTMLElement and has activation behavior + this._hasActivationBehavior = this._localName === "summary"; + + // https://html.spec.whatwg.org/#attached-internals + this._attachedInternals = null; + } + + _activationBehavior() { + const parent = this.parentNode; + if (parent && parent._localName === "details" && + this === firstChildWithLocalName(parent, "summary")) { + if (parent.hasAttributeNS(null, "open")) { + parent.removeAttributeNS(null, "open"); + } else { + parent.setAttributeNS(null, "open", ""); + } + } + } + + // https://html.spec.whatwg.org/multipage/dom.html#the-translate-attribute + get translate() { + const translateAttr = this.getAttributeNS(null, "translate"); + const translateAttrString = asciiLowercase(translateAttr || ""); + + if (translateAttrString === "yes" || (translateAttr && translateAttrString === "")) { + return true; + } else if (translateAttrString === "no") { + return false; + } + + if (this === this.ownerDocument.documentElement) { + return true; + } + + return this.parentElement && this.parentElement.translate; + } + set translate(value) { + if (value === true) { + this.setAttributeNS(null, "translate", "yes"); + } else { + this.setAttributeNS(null, "translate", "no"); + } + } + + click() { + // https://html.spec.whatwg.org/multipage/interaction.html#dom-click + // https://html.spec.whatwg.org/multipage/webappapis.html#fire-a-synthetic-pointer-event + + if (isDisabled(this)) { + return; + } + + if (this._clickInProgress) { + return; + } + + this._clickInProgress = true; + + // https://github.com/whatwg/html/issues/4452 + // https://github.com/whatwg/html/issues/11236 + fireAnEvent("click", this, PointerEvent, { + bubbles: true, + cancelable: true, + composed: true, + isTrusted: false, + pointerId: -1, + view: this.ownerDocument.defaultView + }); + + this._clickInProgress = false; + } + + get draggable() { + const attributeValue = asciiLowercase(this.getAttributeNS(null, "draggable") || ""); + + if (attributeValue === "true") { + return true; + } else if (attributeValue === "false") { + return false; + } + + return this._localName === "img" || (this._localName === "a" && this.hasAttributeNS(null, "href")); + } + set draggable(value) { + this.setAttributeNS(null, "draggable", String(value)); + } + + get dir() { + let dirValue = this.getAttributeNS(null, "dir"); + if (dirValue !== null) { + dirValue = dirValue.toLowerCase(); + + if (["ltr", "rtl", "auto"].includes(dirValue)) { + return dirValue; + } + } + return ""; + } + set dir(value) { + this.setAttributeNS(null, "dir", value); + } + + // https://html.spec.whatwg.org/#dom-attachinternals + attachInternals() { + if (this._isValue !== null) { + throw DOMException.create(this._globalObject, [ + "Unable to attach ElementInternals to a customized built-in element.", + "NotSupportedError" + ]); + } + + const definition = lookupCEDefinition(this._ownerDocument, this._namespaceURI, this._localName, null); + + if (definition === null) { + throw DOMException.create(this._globalObject, [ + "Unable to attach ElementInternals to non-custom elements.", + "NotSupportedError" + ]); + } + + if (definition.disableInternals === true) { + throw DOMException.create(this._globalObject, [ + "ElementInternals is disabled by disabledFeature static field.", + "NotSupportedError" + ]); + } + + if (this._attachedInternals !== null) { + throw DOMException.create(this._globalObject, [ + "ElementInternals for the specified element was already attached.", + "NotSupportedError" + ]); + } + + if (this._ceState !== "precustomized" && this._ceState !== "custom") { + throw DOMException.create(this._globalObject, [ + "The attachInternals() function cannot be called prior to the execution of the custom element constructor.", + "NotSupportedError" + ]); + } + + this._attachedInternals = ElementInternals.createImpl(this._globalObject, [], { targetElement: this }); + + return this._attachedInternals; + } + + // Keep in sync with SVGElement. https://github.com/jsdom/jsdom/issues/2599 + _attrModified(name, value, oldValue) { + if (name === "style" && value !== oldValue && !this._settingCssText) { + this._settingCssText = true; + this._style.cssText = value; + this._settingCssText = false; + } else if (name.startsWith("on")) { + this._globalEventChanged(name.substring(2)); + } + + super._attrModified(name, value, oldValue); + } + + get offsetParent() { + return null; + } + + get offsetTop() { + return 0; + } + + get offsetLeft() { + return 0; + } + + get offsetWidth() { + return 0; + } + + get offsetHeight() { + return 0; + } +} + +mixin(HTMLElementImpl.prototype, ElementCSSInlineStyleImpl.prototype); +mixin(HTMLElementImpl.prototype, GlobalEventHandlersImpl.prototype); +mixin(HTMLElementImpl.prototype, HTMLOrSVGElementImpl.prototype); + +module.exports = { + implementation: HTMLElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLEmbedElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLEmbedElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..c1c9788b9517a9ec9cc6ddecead399d6c9ca3b8d --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLEmbedElement-impl.js @@ -0,0 +1,8 @@ +"use strict"; +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLEmbedElementImpl extends HTMLElementImpl {} + +module.exports = { + implementation: HTMLEmbedElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFieldSetElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFieldSetElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..360a8388dbc1efe962f0033abbaced39e0769faa --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFieldSetElement-impl.js @@ -0,0 +1,43 @@ +"use strict"; +const HTMLCollection = require("../generated/HTMLCollection"); +const HTMLElementImpl = require("./HTMLElement-impl").implementation; +const DefaultConstraintValidationImpl = + require("../constraint-validation/DefaultConstraintValidation-impl").implementation; +const { formOwner } = require("../helpers/form-controls"); +const { mixin } = require("../../utils"); +const { descendantsByLocalNames } = require("../helpers/traversal"); + +const listedElements = new Set(["button", "fieldset", "input", "object", "output", "select", "textarea"]); + +class HTMLFieldSetElementImpl extends HTMLElementImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this._customValidityErrorMessage = ""; + } + + get elements() { + return HTMLCollection.createImpl(this._globalObject, [], { + element: this, + query: () => descendantsByLocalNames(this, listedElements) + }); + } + + get form() { + return formOwner(this); + } + + get type() { + return "fieldset"; + } + + _barredFromConstraintValidationSpecialization() { + return true; + } +} + +mixin(HTMLFieldSetElementImpl.prototype, DefaultConstraintValidationImpl.prototype); + +module.exports = { + implementation: HTMLFieldSetElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFontElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFontElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..688773a242d8d3156eaf75a97e7bcb4607f715c4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFontElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLFontElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLFontElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFormControlsCollection-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFormControlsCollection-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..22a73517d1bebc7d697e905433b40ce9756c26b7 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFormControlsCollection-impl.js @@ -0,0 +1,33 @@ +"use strict"; + +const HTMLCollectionImpl = require("./HTMLCollection-impl").implementation; +const RadioNodeList = require("../generated/RadioNodeList"); + +exports.implementation = class HTMLFormControlsCollectionImpl extends HTMLCollectionImpl { + namedItem(name) { + if (name === "") { + return null; + } + + this._update(); + + const nodeList = RadioNodeList.createImpl(this._globalObject, [], { + element: this, + query: () => this._list.filter( + e => e.getAttributeNS(null, "id") === name || e.getAttributeNS(null, "name") === name + ) + }); + + switch (nodeList.length) { + case 0: { + return null; + } + case 1: { + return nodeList.item(0); + } + default: { + return nodeList; + } + } + } +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFormElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFormElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..a7a9fb2cfb88b2bb27a949caa89676a8c6986437 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFormElement-impl.js @@ -0,0 +1,248 @@ +"use strict"; + +const idlUtils = require("../generated/utils.js"); +const DOMException = require("../generated/DOMException"); +const { serializeURL } = require("whatwg-url"); +const HTMLElementImpl = require("./HTMLElement-impl").implementation; +const { domSymbolTree } = require("../helpers/internal-constants"); +const { fireAnEvent } = require("../helpers/events"); +const { formOwner, isListed, isSubmittable, isSubmitButton } = require("../helpers/form-controls"); +const HTMLFormControlsCollection = require("../generated/HTMLFormControlsCollection"); +const { notImplementedMethod } = require("../../browser/not-implemented"); +const SubmitEvent = require("../generated/SubmitEvent"); + +const encTypes = new Set([ + "application/x-www-form-urlencoded", + "multipart/form-data", + "text/plain" +]); + +const methods = new Set([ + "get", + "post", + "dialog" +]); + +const constraintValidationPositiveResult = Symbol("positive"); +const constraintValidationNegativeResult = Symbol("negative"); + +class HTMLFormElementImpl extends HTMLElementImpl { + _descendantAdded(parent, child) { + const form = this; + for (const el of domSymbolTree.treeIterator(child)) { + if (typeof el._changedFormOwner === "function") { + el._changedFormOwner(form); + } + } + + super._descendantAdded(parent, child); + } + + _descendantRemoved(parent, child) { + for (const el of domSymbolTree.treeIterator(child)) { + if (typeof el._changedFormOwner === "function") { + el._changedFormOwner(null); + } + } + + super._descendantRemoved(parent, child); + } + + _getSubmittableElementNodes() { + return domSymbolTree.treeToArray(this.getRootNode({}), { + filter: node => { + if (!isSubmittable(node)) { + return false; + } + + return formOwner(node) === this; + } + }); + } + + _getElementNodes() { + return domSymbolTree.treeToArray(this.getRootNode({}), { + filter: node => { + if (!isListed(node) || (node._localName === "input" && node.type === "image")) { + return false; + } + + return formOwner(node) === this; + } + }); + } + + // https://html.spec.whatwg.org/multipage/forms.html#dom-form-elements + get elements() { + return HTMLFormControlsCollection.createImpl(this._globalObject, [], { + element: this.getRootNode({}), + query: () => this._getElementNodes() + }); + } + + [idlUtils.indexedGet](index) { + return this._getElementNodes()[index] || null; + } + + get [idlUtils.supportedPropertyIndices]() { + return Object.keys(this._getElementNodes()); + } + + get length() { + return this.elements.length; + } + + _doRequestSubmit(submitter) { + if (!this.isConnected) { + return; + } + + this.requestSubmit(submitter); + } + + submit() { + notImplementedMethod(this._ownerDocument._defaultView, "HTMLFormElement", "submit"); + } + + requestSubmit(submitter = null) { + if (submitter !== null) { + if (!isSubmitButton(submitter)) { + throw new TypeError("The specified element is not a submit button"); + } + if (submitter.form !== this) { + throw DOMException.create(this._globalObject, [ + "The specified element is not owned by this form element", + "NotFoundError" + ]); + } + } + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-algorithm + // Step 6.3: if form doesn't have the 'novalidate' attribute, validate it and abort submission if form is invalid + if (!this.hasAttributeNS(null, "novalidate") && !this.reportValidity()) { + return; + } + + if (!fireAnEvent("submit", this, SubmitEvent, { bubbles: true, cancelable: true, submitter })) { + return; + } + + notImplementedMethod(this._ownerDocument._defaultView, "HTMLFormElement", "requestSubmit"); + } + + _doReset() { + if (!this.isConnected) { + return; + } + + this.reset(); + } + + reset() { + if (!fireAnEvent("reset", this, undefined, { bubbles: true, cancelable: true })) { + return; + } + + for (const el of this.elements) { + if (typeof el._formReset === "function") { + el._formReset(); + } + } + } + + get method() { + let method = this.getAttributeNS(null, "method"); + if (method) { + method = method.toLowerCase(); + } + + if (methods.has(method)) { + return method; + } + return "get"; + } + + set method(V) { + this.setAttributeNS(null, "method", V); + } + + get enctype() { + let type = this.getAttributeNS(null, "enctype"); + if (type) { + type = type.toLowerCase(); + } + + if (encTypes.has(type)) { + return type; + } + return "application/x-www-form-urlencoded"; + } + + set enctype(V) { + this.setAttributeNS(null, "enctype", V); + } + + get action() { + const attributeValue = this.getAttributeNS(null, "action"); + if (attributeValue === null || attributeValue === "") { + return this._ownerDocument.URL; + } + const urlRecord = this._ownerDocument.encodingParseAURL(attributeValue); + if (urlRecord === null) { + return attributeValue; + } + return serializeURL(urlRecord); + } + + set action(V) { + this.setAttributeNS(null, "action", V); + } + + // If the checkValidity() method is invoked, the user agent must statically validate the + // constraints of the form element, and return true if the constraint validation returned + // a positive result, and false if it returned a negative result. + checkValidity() { + return this._staticallyValidateConstraints().result === constraintValidationPositiveResult; + } + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#interactively-validate-the-constraints + reportValidity() { + return this.checkValidity(); + } + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#statically-validate-the-constraints + _staticallyValidateConstraints() { + const controls = []; + for (const el of this.elements) { + if (el.form === this && isSubmittable(el)) { + controls.push(el); + } + } + + const invalidControls = []; + + for (const control of controls) { + if (control._isCandidateForConstraintValidation() && !control._satisfiesConstraints()) { + invalidControls.push(control); + } + } + + if (invalidControls.length === 0) { + return { result: constraintValidationPositiveResult }; + } + + const unhandledInvalidControls = []; + for (const invalidControl of invalidControls) { + const notCancelled = fireAnEvent("invalid", invalidControl, undefined, { cancelable: true }); + if (notCancelled) { + unhandledInvalidControls.push(invalidControl); + } + } + + return { result: constraintValidationNegativeResult, unhandledInvalidControls }; + } +} + +module.exports = { + implementation: HTMLFormElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFrameElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFrameElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..20e9d3520104c7f75889c0d5d1a49786edbf6b27 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFrameElement-impl.js @@ -0,0 +1,266 @@ +"use strict"; + +const MIMEType = require("whatwg-mimetype"); +const whatwgEncoding = require("whatwg-encoding"); +const { parseURL, serializeURL } = require("whatwg-url"); +const sniffHTMLEncoding = require("html-encoding-sniffer"); + +const window = require("../../browser/Window"); +const HTMLElementImpl = require("./HTMLElement-impl").implementation; +const { evaluateJavaScriptURL } = require("../window/navigation"); +const { parseIntoDocument } = require("../../browser/parser"); +const { fireAnEvent } = require("../helpers/events"); +const { getAttributeValue } = require("../attributes"); +const idlUtils = require("../generated/utils"); + +function fireLoadEvent(document, frame, attaching) { + if (attaching) { + fireAnEvent("load", frame); + + return; + } + + const dummyPromise = Promise.resolve(); + + function onLoad() { + fireAnEvent("load", frame); + } + + document._queue.push(dummyPromise, onLoad); +} + +function fetchFrame(serializedURL, frame, document, contentDoc) { + const resourceLoader = document._resourceLoader; + + let request; + + function onFrameLoaded(data) { + const sniffOptions = { + defaultEncoding: document._encoding + }; + + if (request.response) { + const contentType = MIMEType.parse(request.response.headers["content-type"]) || new MIMEType("text/plain"); + sniffOptions.transportLayerEncodingLabel = contentType.parameters.get("charset"); + + if (contentType) { + if (contentType.isXML()) { + contentDoc._parsingMode = "xml"; + } + contentDoc.contentType = contentType.essence; + } + } + + const encoding = sniffHTMLEncoding(data, sniffOptions); + contentDoc._encoding = encoding; + + const html = whatwgEncoding.decode(data, contentDoc._encoding); + + try { + parseIntoDocument(html, contentDoc); + } catch (error) { + const { DOMException } = contentDoc._globalObject; + + if ( + error.constructor.name === "DOMException" && + error.code === DOMException.SYNTAX_ERR && + contentDoc._parsingMode === "xml" + ) { + // As defined (https://html.spec.whatwg.org/#read-xml) parsing error in XML document may be reported inline by + // mutating the document. + const element = contentDoc.createElementNS("http://www.mozilla.org/newlayout/xml/parsererror.xml", "parsererror"); + element.textContent = error.message; + + while (contentDoc.childNodes.length > 0) { + contentDoc.removeChild(contentDoc.lastChild); + } + contentDoc.appendChild(element); + } else { + throw error; + } + } + + contentDoc.close(); + + return new Promise((resolve, reject) => { + contentDoc.addEventListener("load", resolve); + contentDoc.addEventListener("error", reject); + }); + } + + request = resourceLoader.fetch(serializedURL, { + element: frame, + onLoad: onFrameLoaded + }); +} + +function canDispatchEvents(frame, attaching) { + if (!attaching) { + return false; + } + + return Object.keys(frame._eventListeners).length === 0; +} + +function loadFrame(frame, attaching) { + if (frame._contentDocument) { + if (frame._contentDocument._defaultView) { + // close calls delete on its document. + frame._contentDocument._defaultView.close(); + } else { + delete frame._contentDocument; + } + } + + const parentDoc = frame._ownerDocument; + + // https://html.spec.whatwg.org/#process-the-iframe-attributes + let url; + const srcAttribute = getAttributeValue(frame, "src"); + if (srcAttribute === "") { + url = parseURL("about:blank"); + } else { + url = parseURL(srcAttribute, { baseURL: parentDoc.baseURL() || undefined }) || parseURL("about:blank"); + } + const serializedURL = serializeURL(url); + + const wnd = window.createWindow({ + parsingMode: "html", + url: url.scheme === "javascript" ? parentDoc.URL : serializedURL, + parentOrigin: parentDoc._origin, + resourceLoader: parentDoc._defaultView._resourceLoader, + referrer: parentDoc.URL, + cookieJar: parentDoc._cookieJar, + pool: parentDoc._pool, + encoding: parentDoc._encoding, + runScripts: parentDoc._defaultView._runScripts, + commonForOrigin: parentDoc._defaultView._commonForOrigin, + pretendToBeVisual: parentDoc._defaultView._pretendToBeVisual + }); + + const contentDoc = frame._contentDocument = idlUtils.implForWrapper(wnd._document); + const parent = parentDoc._defaultView; + const contentWindow = contentDoc._defaultView; + contentWindow._parent = parent; + contentWindow._top = parent.top; + contentWindow._frameElement = frame; + contentWindow._virtualConsole = parent._virtualConsole; + + if (parentDoc._origin === contentDoc._origin) { + contentWindow._currentOriginData.windowsInSameOrigin.push(contentWindow); + } + + const noQueue = canDispatchEvents(frame, attaching); + + // Handle about:blank with a simulated load of an empty document. + if (serializedURL === "about:blank") { + // Cannot be done inside the enqueued callback; the documentElement etc. need to be immediately available. + parseIntoDocument("", contentDoc); + contentDoc.close(noQueue); + + if (noQueue) { + fireLoadEvent(parentDoc, frame, noQueue); + } else { + contentDoc.addEventListener("load", () => { + fireLoadEvent(parentDoc, frame); + }); + } + } else if (url.scheme === "javascript") { + // Cannot be done inside the enqueued callback; the documentElement etc. need to be immediately available. + parseIntoDocument("", contentDoc); + contentDoc.close(noQueue); + const result = evaluateJavaScriptURL(contentWindow, url); + if (typeof result === "string") { + contentDoc.body.textContent = result; + } + if (noQueue) { + fireLoadEvent(parentDoc, frame, noQueue); + } else { + contentDoc.addEventListener("load", () => { + fireLoadEvent(parentDoc, frame); + }); + } + } else { + fetchFrame(serializedURL, frame, parentDoc, contentDoc); + } +} + +function refreshAccessors(document) { + const { _defaultView } = document; + + if (!_defaultView) { + return; + } + + const frames = document.querySelectorAll("iframe,frame"); + + // delete accessors for all frames + for (let i = 0; i < _defaultView._length; ++i) { + delete _defaultView[i]; + } + + _defaultView._length = frames.length; + for (let i = 0; i < frames.length; ++i) { + const frame = frames.item(i); + Object.defineProperty(_defaultView, i, { + configurable: true, + enumerable: true, + get() { + return frame.contentWindow; + } + }); + } +} + +class HTMLFrameElementImpl extends HTMLElementImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + this._contentDocument = null; + } + _attrModified(name, value, oldVal) { + super._attrModified(name, value, oldVal); + if (name === "src") { + // iframe should never load in a document without a Window + // (e.g. implementation.createHTMLDocument) + if (this._attached && this._ownerDocument._defaultView) { + loadFrame(this); + } + } + } + + _detach() { + super._detach(); + + if (this.contentWindow) { + // TODO: this is not really correct behavior, because jsdom's window.close() is very aggressive and is meant for + // killing off the whole jsdom, not just moving the Window to a no-browsing-context state. + // + // If we revise this in the future, be sure to also invalidate the base URL cache. + + this.contentWindow.close(); + } + + refreshAccessors(this._ownerDocument); + } + + _attach() { + super._attach(); + + if (this._ownerDocument._defaultView) { + loadFrame(this, true); + } + refreshAccessors(this._ownerDocument); + } + + get contentDocument() { + return this._contentDocument; + } + + get contentWindow() { + return this.contentDocument ? this.contentDocument._defaultView : null; + } +} + +module.exports = { + implementation: HTMLFrameElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFrameSetElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFrameSetElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..89eee2de691b7999a6265ef044173b08726b0b76 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLFrameSetElement-impl.js @@ -0,0 +1,17 @@ +"use strict"; +const { mixin } = require("../../utils"); +const HTMLElementImpl = require("./HTMLElement-impl").implementation; +const WindowEventHandlersImpl = require("./WindowEventHandlers-impl").implementation; + +class HTMLFrameSetElementImpl extends HTMLElementImpl { + constructor(...args) { + super(...args); + this._proxyWindowEventsToWindow(); + } +} + +mixin(HTMLFrameSetElementImpl.prototype, WindowEventHandlersImpl.prototype); + +module.exports = { + implementation: HTMLFrameSetElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHRElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHRElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..8c5d337f909bb40f33bdd66a5ee0f19be3ae8efb --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHRElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLHRElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLHRElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHeadElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHeadElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..68033772a3917d5f6666b065c4ca3e5a420a22d4 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHeadElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLHeadElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLHeadElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHeadingElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHeadingElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..4fb4250434578745268de12a4890f9e285d6d359 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHeadingElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLHeadingElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLHeadingElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHtmlElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHtmlElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..bda178068b64b41fb94784d90301d5f59c38cf5b --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHtmlElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLHtmlElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLHtmlElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHyperlinkElementUtils-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHyperlinkElementUtils-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..5a9d773251a0109683b00dec2e199501fe845240 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLHyperlinkElementUtils-impl.js @@ -0,0 +1,366 @@ +"use strict"; +const whatwgURL = require("whatwg-url"); +const { asciiCaseInsensitiveMatch } = require("../helpers/strings"); +const { navigate } = require("../window/navigation"); + +exports.implementation = class HTMLHyperlinkElementUtilsImpl { + _htmlHyperlinkElementUtilsSetup() { + this.url = null; + } + + // https://html.spec.whatwg.org/multipage/links.html#cannot-navigate + _cannotNavigate() { + // TODO: Correctly check if the document is fully active + return this._localName !== "a" && !this.isConnected; + } + + // https://html.spec.whatwg.org/multipage/semantics.html#get-an-element's-target + _getAnElementsTarget() { + if (this.hasAttributeNS(null, "target")) { + return this.getAttributeNS(null, "target"); + } + + const baseEl = this._ownerDocument.querySelector("base[target]"); + + if (baseEl) { + return baseEl.getAttributeNS(null, "target"); + } + + return ""; + } + + // https://html.spec.whatwg.org/multipage/browsers.html#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name + _chooseABrowsingContext(name, current) { + let chosen = null; + + if (name === "" || asciiCaseInsensitiveMatch(name, "_self")) { + chosen = current; + } else if (asciiCaseInsensitiveMatch(name, "_parent")) { + chosen = current.parent; + } else if (asciiCaseInsensitiveMatch(name, "_top")) { + chosen = current.top; + } else if (!asciiCaseInsensitiveMatch(name, "_blank")) { + // https://github.com/whatwg/html/issues/1440 + } + + // TODO: Create new browsing context, handle noopener + + return chosen; + } + + // https://html.spec.whatwg.org/multipage/links.html#following-hyperlinks-2 + _followAHyperlink() { + if (this._cannotNavigate()) { + return; + } + + const source = this._ownerDocument._defaultView; + let targetAttributeValue = ""; + + if (this._localName === "a" || this._localName === "area") { + targetAttributeValue = this._getAnElementsTarget(); + } + + const noopener = this.relList.contains("noreferrer") || this.relList.contains("noopener"); + + const target = this._chooseABrowsingContext(targetAttributeValue, source, noopener); + + if (target === null) { + return; + } + + const url = this._ownerDocument.encodingParseAURL(this.href); + + if (url === null) { + return; + } + + // TODO: Handle hyperlink suffix and referrerpolicy + setTimeout(() => { + navigate(target, url, {}); + }, 0); + } + + toString() { + return this.href; + } + + get href() { + reinitializeURL(this); + const { url } = this; + + if (url === null) { + const href = this.getAttributeNS(null, "href"); + return href === null ? "" : href; + } + + return whatwgURL.serializeURL(url); + } + + set href(v) { + this.setAttributeNS(null, "href", v); + } + + get origin() { + reinitializeURL(this); + + if (this.url === null) { + return ""; + } + + return whatwgURL.serializeURLOrigin(this.url); + } + + get protocol() { + reinitializeURL(this); + + if (this.url === null) { + return ":"; + } + + return this.url.scheme + ":"; + } + + set protocol(v) { + reinitializeURL(this); + + if (this.url === null) { + return; + } + + whatwgURL.basicURLParse(v + ":", { url: this.url, stateOverride: "scheme start" }); + updateHref(this); + } + + get username() { + reinitializeURL(this); + + if (this.url === null) { + return ""; + } + + return this.url.username; + } + + set username(v) { + reinitializeURL(this); + const { url } = this; + + if (url === null || whatwgURL.cannotHaveAUsernamePasswordPort(url)) { + return; + } + + whatwgURL.setTheUsername(url, v); + updateHref(this); + } + + get password() { + reinitializeURL(this); + const { url } = this; + + if (url === null) { + return ""; + } + + return url.password; + } + + set password(v) { + reinitializeURL(this); + const { url } = this; + + if (url === null || whatwgURL.cannotHaveAUsernamePasswordPort(url)) { + return; + } + + whatwgURL.setThePassword(url, v); + updateHref(this); + } + + get host() { + reinitializeURL(this); + const { url } = this; + + if (url === null || url.host === null) { + return ""; + } + + if (url.port === null) { + return whatwgURL.serializeHost(url.host); + } + + return whatwgURL.serializeHost(url.host) + ":" + whatwgURL.serializeInteger(url.port); + } + + set host(v) { + reinitializeURL(this); + const { url } = this; + + if (url === null || whatwgURL.hasAnOpaquePath(url)) { + return; + } + + whatwgURL.basicURLParse(v, { url, stateOverride: "host" }); + updateHref(this); + } + + get hostname() { + reinitializeURL(this); + const { url } = this; + + if (url === null || url.host === null) { + return ""; + } + + return whatwgURL.serializeHost(url.host); + } + + set hostname(v) { + reinitializeURL(this); + const { url } = this; + + if (url === null || whatwgURL.hasAnOpaquePath(url)) { + return; + } + + whatwgURL.basicURLParse(v, { url, stateOverride: "hostname" }); + updateHref(this); + } + + get port() { + reinitializeURL(this); + const { url } = this; + + if (url === null || url.port === null) { + return ""; + } + + return whatwgURL.serializeInteger(url.port); + } + + set port(v) { + reinitializeURL(this); + const { url } = this; + + if (url === null || whatwgURL.cannotHaveAUsernamePasswordPort(url)) { + return; + } + + if (v === "") { + url.port = null; + } else { + whatwgURL.basicURLParse(v, { url, stateOverride: "port" }); + } + updateHref(this); + } + + get pathname() { + reinitializeURL(this); + const { url } = this; + + if (url === null) { + return ""; + } + + return whatwgURL.serializePath(url); + } + + set pathname(v) { + reinitializeURL(this); + const { url } = this; + + if (url === null || whatwgURL.hasAnOpaquePath(url)) { + return; + } + + url.path = []; + whatwgURL.basicURLParse(v, { url, stateOverride: "path start" }); + updateHref(this); + } + + get search() { + reinitializeURL(this); + const { url } = this; + + if (url === null || url.query === null || url.query === "") { + return ""; + } + + return "?" + url.query; + } + + set search(v) { + reinitializeURL(this); + const { url } = this; + + if (url === null) { + return; + } + + if (v === "") { + url.query = null; + } else { + const input = v[0] === "?" ? v.substring(1) : v; + url.query = ""; + whatwgURL.basicURLParse(input, { + url, + stateOverride: "query", + encodingOverride: this._ownerDocument.charset + }); + } + updateHref(this); + } + + get hash() { + reinitializeURL(this); + const { url } = this; + + if (url === null || url.fragment === null || url.fragment === "") { + return ""; + } + + return "#" + url.fragment; + } + + set hash(v) { + reinitializeURL(this); + const { url } = this; + + if (url === null) { + return; + } + + if (v === "") { + url.fragment = null; + } else { + const input = v[0] === "#" ? v.substring(1) : v; + url.fragment = ""; + whatwgURL.basicURLParse(input, { url, stateOverride: "fragment" }); + } + updateHref(this); + } +}; + +function reinitializeURL(hheu) { + if (hheu.url !== null && hheu.url.scheme === "blob" && whatwgURL.hasAnOpaquePath(hheu.url)) { + return; + } + + setTheURL(hheu); +} + +function setTheURL(hheu) { + const href = hheu.getAttributeNS(null, "href"); + if (href === null) { + hheu.url = null; + return; + } + + const parsed = hheu._ownerDocument.encodingParseAURL(href); + + hheu.url = parsed === null ? null : parsed; +} + +function updateHref(hheu) { + hheu.setAttributeNS(null, "href", whatwgURL.serializeURL(hheu.url)); +} diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLIFrameElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLIFrameElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..643e98965badafc58ae4665f562a38bb07608ded --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLIFrameElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLFrameElementImpl = require("./HTMLFrameElement-impl").implementation; + +class HTMLIFrameElementImpl extends HTMLFrameElementImpl { } + +module.exports = { + implementation: HTMLIFrameElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLImageElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLImageElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..b755103a53e8dc6e5d36599359804b8cd3935e37 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLImageElement-impl.js @@ -0,0 +1,131 @@ +"use strict"; +const conversions = require("webidl-conversions"); +const { serializeURL } = require("whatwg-url"); +const HTMLElementImpl = require("./HTMLElement-impl").implementation; +const { Canvas } = require("../../utils"); + +class HTMLImageElementImpl extends HTMLElementImpl { + constructor(...args) { + super(...args); + this._currentRequestState = "unavailable"; + } + + _attrModified(name, value, oldVal) { + // TODO: handle crossorigin + if (name === "src" || ((name === "srcset" || name === "width" || name === "sizes") && value !== oldVal)) { + this._updateTheImageData(); + } + + super._attrModified(name, value, oldVal); + } + + get _accept() { + return "image/png,image/*;q=0.8,*/*;q=0.5"; + } + + get height() { + // Just like on browsers, if no width / height is defined, we fall back on the + // dimensions of the internal image data. + return this.hasAttributeNS(null, "height") ? + conversions["unsigned long"](this.getAttributeNS(null, "height")) : + this.naturalHeight; + } + + set height(V) { + this.setAttributeNS(null, "height", String(V)); + } + + get width() { + return this.hasAttributeNS(null, "width") ? + conversions["unsigned long"](this.getAttributeNS(null, "width")) : + this.naturalWidth; + } + + set width(V) { + this.setAttributeNS(null, "width", String(V)); + } + + get naturalHeight() { + return this._image ? this._image.naturalHeight : 0; + } + + get naturalWidth() { + return this._image ? this._image.naturalWidth : 0; + } + + get complete() { + const srcAttributeValue = this.getAttributeNS(null, "src"); + return srcAttributeValue === null || + srcAttributeValue === "" || + this._currentRequestState === "broken" || + this._currentRequestState === "completely available"; + } + + get currentSrc() { + return this._currentSrc || ""; + } + + // https://html.spec.whatwg.org/multipage/images.html#updating-the-image-data + _updateTheImageData() { + const document = this._ownerDocument; + + if (!document._defaultView) { + return; + } + + if (!Canvas) { + return; + } + + if (!this._image) { + this._image = new Canvas.Image(); + } + this._currentSrc = null; + this._currentRequestState = "unavailable"; + const srcAttributeValue = this.getAttributeNS(null, "src"); + let urlString = null; + if (srcAttributeValue !== null && srcAttributeValue !== "") { + const urlRecord = this._ownerDocument.encodingParseAURL(srcAttributeValue); + if (urlRecord === null) { + return; + } + urlString = serializeURL(urlRecord); + } + if (urlString !== null) { + const resourceLoader = document._resourceLoader; + let request; + + const onLoadImage = data => { + const { response } = request; + + if (response && response.statusCode !== undefined && response.statusCode !== 200) { + throw new Error("Status code: " + response.statusCode); + } + let error = null; + this._image.onerror = function (err) { + error = err; + }; + this._image.src = data; + if (error) { + throw new Error(error); + } + this._currentSrc = srcAttributeValue; + this._currentRequestState = "completely available"; + }; + + request = resourceLoader.fetch(urlString, { + element: this, + onLoad: onLoadImage, + onError: () => { + this._currentRequestState = "broken"; + } + }); + } else { + this._image.src = ""; + } + } +} + +module.exports = { + implementation: HTMLImageElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLInputElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLInputElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..7968fefff0d207912b1ce6fcc371cda0faad83e8 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLInputElement-impl.js @@ -0,0 +1,1097 @@ +"use strict"; +const DOMException = require("../generated/DOMException"); +const FileList = require("../generated/FileList"); +const Decimal = require("decimal.js"); +const HTMLElementImpl = require("./HTMLElement-impl").implementation; +const idlUtils = require("../generated/utils"); +const DefaultConstraintValidationImpl = + require("../constraint-validation/DefaultConstraintValidation-impl").implementation; +const ValidityState = require("../generated/ValidityState"); +const { mixin } = require("../../utils"); +const { domSymbolTree, cloningSteps } = require("../helpers/internal-constants"); +const { getLabelsForLabelable, formOwner } = require("../helpers/form-controls"); +const { fireAnEvent } = require("../helpers/events"); +const { + isDisabled, + isValidEmailAddress, + isValidAbsoluteURL, + sanitizeValueByType +} = require("../helpers/form-controls"); +const { + asciiCaseInsensitiveMatch, + asciiLowercase, + parseFloatingPointNumber, + splitOnCommas +} = require("../helpers/strings"); +const { isDate } = require("../helpers/dates-and-times"); +const { + convertStringToNumberByType, + convertStringToDateByType, + serializeDateByType, + convertNumberToStringByType +} = require("../helpers/number-and-date-inputs"); + +const filesSymbol = Symbol("files"); + +// https://html.spec.whatwg.org/multipage/input.html#attr-input-type +const inputAllowedTypes = new Set([ + "hidden", "text", "search", "tel", "url", "email", "password", "date", + "month", "week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio", + "file", "submit", "image", "reset", "button" +]); + +// https://html.spec.whatwg.org/multipage/input.html#concept-input-apply + +const variableLengthSelectionAllowedTypes = new Set(["text", "search", "url", "tel", "password"]); +const numericTypes = new Set(["date", "month", "week", "time", "datetime-local", "number", "range"]); + +const applicableTypesForIDLMember = { + valueAsDate: new Set(["date", "month", "week", "time"]), + valueAsNumber: numericTypes, + + select: new Set([ + "text", "search", "url", "tel", "email", "password", "date", "month", "week", + "time", "datetime-local", "number", "color", "file" + ]), + selectionStart: variableLengthSelectionAllowedTypes, + selectionEnd: variableLengthSelectionAllowedTypes, + selectionDirection: variableLengthSelectionAllowedTypes, + setRangeText: variableLengthSelectionAllowedTypes, + setSelectionRange: variableLengthSelectionAllowedTypes, + stepDown: numericTypes, + stepUp: numericTypes +}; + +const lengthPatternSizeTypes = new Set(["text", "search", "url", "tel", "email", "password"]); +const readonlyTypes = + new Set([...lengthPatternSizeTypes, "date", "month", "week", "time", "datetime-local", "number"]); + +const applicableTypesForContentAttribute = { + list: new Set(["text", "search", "url", "tel", "email", ...numericTypes, "color"]), + max: numericTypes, + maxlength: lengthPatternSizeTypes, + min: numericTypes, + minlength: lengthPatternSizeTypes, + multiple: new Set(["email", "file"]), + pattern: lengthPatternSizeTypes, + readonly: readonlyTypes, + required: new Set([...readonlyTypes, "checkbox", "radio", "file"]), + step: numericTypes +}; + +const valueAttributeDefaultMode = new Set(["hidden", "submit", "image", "reset", "button"]); +const valueAttributeDefaultOnMode = new Set(["checkbox", "radio"]); + +function valueAttributeMode(type) { + if (valueAttributeDefaultMode.has(type)) { + return "default"; + } + if (valueAttributeDefaultOnMode.has(type)) { + return "default/on"; + } + if (type === "file") { + return "filename"; + } + return "value"; +} + +function getTypeFromAttribute(typeAttribute) { + if (typeof typeAttribute !== "string") { + return "text"; + } + const type = asciiLowercase(typeAttribute); + return inputAllowedTypes.has(type) ? type : "text"; +} + +class HTMLInputElementImpl extends HTMLElementImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this._selectionStart = this._selectionEnd = 0; + this._selectionDirection = "none"; + this._value = ""; + this._dirtyValue = false; + this._checkedness = false; + this._dirtyCheckedness = false; + + this._preCheckedRadioState = null; + this._legacyActivationBehaviorPreviousIndeterminateState = false; + + this.indeterminate = false; + + this._customValidityErrorMessage = ""; + + this._labels = null; + + this._hasActivationBehavior = true; + } + + // https://html.spec.whatwg.org/multipage/input.html#concept-input-value-string-number + get _convertStringToNumber() { + return convertStringToNumberByType[this.type]; + } + + get _convertNumberToString() { + return convertNumberToStringByType[this.type]; + } + + get _convertDateToString() { + return serializeDateByType[this.type]; + } + + get _convertStringToDate() { + return convertStringToDateByType[this.type]; + } + + _isStepAligned(v) { + return new Decimal(v).minus(this._stepBase) + .modulo(this._allowedValueStep) + .isZero(); + } + + // Returns a Decimal. + _stepAlign(v, roundUp) { + const allowedValueStep = this._allowedValueStep; + const stepBase = this._stepBase; + + return new Decimal(v).minus(stepBase) + .toNearest(allowedValueStep, roundUp ? Decimal.ROUND_UP : Decimal.ROUND_DOWN) + .add(stepBase); + } + + // For , https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-value + // is a simple value that is gotten and set, not computed. + _getValue() { + return this._value; + } + + _legacyPreActivationBehavior() { + if (this.type === "checkbox") { + this.checked = !this.checked; + this._legacyActivationBehaviorPreviousIndeterminateState = this.indeterminate; + this.indeterminate = false; + } else if (this.type === "radio") { + this._preCheckedRadioState = this.checked; + this.checked = true; + } + } + + _legacyCanceledActivationBehavior() { + if (this.type === "checkbox") { + this.checked = !this.checked; + this.indeterminate = this._legacyActivationBehaviorPreviousIndeterminateState; + } else if (this.type === "radio") { + if (this._preCheckedRadioState !== null) { + this.checked = this._preCheckedRadioState; + this._preCheckedRadioState = null; + } + } + } + + _activationBehavior(event) { + if (!this._mutable && this.type !== "checkbox" && this.type !== "radio") { + return; + } + + const { form } = this; + + if (this.type === "checkbox" || (this.type === "radio" && !this._preCheckedRadioState)) { + if (this.isConnected) { + fireAnEvent("input", this, undefined, { bubbles: true }); + fireAnEvent("change", this, undefined, { bubbles: true }); + } + } else if (form && this.type === "image") { + // https://html.spec.whatwg.org/multipage/input.html#image-button-state-(type=image):input-activation-behavior + + // TODO: if/when layout is implemented, record the selected coordinate at the start of dispatch and use it here, + // rather than relying on these getters that just mirror pageX/Y outside of dispatch + this._selectedCoordinate = { x: event.offsetX, y: event.offsetY }; + form._doRequestSubmit(this); + } else if (form && this.type === "submit") { + form._doRequestSubmit(this); + } else if (form && this.type === "reset") { + form._doReset(); + } + } + + _attrModified(name, value, oldVal) { + const wrapper = idlUtils.wrapperForImpl(this); + if (!this._dirtyValue && name === "value") { + this._value = sanitizeValueByType(this, wrapper.defaultValue); + } + if (!this._dirtyCheckedness && name === "checked") { + this._checkedness = wrapper.defaultChecked; + if (this._checkedness) { + this._removeOtherRadioCheckedness(); + } + } + + if (name === "name" || name === "type") { + if (this._checkedness) { + this._removeOtherRadioCheckedness(); + } + } + + if (name === "type") { + const prevType = getTypeFromAttribute(oldVal); + const curType = getTypeFromAttribute(value); + // When an input element's type attribute changes state… + if (prevType !== curType) { + const prevValueMode = valueAttributeMode(prevType); + const curValueMode = valueAttributeMode(curType); + if (prevValueMode === "value" && this._value !== "" && + (curValueMode === "default" || curValueMode === "default/on")) { + this.setAttributeNS(null, "value", this._value); + } else if (prevValueMode !== "value" && curValueMode === "value") { + this._value = this.getAttributeNS(null, "value") || ""; + this._dirtyValue = false; + } else if (prevValueMode !== "filename" && curValueMode === "filename") { + this._value = ""; + } + + this._signalATypeChange(); + + this._value = sanitizeValueByType(this, this._value); + + const previouslySelectable = this._idlMemberApplies("setRangeText", prevType); + const nowSelectable = this._idlMemberApplies("setRangeText", curType); + if (!previouslySelectable && nowSelectable) { + this._selectionStart = 0; + this._selectionEnd = 0; + this._selectionDirection = "none"; + } + } + } + + super._attrModified(name, value, oldVal); + } + + // https://html.spec.whatwg.org/multipage/input.html#signal-a-type-change + _signalATypeChange() { + if (this._checkedness) { + this._removeOtherRadioCheckedness(); + } + } + + _formReset() { + const wrapper = idlUtils.wrapperForImpl(this); + this._value = sanitizeValueByType(this, wrapper.defaultValue); + this._dirtyValue = false; + this._checkedness = wrapper.defaultChecked; + this._dirtyCheckedness = false; + if (this._checkedness) { + this._removeOtherRadioCheckedness(); + } + } + + _changedFormOwner() { + if (this._checkedness) { + this._removeOtherRadioCheckedness(); + } + } + + get _otherRadioGroupElements() { + const wrapper = idlUtils.wrapperForImpl(this); + const root = this._radioButtonGroupRoot; + if (!root) { + return []; + } + + const result = []; + + const descendants = domSymbolTree.treeIterator(root); + for (const candidate of descendants) { + if (candidate._radioButtonGroupRoot !== root) { + continue; + } + + const candidateWrapper = idlUtils.wrapperForImpl(candidate); + if (!candidateWrapper.name || candidateWrapper.name !== wrapper.name) { + continue; + } + + if (candidate !== this) { + result.push(candidate); + } + } + return result; + } + + _removeOtherRadioCheckedness() { + for (const radioGroupElement of this._otherRadioGroupElements) { + radioGroupElement._checkedness = false; + } + } + + get _radioButtonGroupRoot() { + const wrapper = idlUtils.wrapperForImpl(this); + if (this.type !== "radio" || !wrapper.name) { + return null; + } + + let e = domSymbolTree.parent(this); + while (e) { + // root node of this home sub tree + // or the form element we belong to + if (!domSymbolTree.parent(e) || e._localName === "form") { + return e; + } + e = domSymbolTree.parent(e); + } + return null; + } + + _someInRadioGroup(name) { + if (this[name]) { + return true; + } + return this._otherRadioGroupElements.some(radioGroupElement => radioGroupElement[name]); + } + + get _mutable() { + return !isDisabled(this) && !this._hasAttributeAndApplies("readonly"); + } + + get labels() { + return getLabelsForLabelable(this); + } + + get form() { + return formOwner(this); + } + + get checked() { + return this._checkedness; + } + + set checked(checked) { + this._checkedness = Boolean(checked); + this._dirtyCheckedness = true; + if (this._checkedness) { + this._removeOtherRadioCheckedness(); + } + } + + get value() { + switch (valueAttributeMode(this.type)) { + // https://html.spec.whatwg.org/multipage/input.html#dom-input-value-value + case "value": + return this._getValue(); + // https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default + case "default": { + const attr = this.getAttributeNS(null, "value"); + return attr !== null ? attr : ""; + } + // https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on + case "default/on": { + const attr = this.getAttributeNS(null, "value"); + return attr !== null ? attr : "on"; + } + // https://html.spec.whatwg.org/multipage/input.html#dom-input-value-filename + case "filename": + return this.files.length ? "C:\\fakepath\\" + this.files[0].name : ""; + default: + throw new Error("jsdom internal error: unknown value attribute mode"); + } + } + + set value(val) { + switch (valueAttributeMode(this.type)) { + // https://html.spec.whatwg.org/multipage/input.html#dom-input-value-value + case "value": { + const oldValue = this._value; + this._value = sanitizeValueByType(this, val); + this._dirtyValue = true; + + if (oldValue !== this._value) { + this._selectionStart = this._selectionEnd = this._getValueLength(); + this._selectionDirection = "none"; + } + break; + } + + // https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default + // https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on + case "default": + case "default/on": + this.setAttributeNS(null, "value", val); + break; + + // https://html.spec.whatwg.org/multipage/input.html#dom-input-value-filename + case "filename": + if (val === "") { + this.files.length = 0; + } else { + throw DOMException.create(this._globalObject, [ + "This input element accepts a filename, which may only be programmatically set to the empty string.", + "InvalidStateError" + ]); + } + break; + + default: + throw new Error("jsdom internal error: unknown value attribute mode"); + } + } + + // https://html.spec.whatwg.org/multipage/input.html#dom-input-valueasdate + get valueAsDate() { + if (!this._idlMemberApplies("valueAsDate")) { + return null; + } + + const window = this._ownerDocument._defaultView; + const convertedValue = this._convertStringToDate(this._value); + + if (convertedValue instanceof Date) { + return new window.Date(convertedValue.getTime()); + } + + return null; + } + + set valueAsDate(v) { + if (!this._idlMemberApplies("valueAsDate")) { + throw DOMException.create(this._globalObject, [ + "Failed to set the 'valueAsDate' property on 'HTMLInputElement': This input element does not support Date " + + "values.", + "InvalidStateError" + ]); + } + + if (v !== null && !isDate(v)) { + throw new TypeError("Failed to set the 'valueAsDate' property on 'HTMLInputElement': The provided value is " + + "not a Date."); + } + + if (v === null || isNaN(v)) { + this._value = ""; + return; + } + + this._value = this._convertDateToString(v); + } + + // https://html.spec.whatwg.org/multipage/input.html#dom-input-valueasnumber + get valueAsNumber() { + if (!this._idlMemberApplies("valueAsNumber")) { + return NaN; + } + + const parsedValue = this._convertStringToNumber(this._value); + return parsedValue !== null ? parsedValue : NaN; + } + + set valueAsNumber(v) { + if (!isFinite(v) && !isNaN(v)) { + throw new TypeError("Failed to set infinite value as Number"); + } + + if (!this._idlMemberApplies("valueAsNumber")) { + throw DOMException.create(this._globalObject, [ + "Failed to set the 'valueAsNumber' property on 'HTMLInputElement': This input element does not support " + + "Number values.", + "InvalidStateError" + ]); + } + + if (isNaN(v)) { + this._value = ""; + } else { + this._value = this._convertNumberToString(v); + } + } + + // https://html.spec.whatwg.org/multipage/input.html#dom-input-stepup + _stepUpdate(n, isUp) { + const methodName = isUp ? "stepUp" : "stepDown"; + if (!this._idlMemberApplies(methodName)) { + throw DOMException.create(this._globalObject, [ + `Failed to invoke '${methodName}' method on 'HTMLInputElement': ` + + "This input element does not support Number values.", + "InvalidStateError" + ]); + } + + const allowedValueStep = this._allowedValueStep; + if (allowedValueStep === null) { + throw DOMException.create(this._globalObject, [ + `Failed to invoke '${methodName}' method on 'HTMLInputElement': ` + + "This input element does not support value step.", + "InvalidStateError" + ]); + } + + const min = this._minimum; + const max = this._maximum; + + if (min !== null && max !== null) { + if (min > max) { + return; + } + + const candidateStepValue = this._stepAlign(Decimal.add(min, allowedValueStep), /* roundUp = */ false); + if (candidateStepValue.lt(min) || candidateStepValue.gt(max)) { + return; + } + } + + let value = 0; + try { + value = this.valueAsNumber; + if (isNaN(value)) { // Empty value is parsed as NaN. + value = 0; + } + } catch { + // Step 5. Default value is 0. + } + value = new Decimal(value); + + const valueBeforeStepping = value; + + if (!this._isStepAligned(value)) { + value = this._stepAlign(value, /* roundUp = */ isUp); + } else { + let delta = Decimal.mul(n, allowedValueStep); + if (!isUp) { + delta = delta.neg(); + } + value = value.add(delta); + } + + if (min !== null && value.lt(min)) { + value = this._stepAlign(min, /* roundUp = */ true); + } + + if (max !== null && value.gt(max)) { + value = this._stepAlign(max, /* roundUp = */ false); + } + + if (isUp ? value.lt(valueBeforeStepping) : value.gt(valueBeforeStepping)) { + return; + } + + this._value = this._convertNumberToString(value.toNumber()); + } + + stepDown(n = 1) { + return this._stepUpdate(n, false); + } + + stepUp(n = 1) { + return this._stepUpdate(n, true); + } + + get files() { + if (this.type === "file") { + this[filesSymbol] ||= FileList.createImpl(this._globalObject); + } else { + this[filesSymbol] = null; + } + return this[filesSymbol]; + } + + set files(value) { + if (this.type === "file" && value !== null) { + this[filesSymbol] = value; + } + } + + get type() { + const typeAttribute = this.getAttributeNS(null, "type"); + return getTypeFromAttribute(typeAttribute); + } + + set type(type) { + this.setAttributeNS(null, "type", type); + } + + _dispatchSelectEvent() { + setTimeout(() => fireAnEvent("select", this, undefined, { bubbles: true, cancelable: false }), 0); + } + + _getValueLength() { + return typeof this.value === "string" ? this.value.length : 0; + } + + select() { + if (!this._idlMemberApplies("select")) { + return; + } + + this._selectionStart = 0; + this._selectionEnd = this._getValueLength(); + this._selectionDirection = "none"; + this._dispatchSelectEvent(); + } + + get selectionStart() { + if (!this._idlMemberApplies("selectionStart")) { + return null; + } + + return this._selectionStart; + } + + set selectionStart(start) { + if (!this._idlMemberApplies("selectionStart")) { + throw DOMException.create(this._globalObject, ["The object is in an invalid state.", "InvalidStateError"]); + } + + this.setSelectionRange(start, Math.max(start, this._selectionEnd), this._selectionDirection); + } + + get selectionEnd() { + if (!this._idlMemberApplies("selectionEnd")) { + return null; + } + + return this._selectionEnd; + } + + set selectionEnd(end) { + if (!this._idlMemberApplies("selectionEnd")) { + throw DOMException.create(this._globalObject, ["The object is in an invalid state.", "InvalidStateError"]); + } + + this.setSelectionRange(this._selectionStart, end, this._selectionDirection); + } + + get selectionDirection() { + if (!this._idlMemberApplies("selectionDirection")) { + return null; + } + + return this._selectionDirection; + } + + set selectionDirection(dir) { + if (!this._idlMemberApplies("selectionDirection")) { + throw DOMException.create(this._globalObject, ["The object is in an invalid state.", "InvalidStateError"]); + } + + this.setSelectionRange(this._selectionStart, this._selectionEnd, dir); + } + + setSelectionRange(start, end, dir) { + if (!this._idlMemberApplies("setSelectionRange")) { + throw DOMException.create(this._globalObject, ["The object is in an invalid state.", "InvalidStateError"]); + } + + this._selectionEnd = Math.min(end, this._getValueLength()); + this._selectionStart = Math.min(start, this._selectionEnd); + this._selectionDirection = dir === "forward" || dir === "backward" ? dir : "none"; + this._dispatchSelectEvent(); + } + + setRangeText(repl, start, end, selectionMode = "preserve") { + if (!this._idlMemberApplies("setRangeText")) { + throw DOMException.create(this._globalObject, ["The object is in an invalid state.", "InvalidStateError"]); + } + + if (arguments.length < 2) { + start = this._selectionStart; + end = this._selectionEnd; + } else if (start > end) { + throw DOMException.create(this._globalObject, ["The index is not in the allowed range.", "IndexSizeError"]); + } + + start = Math.min(start, this._getValueLength()); + end = Math.min(end, this._getValueLength()); + + const val = this.value; + let selStart = this._selectionStart; + let selEnd = this._selectionEnd; + + this.value = val.slice(0, start) + repl + val.slice(end); + + const newEnd = start + repl.length; + + if (selectionMode === "select") { + this.setSelectionRange(start, newEnd); + } else if (selectionMode === "start") { + this.setSelectionRange(start, start); + } else if (selectionMode === "end") { + this.setSelectionRange(newEnd, newEnd); + } else { // preserve + const delta = repl.length - (end - start); + + if (selStart > end) { + selStart += delta; + } else if (selStart > start) { + selStart = start; + } + + if (selEnd > end) { + selEnd += delta; + } else if (selEnd > start) { + selEnd = newEnd; + } + + this.setSelectionRange(selStart, selEnd); + } + } + + // https://html.spec.whatwg.org/multipage/input.html#the-list-attribute + get list() { + const id = this._getAttributeIfApplies("list"); + if (!id) { + return null; + } + + const el = this.getRootNode({}).getElementById(id); + + if (el && el.localName === "datalist") { + return el; + } + + return null; + } + + // https://html.spec.whatwg.org/multipage/input.html#the-min-and-max-attributes + get _minimum() { + let min = this._defaultMinimum; + const attr = this._getAttributeIfApplies("min"); + if (attr !== null && this._convertStringToNumber !== undefined) { + const parsed = this._convertStringToNumber(attr); + if (parsed !== null) { + min = parsed; + } + } + return min; + } + + get _maximum() { + let max = this._defaultMaximum; + const attr = this._getAttributeIfApplies("max"); + if (attr !== null && this._convertStringToNumber !== undefined) { + const parsed = this._convertStringToNumber(attr); + if (parsed !== null) { + max = parsed; + } + } + return max; + } + + get _defaultMinimum() { + if (this.type === "range") { + return 0; + } + return null; + } + + get _defaultMaximum() { + if (this.type === "range") { + return 100; + } + return null; + } + + // https://html.spec.whatwg.org/multipage/input.html#concept-input-step + get _allowedValueStep() { + if (!this._contentAttributeApplies("step")) { + return null; + } + const attr = this.getAttributeNS(null, "step"); + if (attr === null) { + return this._defaultStep * this._stepScaleFactor; + } + if (asciiCaseInsensitiveMatch(attr, "any")) { + return null; + } + const parsedStep = parseFloatingPointNumber(attr); + if (parsedStep === null || parsedStep <= 0) { + return this._defaultStep * this._stepScaleFactor; + } + return parsedStep * this._stepScaleFactor; + } + + // https://html.spec.whatwg.org/multipage/input.html#concept-input-step-scale + get _stepScaleFactor() { + const dayInMilliseconds = 24 * 60 * 60 * 1000; + switch (this.type) { + case "week": + return 7 * dayInMilliseconds; + case "date": + return dayInMilliseconds; + case "datetime-local": + case "datetime": + case "time": + return 1000; + } + return 1; + } + + // https://html.spec.whatwg.org/multipage/input.html#concept-input-step-default + get _defaultStep() { + if (this.type === "datetime-local" || this.type === "datetime" || this.type === "time") { + return 60; + } + return 1; + } + + // https://html.spec.whatwg.org/multipage/input.html#concept-input-min-zero + get _stepBase() { + if (this._hasAttributeAndApplies("min")) { + const min = this._convertStringToNumber(this.getAttributeNS(null, "min")); + if (min !== null) { + return min; + } + } + if (this.hasAttributeNS(null, "value")) { + const value = this._convertStringToNumber(this.getAttributeNS(null, "value")); + if (value !== null) { + return value; + } + } + if (this._defaultStepBase !== null) { + return this._defaultStepBase; + } + return 0; + } + + // https://html.spec.whatwg.org/multipage/input.html#concept-input-step-default-base + get _defaultStepBase() { + if (this.type === "week") { + // The start of week 1970-W01 + return -259200000; + } + return null; + } + + // https://html.spec.whatwg.org/multipage/input.html#common-input-element-attributes + // When an attribute doesn't apply to an input element, user agents must ignore the attribute. + _contentAttributeApplies(attribute) { + return applicableTypesForContentAttribute[attribute].has(this.type); + } + + _hasAttributeAndApplies(attribute) { + return this._contentAttributeApplies(attribute) && this.hasAttributeNS(null, attribute); + } + + _getAttributeIfApplies(attribute) { + if (this._contentAttributeApplies(attribute)) { + return this.getAttributeNS(null, attribute); + } + return null; + } + + _idlMemberApplies(member, type = this.type) { + return applicableTypesForIDLMember[member].has(type); + } + + _barredFromConstraintValidationSpecialization() { + // https://html.spec.whatwg.org/multipage/input.html#hidden-state-(type=hidden) + // https://html.spec.whatwg.org/multipage/input.html#reset-button-state-(type=reset) + // https://html.spec.whatwg.org/multipage/input.html#button-state-(type=button) + const willNotValidateTypes = new Set(["hidden", "reset", "button"]); + // https://html.spec.whatwg.org/multipage/input.html#attr-input-readonly + const readOnly = this._hasAttributeAndApplies("readonly"); + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-disabled + return willNotValidateTypes.has(this.type) || readOnly; + } + + // https://html.spec.whatwg.org/multipage/input.html#concept-input-required + get _required() { + return this._hasAttributeAndApplies("required"); + } + + // https://html.spec.whatwg.org/multipage/input.html#has-a-periodic-domain + get _hasAPeriodicDomain() { + return this.type === "time"; + } + + // https://html.spec.whatwg.org/multipage/input.html#has-a-reversed-range + get _hasAReversedRange() { + return this._hasAPeriodicDomain && this._maximum < this._minimum; + } + + get validity() { + if (!this._validity) { + // Constraint validation: When an element has a reversed range, and the result of applying + // the algorithm to convert a string to a number to the string given by the element's value + // is a number, and the number obtained from that algorithm is more than the maximum and less + // than the minimum, the element is simultaneously suffering from an underflow and suffering + // from an overflow. + const reversedRangeSufferingOverUnderflow = () => { + const parsedValue = this._convertStringToNumber(this._value); + return parsedValue !== null && parsedValue > this._maximum && parsedValue < this._minimum; + }; + + const state = { + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-being-missing + valueMissing: () => { + // https://html.spec.whatwg.org/multipage/input.html#the-required-attribute + // Constraint validation: If the element is required, and its value IDL attribute applies + // and is in the mode value, and the element is mutable, and the element's value is the + // empty string, then the element is suffering from being missing. + // + // Note: As of today, the value IDL attribute always applies. + if (this._required && valueAttributeMode(this.type) === "value" && this._mutable && this._value === "") { + return true; + } + + switch (this.type) { + // https://html.spec.whatwg.org/multipage/input.html#checkbox-state-(type=checkbox) + // Constraint validation: If the element is required and its checkedness is + // false, then the element is suffering from being missing. + case "checkbox": + if (this._required && !this._checkedness) { + return true; + } + break; + + // https://html.spec.whatwg.org/multipage/input.html#radio-button-state-(type=radio) + // Constraint validation: If an element in the radio button group is required, + // and all of the input elements in the radio button group have a checkedness + // that is false, then the element is suffering from being missing. + case "radio": + if (this._someInRadioGroup("_required") && !this._someInRadioGroup("checked")) { + return true; + } + break; + + // https://html.spec.whatwg.org/multipage/input.html#file-upload-state-(type=file) + // Constraint validation: If the element is required and the list of selected files is + // empty, then the element is suffering from being missing. + case "file": + if (this._required && this.files.length === 0) { + return true; + } + break; + } + + return false; + }, + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-being-too-long + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-maxlength + // jsdom has no way at the moment to emulate a user interaction, so tooLong/tooShort have + // to be set to false. + tooLong: () => false, + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-being-too-short + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-minlength + tooShort: () => false, + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-an-overflow + rangeOverflow: () => { + // https://html.spec.whatwg.org/multipage/input.html#the-min-and-max-attributes + if (this._hasAReversedRange) { + return reversedRangeSufferingOverUnderflow(); + } + // Constraint validation: When the element has a maximum and does not have a reversed + // range, and the result of applying the algorithm to convert a string to a number to the + // string given by the element's value is a number, and the number obtained from that + // algorithm is more than the maximum, the element is suffering from an overflow. + if (this._maximum !== null) { + const parsedValue = this._convertStringToNumber(this._value); + if (parsedValue !== null && parsedValue > this._maximum) { + return true; + } + } + return false; + }, + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-an-underflow + rangeUnderflow: () => { + // https://html.spec.whatwg.org/multipage/input.html#the-min-and-max-attributes + if (this._hasAReversedRange) { + return reversedRangeSufferingOverUnderflow(); + } + // Constraint validation: When the element has a minimum and does not have a reversed + // range, and the result of applying the algorithm to convert a string to a number to the + // string given by the element's value is a number, and the number obtained from that + // algorithm is less than the minimum, the element is suffering from an underflow. + if (this._minimum !== null) { + const parsedValue = this._convertStringToNumber(this._value); + if (parsedValue !== null && parsedValue < this._minimum) { + return true; + } + } + return false; + }, + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-a-pattern-mismatch + patternMismatch: () => { + // https://html.spec.whatwg.org/multipage/input.html#the-pattern-attribute + if (this._value === "" || !this._hasAttributeAndApplies("pattern")) { + return false; + } + let regExp; + try { + const pattern = this.getAttributeNS(null, "pattern"); + // The pattern attribute should be matched against the entire value, not just any + // subset, so add ^ and $ anchors. But also check the validity of the regex itself + // first. + new RegExp(pattern, "v"); // eslint-disable-line no-new + regExp = new RegExp("^(?:" + pattern + ")$", "v"); + } catch { + return false; + } + if (this._hasAttributeAndApplies("multiple")) { + return !splitOnCommas(this._value).every(value => regExp.test(value)); + } + return !regExp.test(this._value); + }, + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-a-step-mismatch + // https://html.spec.whatwg.org/multipage/input.html#attr-input-step + stepMismatch: () => { + const allowedValueStep = this._allowedValueStep; + if (allowedValueStep === null) { + return false; + } + const number = this._convertStringToNumber(this._value); + return number !== null && !this._isStepAligned(number); + }, + + // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#suffering-from-a-type-mismatch + typeMismatch: () => { + switch (this.type) { + // https://html.spec.whatwg.org/multipage/input.html#url-state-(type=url) + // Constraint validation: While the value of the element is neither the empty string + // nor a valid absolute URL, the element is suffering from a type mismatch. + case "url": + if (this._value !== "" && !isValidAbsoluteURL(this._value)) { + return true; + } + break; + + // https://html.spec.whatwg.org/multipage/input.html#e-mail-state-(type=email) + // Constraint validation [multiple=false]: While the value of the element is neither the empty + // string nor a single valid e - mail address, the element is suffering from a type mismatch. + // Constraint validation [multiple=true]: While the value of the element is not a valid e-mail address list, + // the element is suffering from a type mismatch. + case "email": + if (this._value !== "" && !isValidEmailAddress(this._getValue(), this.hasAttributeNS(null, "multiple"))) { + return true; + } + break; + } + return false; + } + }; + + this._validity = ValidityState.createImpl(this._globalObject, [], { + element: this, + state + }); + } + return this._validity; + } + + [cloningSteps](copy, node) { + copy._value = node._value; + copy._checkedness = node._checkedness; + copy._dirtyValue = node._dirtyValue; + copy._dirtyCheckedness = node._dirtyCheckedness; + } +} + +mixin(HTMLInputElementImpl.prototype, DefaultConstraintValidationImpl.prototype); + +module.exports = { + implementation: HTMLInputElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLLIElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLLIElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..e5925824b2a3ff627d4048c077a14ed786c7c1da --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLLIElement-impl.js @@ -0,0 +1,9 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; + +class HTMLLIElementImpl extends HTMLElementImpl { } + +module.exports = { + implementation: HTMLLIElementImpl +}; diff --git a/node_modules/jsdom/lib/jsdom/living/nodes/HTMLLabelElement-impl.js b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLLabelElement-impl.js new file mode 100644 index 0000000000000000000000000000000000000000..ba6bcb44194d190c71f96238b0a02306765a6787 --- /dev/null +++ b/node_modules/jsdom/lib/jsdom/living/nodes/HTMLLabelElement-impl.js @@ -0,0 +1,94 @@ +"use strict"; + +const HTMLElementImpl = require("./HTMLElement-impl").implementation; +const MouseEvent = require("../generated/MouseEvent"); +const { domSymbolTree } = require("../helpers/internal-constants"); +const NODE_TYPE = require("../node-type"); +const { isLabelable, isDisabled, isInteractiveContent } = require("../helpers/form-controls"); +const { isInclusiveAncestor } = require("../helpers/node"); +const { fireAnEvent } = require("../helpers/events"); + +function sendClickToAssociatedNode(node) { + fireAnEvent("click", node, MouseEvent, { + bubbles: true, + cancelable: true, + view: node.ownerDocument ? node.ownerDocument.defaultView : null, + screenX: 0, + screenY: 0, + clientX: 0, + clientY: 0, + button: 0, + detail: 1, + relatedTarget: null + }); +} + +class HTMLLabelElementImpl extends HTMLElementImpl { + constructor(globalObject, args, privateData) { + super(globalObject, args, privateData); + + this._hasActivationBehavior = true; + } + + get control() { + if (this.hasAttributeNS(null, "for")) { + const forValue = this.getAttributeNS(null, "for"); + if (forValue === "") { + return null; + } + const root = this.getRootNode({}); + for (const descendant of domSymbolTree.treeIterator(root)) { + if (descendant.nodeType === NODE_TYPE.ELEMENT_NODE && + descendant.getAttributeNS(null, "id") === forValue) { + return isLabelable(descendant) ? descendant : null; + } + } + return null; + } + for (const descendant of domSymbolTree.treeIterator(this)) { + if (isLabelable(descendant)) { + return descendant; + } + } + return null; + } + + get form() { + const node = this.control; + if (node) { + return node.form; + } + return null; + } + + _activationBehavior(event) { + // Check if the event's target is an inclusive descendant of any interactive content descendant of this