diff options
author | Minteck <contact@minteck.org> | 2022-10-18 08:59:09 +0200 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-10-18 08:59:09 +0200 |
commit | 2c4ae43e688a9873e86211ea0e7aeb9ba770dd77 (patch) | |
tree | 17848d95522dab25d3cdeb9c4a6450e2a234861f /alarm/node_modules/jsdom/lib/jsdom/living/events | |
parent | 108525534c28013cfe1897c30e4565f9893f3766 (diff) | |
download | pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.tar.gz pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.tar.bz2 pluralconnect-2c4ae43e688a9873e86211ea0e7aeb9ba770dd77.zip |
Update
Diffstat (limited to 'alarm/node_modules/jsdom/lib/jsdom/living/events')
20 files changed, 974 insertions, 0 deletions
diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/CloseEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/CloseEvent-impl.js new file mode 100644 index 0000000..83972df --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/CloseEvent-impl.js @@ -0,0 +1,10 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const CloseEventInit = require("../generated/CloseEventInit"); + +class CloseEventImpl extends EventImpl {} +CloseEventImpl.defaultInit = CloseEventInit.convert(undefined); + +exports.implementation = CloseEventImpl; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/CompositionEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/CompositionEvent-impl.js new file mode 100644 index 0000000..4932a61 --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/CompositionEvent-impl.js @@ -0,0 +1,20 @@ +"use strict"; + +const UIEventImpl = require("./UIEvent-impl").implementation; +const CompositionEventInit = require("../generated/CompositionEventInit"); + +class CompositionEventImpl extends UIEventImpl { + initCompositionEvent(type, bubbles, cancelable, view, data) { + if (this._dispatchFlag) { + return; + } + + this.initUIEvent(type, bubbles, cancelable, view, 0); + this.data = data; + } +} +CompositionEventImpl.defaultInit = CompositionEventInit.convert(undefined); + +module.exports = { + implementation: CompositionEventImpl +}; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/CustomEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/CustomEvent-impl.js new file mode 100644 index 0000000..5601249 --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/CustomEvent-impl.js @@ -0,0 +1,21 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const CustomEventInit = require("../generated/CustomEventInit"); + +class CustomEventImpl extends EventImpl { + initCustomEvent(type, bubbles, cancelable, detail) { + if (this._dispatchFlag) { + return; + } + + this.initEvent(type, bubbles, cancelable); + this.detail = detail; + } +} +CustomEventImpl.defaultInit = CustomEventInit.convert(undefined); + +module.exports = { + implementation: CustomEventImpl +}; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/ErrorEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/ErrorEvent-impl.js new file mode 100644 index 0000000..518551b --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/ErrorEvent-impl.js @@ -0,0 +1,14 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const ErrorEventInit = require("../generated/ErrorEventInit"); + +class ErrorEventImpl extends EventImpl { + +} +ErrorEventImpl.defaultInit = ErrorEventInit.convert(undefined); + +module.exports = { + implementation: ErrorEventImpl +}; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/Event-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/Event-impl.js new file mode 100644 index 0000000..787a66b --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/Event-impl.js @@ -0,0 +1,197 @@ +"use strict"; + +const idlUtils = require("../generated/utils"); +const EventInit = require("../generated/EventInit"); + +class EventImpl { + constructor(globalObject, args, privateData) { + const [type, eventInitDict = this.constructor.defaultInit] = args; + + this.type = type; + + this.bubbles = false; + this.cancelable = false; + for (const key in eventInitDict) { + if (key in this.constructor.defaultInit) { + this[key] = eventInitDict[key]; + } + } + for (const key in this.constructor.defaultInit) { + if (!(key in this)) { + this[key] = this.constructor.defaultInit[key]; + } + } + + this.target = null; + this.currentTarget = null; + this.eventPhase = 0; + + this._globalObject = globalObject; + this._initializedFlag = true; + this._stopPropagationFlag = false; + this._stopImmediatePropagationFlag = false; + this._canceledFlag = false; + this._inPassiveListenerFlag = false; + this._dispatchFlag = false; + this._path = []; + + this.isTrusted = privateData.isTrusted || false; + this.timeStamp = Date.now(); + } + + // https://dom.spec.whatwg.org/#set-the-canceled-flag + _setTheCanceledFlag() { + if (this.cancelable && !this._inPassiveListenerFlag) { + this._canceledFlag = true; + } + } + + get srcElement() { + return this.target; + } + + get returnValue() { + return !this._canceledFlag; + } + + set returnValue(v) { + if (v === false) { + this._setTheCanceledFlag(); + } + } + + get defaultPrevented() { + return this._canceledFlag; + } + + stopPropagation() { + this._stopPropagationFlag = true; + } + + get cancelBubble() { + return this._stopPropagationFlag; + } + + set cancelBubble(v) { + if (v) { + this._stopPropagationFlag = true; + } + } + + stopImmediatePropagation() { + this._stopPropagationFlag = true; + this._stopImmediatePropagationFlag = true; + } + + preventDefault() { + this._setTheCanceledFlag(); + } + + // https://dom.spec.whatwg.org/#dom-event-composedpath + // Current implementation is based of https://whatpr.org/dom/699.html#dom-event-composedpath + // due to a bug in composed path implementation https://github.com/whatwg/dom/issues/684 + composedPath() { + const composedPath = []; + + const { currentTarget, _path: path } = this; + + if (path.length === 0) { + return composedPath; + } + + composedPath.push(currentTarget); + + let currentTargetIndex = 0; + let currentTargetHiddenSubtreeLevel = 0; + + for (let index = path.length - 1; index >= 0; index--) { + const { item, rootOfClosedTree, slotInClosedTree } = path[index]; + + if (rootOfClosedTree) { + currentTargetHiddenSubtreeLevel++; + } + + if (item === idlUtils.implForWrapper(currentTarget)) { + currentTargetIndex = index; + break; + } + + if (slotInClosedTree) { + currentTargetHiddenSubtreeLevel--; + } + } + + let currentHiddenLevel = currentTargetHiddenSubtreeLevel; + let maxHiddenLevel = currentTargetHiddenSubtreeLevel; + + for (let i = currentTargetIndex - 1; i >= 0; i--) { + const { item, rootOfClosedTree, slotInClosedTree } = path[i]; + + if (rootOfClosedTree) { + currentHiddenLevel++; + } + + if (currentHiddenLevel <= maxHiddenLevel) { + composedPath.unshift(idlUtils.wrapperForImpl(item)); + } + + if (slotInClosedTree) { + currentHiddenLevel--; + if (currentHiddenLevel < maxHiddenLevel) { + maxHiddenLevel = currentHiddenLevel; + } + } + } + + currentHiddenLevel = currentTargetHiddenSubtreeLevel; + maxHiddenLevel = currentTargetHiddenSubtreeLevel; + + for (let index = currentTargetIndex + 1; index < path.length; index++) { + const { item, rootOfClosedTree, slotInClosedTree } = path[index]; + + if (slotInClosedTree) { + currentHiddenLevel++; + } + + if (currentHiddenLevel <= maxHiddenLevel) { + composedPath.push(idlUtils.wrapperForImpl(item)); + } + + if (rootOfClosedTree) { + currentHiddenLevel--; + if (currentHiddenLevel < maxHiddenLevel) { + maxHiddenLevel = currentHiddenLevel; + } + } + } + + return composedPath; + } + + _initialize(type, bubbles, cancelable) { + this.type = type; + this._initializedFlag = true; + + this._stopPropagationFlag = false; + this._stopImmediatePropagationFlag = false; + this._canceledFlag = false; + + this.isTrusted = false; + this.target = null; + this.bubbles = bubbles; + this.cancelable = cancelable; + } + + initEvent(type, bubbles, cancelable) { + if (this._dispatchFlag) { + return; + } + + this._initialize(type, bubbles, cancelable); + } +} +EventImpl.defaultInit = EventInit.convert(undefined); + +module.exports = { + implementation: EventImpl +}; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/EventModifierMixin-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/EventModifierMixin-impl.js new file mode 100644 index 0000000..4603eb9 --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/EventModifierMixin-impl.js @@ -0,0 +1,18 @@ +"use strict"; + +// This mixin doesn't have an IDL equivalent, but since MouseEvent and KeyboardEvent implement getModifierState() the +// same way, its implementation is shared here. + +class EventModifierMixinImpl { + // Event's constructor assumes all options correspond to IDL attributes with the same names, and sets them on `this`. + // That is not the case for these modifier boolean options, but since the options are set on `this` anyway we'll + // access them that way. The spec doesn't say much about the case where keyArg is not one of the valid ones + // (https://w3c.github.io/uievents-key/#keys-modifier), but at least Chrome returns false for invalid modifiers. Since + // these invalid modifiers will be undefined on `this` (thus `false` after casting it to boolean), we don't need to do + // extra checking for validity. + getModifierState(keyArg) { + return Boolean(this[`modifier${keyArg}`]); + } +} + +exports.implementation = EventModifierMixinImpl; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js new file mode 100644 index 0000000..15152fd --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js @@ -0,0 +1,403 @@ +"use strict"; +const DOMException = require("domexception/webidl2js-wrapper"); + +const reportException = require("../helpers/runtime-script-errors"); +const idlUtils = require("../generated/utils"); +const { nodeRoot } = require("../helpers/node"); +const { + isNode, isShadowRoot, isSlotable, getEventTargetParent, + isShadowInclusiveAncestor, retarget +} = require("../helpers/shadow-dom"); + +const MouseEvent = require("../generated/MouseEvent"); + +const EVENT_PHASE = { + NONE: 0, + CAPTURING_PHASE: 1, + AT_TARGET: 2, + BUBBLING_PHASE: 3 +}; + +class EventTargetImpl { + constructor(globalObject) { + this._globalObject = globalObject; + this._eventListeners = Object.create(null); + } + + addEventListener(type, callback, options) { + options = normalizeEventHandlerOptions(options, ["capture", "once", "passive"]); + + if (callback === null) { + return; + } + + if (!this._eventListeners[type]) { + this._eventListeners[type] = []; + } + + for (let i = 0; i < this._eventListeners[type].length; ++i) { + const listener = this._eventListeners[type][i]; + if ( + listener.callback.objectReference === callback.objectReference && + listener.options.capture === options.capture + ) { + return; + } + } + + this._eventListeners[type].push({ + callback, + options + }); + } + + removeEventListener(type, callback, options) { + options = normalizeEventHandlerOptions(options, ["capture"]); + + if (callback === null) { + // Optimization, not in the spec. + return; + } + + if (!this._eventListeners[type]) { + return; + } + + for (let i = 0; i < this._eventListeners[type].length; ++i) { + const listener = this._eventListeners[type][i]; + if ( + listener.callback.objectReference === callback.objectReference && + listener.options.capture === options.capture + ) { + this._eventListeners[type].splice(i, 1); + break; + } + } + } + + dispatchEvent(eventImpl) { + if (eventImpl._dispatchFlag || !eventImpl._initializedFlag) { + throw DOMException.create(this._globalObject, [ + "Tried to dispatch an uninitialized event", + "InvalidStateError" + ]); + } + if (eventImpl.eventPhase !== EVENT_PHASE.NONE) { + throw DOMException.create(this._globalObject, [ + "Tried to dispatch a dispatching event", + "InvalidStateError" + ]); + } + + eventImpl.isTrusted = false; + + return this._dispatch(eventImpl); + } + + // https://dom.spec.whatwg.org/#get-the-parent + _getTheParent() { + return null; + } + + // https://dom.spec.whatwg.org/#concept-event-dispatch + // legacyOutputDidListenersThrowFlag optional parameter is not necessary here since it is only used by indexDB. + _dispatch(eventImpl, targetOverride /* , legacyOutputDidListenersThrowFlag */) { + let targetImpl = this; + let clearTargets = false; + let activationTarget = null; + + eventImpl._dispatchFlag = true; + + targetOverride = targetOverride || targetImpl; + let relatedTarget = retarget(eventImpl.relatedTarget, targetImpl); + + if (targetImpl !== relatedTarget || targetImpl === eventImpl.relatedTarget) { + const touchTargets = []; + + appendToEventPath(eventImpl, targetImpl, targetOverride, relatedTarget, touchTargets, false); + + const isActivationEvent = MouseEvent.isImpl(eventImpl) && eventImpl.type === "click"; + + if (isActivationEvent && targetImpl._hasActivationBehavior) { + activationTarget = targetImpl; + } + + let slotInClosedTree = false; + let slotable = isSlotable(targetImpl) && targetImpl._assignedSlot ? targetImpl : null; + let parent = getEventTargetParent(targetImpl, eventImpl); + + // Populate event path + // https://dom.spec.whatwg.org/#event-path + while (parent !== null) { + if (slotable !== null) { + if (parent.localName !== "slot") { + throw new Error(`JSDOM Internal Error: Expected parent to be a Slot`); + } + + slotable = null; + + const parentRoot = nodeRoot(parent); + if (isShadowRoot(parentRoot) && parentRoot.mode === "closed") { + slotInClosedTree = true; + } + } + + if (isSlotable(parent) && parent._assignedSlot) { + slotable = parent; + } + + relatedTarget = retarget(eventImpl.relatedTarget, parent); + + if ( + (isNode(parent) && isShadowInclusiveAncestor(nodeRoot(targetImpl), parent)) || + idlUtils.wrapperForImpl(parent).constructor.name === "Window" + ) { + if (isActivationEvent && eventImpl.bubbles && activationTarget === null && + parent._hasActivationBehavior) { + activationTarget = parent; + } + + appendToEventPath(eventImpl, parent, null, relatedTarget, touchTargets, slotInClosedTree); + } else if (parent === relatedTarget) { + parent = null; + } else { + targetImpl = parent; + + if (isActivationEvent && activationTarget === null && targetImpl._hasActivationBehavior) { + activationTarget = targetImpl; + } + + appendToEventPath(eventImpl, parent, targetImpl, relatedTarget, touchTargets, slotInClosedTree); + } + + if (parent !== null) { + parent = getEventTargetParent(parent, eventImpl); + } + + slotInClosedTree = false; + } + + let clearTargetsStructIndex = -1; + for (let i = eventImpl._path.length - 1; i >= 0 && clearTargetsStructIndex === -1; i--) { + if (eventImpl._path[i].target !== null) { + clearTargetsStructIndex = i; + } + } + const clearTargetsStruct = eventImpl._path[clearTargetsStructIndex]; + + clearTargets = + (isNode(clearTargetsStruct.target) && isShadowRoot(nodeRoot(clearTargetsStruct.target))) || + (isNode(clearTargetsStruct.relatedTarget) && isShadowRoot(nodeRoot(clearTargetsStruct.relatedTarget))); + + if (activationTarget !== null && activationTarget._legacyPreActivationBehavior) { + activationTarget._legacyPreActivationBehavior(); + } + + for (let i = eventImpl._path.length - 1; i >= 0; --i) { + const struct = eventImpl._path[i]; + + if (struct.target !== null) { + eventImpl.eventPhase = EVENT_PHASE.AT_TARGET; + } else { + eventImpl.eventPhase = EVENT_PHASE.CAPTURING_PHASE; + } + + invokeEventListeners(struct, eventImpl, "capturing"); + } + + for (let i = 0; i < eventImpl._path.length; i++) { + const struct = eventImpl._path[i]; + + if (struct.target !== null) { + eventImpl.eventPhase = EVENT_PHASE.AT_TARGET; + } else { + if (!eventImpl.bubbles) { + continue; + } + + eventImpl.eventPhase = EVENT_PHASE.BUBBLING_PHASE; + } + + invokeEventListeners(struct, eventImpl, "bubbling"); + } + } + + eventImpl.eventPhase = EVENT_PHASE.NONE; + + eventImpl.currentTarget = null; + eventImpl._path = []; + eventImpl._dispatchFlag = false; + eventImpl._stopPropagationFlag = false; + eventImpl._stopImmediatePropagationFlag = false; + + if (clearTargets) { + eventImpl.target = null; + eventImpl.relatedTarget = null; + } + + if (activationTarget !== null) { + if (!eventImpl._canceledFlag) { + activationTarget._activationBehavior(eventImpl); + } else if (activationTarget._legacyCanceledActivationBehavior) { + activationTarget._legacyCanceledActivationBehavior(); + } + } + + return !eventImpl._canceledFlag; + } +} + +module.exports = { + implementation: EventTargetImpl +}; + +// https://dom.spec.whatwg.org/#concept-event-listener-invoke +function invokeEventListeners(struct, eventImpl, phase) { + const structIndex = eventImpl._path.indexOf(struct); + for (let i = structIndex; i >= 0; i--) { + const t = eventImpl._path[i]; + if (t.target) { + eventImpl.target = t.target; + break; + } + } + + eventImpl.relatedTarget = idlUtils.wrapperForImpl(struct.relatedTarget); + + if (eventImpl._stopPropagationFlag) { + return; + } + + eventImpl.currentTarget = idlUtils.wrapperForImpl(struct.item); + + const listeners = struct.item._eventListeners; + innerInvokeEventListeners(eventImpl, listeners, phase, struct.itemInShadowTree); +} + +// https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke +function innerInvokeEventListeners(eventImpl, listeners, phase, itemInShadowTree) { + let found = false; + + const { type, target } = eventImpl; + const wrapper = idlUtils.wrapperForImpl(target); + + if (!listeners || !listeners[type]) { + return found; + } + + // Copy event listeners before iterating since the list can be modified during the iteration. + const handlers = listeners[type].slice(); + + for (let i = 0; i < handlers.length; i++) { + const listener = handlers[i]; + const { capture, once, passive } = listener.options; + + // Check if the event listener has been removed since the listeners has been cloned. + if (!listeners[type].includes(listener)) { + continue; + } + + found = true; + + if ( + (phase === "capturing" && !capture) || + (phase === "bubbling" && capture) + ) { + continue; + } + + if (once) { + listeners[type].splice(listeners[type].indexOf(listener), 1); + } + + let window = null; + if (wrapper && wrapper._document) { + // Triggered by Window + window = wrapper; + } else if (target._ownerDocument) { + // Triggered by most webidl2js'ed instances + window = target._ownerDocument._defaultView; + } else if (wrapper._ownerDocument) { + // Currently triggered by some non-webidl2js things + window = wrapper._ownerDocument._defaultView; + } + + let currentEvent; + if (window) { + currentEvent = window._currentEvent; + if (!itemInShadowTree) { + window._currentEvent = eventImpl; + } + } + + if (passive) { + eventImpl._inPassiveListenerFlag = true; + } + + try { + listener.callback.call(eventImpl.currentTarget, eventImpl); + } catch (e) { + if (window) { + reportException(window, e); + } + // Errors in window-less documents just get swallowed... can you think of anything better? + } + + eventImpl._inPassiveListenerFlag = false; + + if (window) { + window._currentEvent = currentEvent; + } + + if (eventImpl._stopImmediatePropagationFlag) { + return found; + } + } + + return found; +} + +/** + * Normalize the event listeners options argument in order to get always a valid options object + * @param {Object} options - user defined options + * @param {Array} defaultBoolKeys - boolean properties that should belong to the options object + * @returns {Object} object containing at least the "defaultBoolKeys" + */ +function normalizeEventHandlerOptions(options, defaultBoolKeys) { + const returnValue = {}; + + // no need to go further here + if (typeof options === "boolean" || options === null || typeof options === "undefined") { + returnValue.capture = Boolean(options); + return returnValue; + } + + // non objects options so we typecast its value as "capture" value + if (typeof options !== "object") { + returnValue.capture = Boolean(options); + // at this point we don't need to loop the "capture" key anymore + defaultBoolKeys = defaultBoolKeys.filter(k => k !== "capture"); + } + + for (const key of defaultBoolKeys) { + returnValue[key] = Boolean(options[key]); + } + + return returnValue; +} + +// https://dom.spec.whatwg.org/#concept-event-path-append +function appendToEventPath(eventImpl, target, targetOverride, relatedTarget, touchTargets, slotInClosedTree) { + const itemInShadowTree = isNode(target) && isShadowRoot(nodeRoot(target)); + const rootOfClosedTree = isShadowRoot(target) && target.mode === "closed"; + + eventImpl._path.push({ + item: target, + itemInShadowTree, + target: targetOverride, + relatedTarget, + touchTargets, + rootOfClosedTree, + slotInClosedTree + }); +} diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/FocusEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/FocusEvent-impl.js new file mode 100644 index 0000000..ec8d86d --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/FocusEvent-impl.js @@ -0,0 +1,9 @@ +"use strict"; +const UIEventImpl = require("./UIEvent-impl").implementation; + +const FocusEventInit = require("../generated/FocusEventInit"); + +class FocusEventImpl extends UIEventImpl {} +FocusEventImpl.defaultInit = FocusEventInit.convert(undefined); + +exports.implementation = FocusEventImpl; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/HashChangeEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/HashChangeEvent-impl.js new file mode 100644 index 0000000..711de8e --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/HashChangeEvent-impl.js @@ -0,0 +1,14 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const HashChangeEventInit = require("../generated/HashChangeEventInit"); + +class HashChangeEventImpl extends EventImpl { + +} +HashChangeEventImpl.defaultInit = HashChangeEventInit.convert(undefined); + +module.exports = { + implementation: HashChangeEventImpl +}; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/InputEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/InputEvent-impl.js new file mode 100644 index 0000000..6f6dd48 --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/InputEvent-impl.js @@ -0,0 +1,11 @@ +"use strict"; +const UIEventImpl = require("./UIEvent-impl").implementation; +const InputEventInit = require("../generated/InputEventInit"); + +// https://w3c.github.io/uievents/#interface-inputevent +class InputEventImpl extends UIEventImpl { } +InputEventImpl.defaultInit = InputEventInit.convert(undefined); + +module.exports = { + implementation: InputEventImpl +}; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/KeyboardEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/KeyboardEvent-impl.js new file mode 100644 index 0000000..e711f4d --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/KeyboardEvent-impl.js @@ -0,0 +1,29 @@ +"use strict"; + +const { mixin } = require("../../utils"); +const EventModifierMixinImpl = require("./EventModifierMixin-impl").implementation; +const UIEventImpl = require("./UIEvent-impl").implementation; + +const KeyboardEventInit = require("../generated/KeyboardEventInit"); + +class KeyboardEventImpl extends UIEventImpl { + initKeyboardEvent(type, bubbles, cancelable, view, key, location, ctrlKey, altKey, shiftKey, metaKey) { + if (this._dispatchFlag) { + return; + } + + this.initUIEvent(type, bubbles, cancelable, view, 0); + this.key = key; + this.location = location; + this.ctrlKey = ctrlKey; + this.altKey = altKey; + this.shiftKey = shiftKey; + this.metaKey = metaKey; + } +} +mixin(KeyboardEventImpl.prototype, EventModifierMixinImpl.prototype); +KeyboardEventImpl.defaultInit = KeyboardEventInit.convert(undefined); + +module.exports = { + implementation: KeyboardEventImpl +}; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/MessageEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/MessageEvent-impl.js new file mode 100644 index 0000000..eb58e56 --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/MessageEvent-impl.js @@ -0,0 +1,25 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const MessageEventInit = require("../generated/MessageEventInit"); + +class MessageEventImpl extends EventImpl { + initMessageEvent(type, bubbles, cancelable, data, origin, lastEventId, source, ports) { + if (this._dispatchFlag) { + return; + } + + this.initEvent(type, bubbles, cancelable); + this.data = data; + this.origin = origin; + this.lastEventId = lastEventId; + this.source = source; + this.ports = ports; + } +} +MessageEventImpl.defaultInit = MessageEventInit.convert(undefined); + +module.exports = { + implementation: MessageEventImpl +}; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/MouseEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/MouseEvent-impl.js new file mode 100644 index 0000000..28ff082 --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/MouseEvent-impl.js @@ -0,0 +1,49 @@ +"use strict"; + +const { mixin } = require("../../utils"); +const EventModifierMixinImpl = require("./EventModifierMixin-impl").implementation; +const UIEventImpl = require("./UIEvent-impl").implementation; + +const MouseEventInit = require("../generated/MouseEventInit"); + +class MouseEventImpl extends UIEventImpl { + initMouseEvent( + type, + bubbles, + cancelable, + view, + detail, + screenX, + screenY, + clientX, + clientY, + ctrlKey, + altKey, + shiftKey, + metaKey, + button, + relatedTarget + ) { + if (this._dispatchFlag) { + return; + } + + this.initUIEvent(type, bubbles, cancelable, view, detail); + this.screenX = screenX; + this.screenY = screenY; + this.clientX = clientX; + this.clientY = clientY; + this.ctrlKey = ctrlKey; + this.altKey = altKey; + this.shiftKey = shiftKey; + this.metaKey = metaKey; + this.button = button; + this.relatedTarget = relatedTarget; + } +} +mixin(MouseEventImpl.prototype, EventModifierMixinImpl.prototype); +MouseEventImpl.defaultInit = MouseEventInit.convert(undefined); + +module.exports = { + implementation: MouseEventImpl +}; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/PageTransitionEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/PageTransitionEvent-impl.js new file mode 100644 index 0000000..ae97b36 --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/PageTransitionEvent-impl.js @@ -0,0 +1,20 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const PageTransitionEventInit = require("../generated/PageTransitionEventInit"); + +// https://html.spec.whatwg.org/multipage/browsing-the-web.html#pagetransitionevent +class PageTransitionEventImpl extends EventImpl { + initPageTransitionEvent(type, bubbles, cancelable, persisted) { + if (this._dispatchFlag) { + return; + } + + this.initEvent(type, bubbles, cancelable); + this.persisted = persisted; + } +} +PageTransitionEventImpl.defaultInit = PageTransitionEventInit.convert(undefined); + +exports.implementation = PageTransitionEventImpl; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/PopStateEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/PopStateEvent-impl.js new file mode 100644 index 0000000..9c152fb --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/PopStateEvent-impl.js @@ -0,0 +1,9 @@ +"use strict"; +const EventImpl = require("./Event-impl.js").implementation; + +const PopStateEventInit = require("../generated/PopStateEventInit"); + +class PopStateEventImpl extends EventImpl {} +PopStateEventImpl.defaultInit = PopStateEventInit.convert(undefined); + +exports.implementation = PopStateEventImpl; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/ProgressEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/ProgressEvent-impl.js new file mode 100644 index 0000000..030a9ae --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/ProgressEvent-impl.js @@ -0,0 +1,14 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const ProgressEventInit = require("../generated/ProgressEventInit"); + +class ProgressEventImpl extends EventImpl { + +} +ProgressEventImpl.defaultInit = ProgressEventInit.convert(undefined); + +module.exports = { + implementation: ProgressEventImpl +}; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/StorageEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/StorageEvent-impl.js new file mode 100644 index 0000000..566d0a2 --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/StorageEvent-impl.js @@ -0,0 +1,26 @@ +"use strict"; + +const EventImpl = require("./Event-impl").implementation; + +const StorageEventInit = require("../generated/StorageEventInit"); + +// https://html.spec.whatwg.org/multipage/webstorage.html#the-storageevent-interface +class StorageEventImpl extends EventImpl { + initStorageEvent(type, bubbles, cancelable, key, oldValue, newValue, url, storageArea) { + if (this._dispatchFlag) { + return; + } + + this.initEvent(type, bubbles, cancelable); + this.key = key; + this.oldValue = oldValue; + this.newValue = newValue; + this.url = url; + this.storageArea = storageArea; + } +} +StorageEventImpl.defaultInit = StorageEventInit.convert(undefined); + +module.exports = { + implementation: StorageEventImpl +}; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/TouchEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/TouchEvent-impl.js new file mode 100644 index 0000000..33635ff --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/TouchEvent-impl.js @@ -0,0 +1,14 @@ +"use strict"; + +const UIEventImpl = require("./UIEvent-impl").implementation; + +const TouchEventInit = require("../generated/TouchEventInit"); + +class TouchEventImpl extends UIEventImpl { + +} +TouchEventImpl.defaultInit = TouchEventInit.convert(undefined); + +module.exports = { + implementation: TouchEventImpl +}; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/UIEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/UIEvent-impl.js new file mode 100644 index 0000000..a5ef713 --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/UIEvent-impl.js @@ -0,0 +1,59 @@ +"use strict"; + +const idlUtils = require("../generated/utils"); +const UIEventInit = require("../generated/UIEventInit"); +const EventImpl = require("./Event-impl").implementation; + +// Until webidl2js gains support for checking for Window, this would have to do. +function isWindow(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 isWindow(idlUtils.implForWrapper(val)); +} + +class UIEventImpl extends EventImpl { + constructor(globalObject, args, privateData) { + const eventInitDict = args[1]; + + // undefined check included so that we can omit the property in internal usage. + if (eventInitDict && eventInitDict.view !== null && eventInitDict.view !== undefined) { + if (!isWindow(eventInitDict.view)) { + throw new TypeError(`Failed to construct '${new.target.name.replace(/Impl$/, "")}': member view is not of ` + + "type Window."); + } + } + + super(globalObject, args, privateData); + } + + initUIEvent(type, bubbles, cancelable, view, detail) { + if (view !== null) { + if (!isWindow(view)) { + throw new TypeError(`Failed to execute 'initUIEvent' on '${this.constructor.name.replace(/Impl$/, "")}': ` + + "parameter 4 is not of type 'Window'."); + } + } + + if (this._dispatchFlag) { + return; + } + + this.initEvent(type, bubbles, cancelable); + this.view = view; + this.detail = detail; + } +} +UIEventImpl.defaultInit = UIEventInit.convert(undefined); + +module.exports = { + implementation: UIEventImpl +}; diff --git a/alarm/node_modules/jsdom/lib/jsdom/living/events/WheelEvent-impl.js b/alarm/node_modules/jsdom/lib/jsdom/living/events/WheelEvent-impl.js new file mode 100644 index 0000000..82f0cbb --- /dev/null +++ b/alarm/node_modules/jsdom/lib/jsdom/living/events/WheelEvent-impl.js @@ -0,0 +1,12 @@ +"use strict"; + +const MouseEventImpl = require("./MouseEvent-impl").implementation; + +const WheelEventInit = require("../generated/WheelEventInit"); + +class WheelEventImpl extends MouseEventImpl {} +WheelEventImpl.defaultInit = WheelEventInit.convert(undefined); + +module.exports = { + implementation: WheelEventImpl +}; |