mirror of
https://github.com/actions/setup-python.git
synced 2026-09-20 10:31:28 +00:00
Initial pass
This commit is contained in:
+10
@@ -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;
|
||||
+20
@@ -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
|
||||
};
|
||||
+21
@@ -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
|
||||
};
|
||||
+14
@@ -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
|
||||
};
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
"use strict";
|
||||
|
||||
const EventInit = require("../generated/EventInit");
|
||||
|
||||
class EventImpl {
|
||||
constructor(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._initializedFlag = true;
|
||||
this._stopPropagationFlag = false;
|
||||
this._stopImmediatePropagationFlag = false;
|
||||
this._canceledFlag = false;
|
||||
this._dispatchFlag = false;
|
||||
|
||||
this.isTrusted = privateData.isTrusted || false;
|
||||
this.timeStamp = Date.now();
|
||||
}
|
||||
|
||||
get srcElement() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
get returnValue() {
|
||||
return !this._canceledFlag;
|
||||
}
|
||||
|
||||
set returnValue(v) {
|
||||
if (this.cancelable && v === false) {
|
||||
this._canceledFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
if (this.cancelable) {
|
||||
this._canceledFlag = true;
|
||||
}
|
||||
}
|
||||
|
||||
_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
|
||||
};
|
||||
+18
@@ -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;
|
||||
+243
@@ -0,0 +1,243 @@
|
||||
"use strict";
|
||||
const DOMException = require("domexception");
|
||||
const reportException = require("../helpers/runtime-script-errors");
|
||||
const { domSymbolTree } = require("../helpers/internal-constants");
|
||||
const idlUtils = require("../generated/utils");
|
||||
|
||||
const Event = require("../generated/Event").interface;
|
||||
|
||||
class EventTargetImpl {
|
||||
constructor() {
|
||||
this._eventListeners = Object.create(null);
|
||||
}
|
||||
|
||||
addEventListener(type, callback, options) {
|
||||
// webidl2js currently can't handle neither optional arguments nor callback interfaces
|
||||
if (callback === undefined || callback === null) {
|
||||
callback = null;
|
||||
} else if (typeof callback !== "object" && typeof callback !== "function") {
|
||||
throw new TypeError("Only undefined, null, an object, or a function are allowed for the callback parameter");
|
||||
}
|
||||
|
||||
options = normalizeEventHandlerOptions(options, ["capture", "once"]);
|
||||
|
||||
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.options.capture === options.capture && listener.callback === callback) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this._eventListeners[type].push({
|
||||
callback,
|
||||
options
|
||||
});
|
||||
}
|
||||
|
||||
removeEventListener(type, callback, options) {
|
||||
if (callback === undefined || callback === null) {
|
||||
callback = null;
|
||||
} else if (typeof callback !== "object" && typeof callback !== "function") {
|
||||
throw new TypeError("Only undefined, null, an object, or a function are allowed for the callback parameter");
|
||||
}
|
||||
|
||||
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 === callback && listener.options.capture === options.capture) {
|
||||
this._eventListeners[type].splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dispatchEvent(eventImpl) {
|
||||
if (eventImpl._dispatchFlag || !eventImpl._initializedFlag) {
|
||||
throw new DOMException("Tried to dispatch an uninitialized event", "InvalidStateError");
|
||||
}
|
||||
if (eventImpl.eventPhase !== Event.NONE) {
|
||||
throw new DOMException("Tried to dispatch a dispatching event", "InvalidStateError");
|
||||
}
|
||||
|
||||
eventImpl.isTrusted = false;
|
||||
|
||||
return this._dispatch(eventImpl);
|
||||
}
|
||||
|
||||
_dispatch(eventImpl, targetOverride) {
|
||||
eventImpl._dispatchFlag = true;
|
||||
eventImpl.target = targetOverride || this;
|
||||
|
||||
const eventPath = [];
|
||||
let { target } = eventImpl;
|
||||
let targetParent = domSymbolTree.parent(target);
|
||||
while (targetParent) {
|
||||
eventPath.push(targetParent);
|
||||
target = targetParent;
|
||||
targetParent = domSymbolTree.parent(targetParent);
|
||||
}
|
||||
if (eventImpl.type !== "load" && target._defaultView) {
|
||||
// https://html.spec.whatwg.org/#events-and-the-window-object
|
||||
eventPath.push(idlUtils.implForWrapper(target._defaultView));
|
||||
}
|
||||
|
||||
eventImpl.eventPhase = Event.CAPTURING_PHASE;
|
||||
for (let i = eventPath.length - 1; i >= 0; --i) {
|
||||
if (eventImpl._stopPropagationFlag) {
|
||||
break;
|
||||
}
|
||||
|
||||
const object = eventPath[i];
|
||||
const objectImpl = idlUtils.implForWrapper(object) || object; // window :(
|
||||
const eventListeners = objectImpl._eventListeners[eventImpl.type];
|
||||
invokeEventListeners(eventListeners, object, eventImpl);
|
||||
}
|
||||
|
||||
eventImpl.eventPhase = Event.AT_TARGET;
|
||||
|
||||
if (!eventImpl._stopPropagationFlag) {
|
||||
if (this._eventListeners[eventImpl.type]) {
|
||||
const eventListeners = this._eventListeners[eventImpl.type];
|
||||
invokeEventListeners(eventListeners, eventImpl.target, eventImpl);
|
||||
}
|
||||
}
|
||||
|
||||
if (eventImpl.bubbles) {
|
||||
eventImpl.eventPhase = Event.BUBBLING_PHASE;
|
||||
for (let i = 0; i < eventPath.length; ++i) {
|
||||
if (eventImpl._stopPropagationFlag) {
|
||||
break;
|
||||
}
|
||||
|
||||
const object = eventPath[i];
|
||||
const objectImpl = idlUtils.implForWrapper(object) || object; // window :(
|
||||
const eventListeners = objectImpl._eventListeners[eventImpl.type];
|
||||
invokeEventListeners(eventListeners, object, eventImpl);
|
||||
}
|
||||
}
|
||||
|
||||
eventImpl._dispatchFlag = false;
|
||||
eventImpl._stopPropagationFlag = false;
|
||||
eventImpl._stopImmediatePropagationFlag = false;
|
||||
eventImpl.eventPhase = Event.NONE;
|
||||
eventImpl.currentTarget = null;
|
||||
return !eventImpl._canceledFlag;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
implementation: EventTargetImpl
|
||||
};
|
||||
|
||||
function invokeEventListeners(listeners, target, eventImpl) {
|
||||
const wrapper = idlUtils.wrapperForImpl(target);
|
||||
const document = target._ownerDocument || (wrapper && (wrapper._document || wrapper._ownerDocument));
|
||||
// Will be falsy for windows that have closed
|
||||
if (!document) {
|
||||
return;
|
||||
}
|
||||
|
||||
// workaround for events emitted on window (window-proxy)
|
||||
// the wrapper is the root window instance, but we only want to expose the vm proxy at all times
|
||||
if (wrapper._document && wrapper.constructor.name === "Window") {
|
||||
target = idlUtils.implForWrapper(wrapper._document)._defaultView;
|
||||
}
|
||||
eventImpl.currentTarget = target;
|
||||
if (!listeners) {
|
||||
return;
|
||||
}
|
||||
|
||||
const handlers = listeners.slice();
|
||||
for (let i = 0; i < handlers.length; ++i) {
|
||||
if (eventImpl._stopImmediatePropagationFlag) {
|
||||
return;
|
||||
}
|
||||
|
||||
const listener = handlers[i];
|
||||
const { capture, once/* , passive */ } = listener.options;
|
||||
|
||||
if (listeners.indexOf(listener) === -1 ||
|
||||
(eventImpl.eventPhase === Event.CAPTURING_PHASE && !capture) ||
|
||||
(eventImpl.eventPhase === Event.BUBBLING_PHASE && capture)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (once) {
|
||||
listeners.splice(listeners.indexOf(listener), 1);
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof listener.callback === "object") {
|
||||
if (typeof listener.callback.handleEvent === "function") {
|
||||
listener.callback.handleEvent(idlUtils.wrapperForImpl(eventImpl));
|
||||
}
|
||||
} else {
|
||||
listener.callback.call(idlUtils.wrapperForImpl(eventImpl.currentTarget), idlUtils.wrapperForImpl(eventImpl));
|
||||
}
|
||||
} catch (e) {
|
||||
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 XHR and some other non-webidl2js things
|
||||
window = wrapper._ownerDocument._defaultView;
|
||||
}
|
||||
|
||||
if (window) {
|
||||
reportException(window, e);
|
||||
}
|
||||
// Errors in window-less documents just get swallowed... can you think of anything better?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
+9
@@ -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;
|
||||
+14
@@ -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
|
||||
};
|
||||
+29
@@ -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
|
||||
};
|
||||
+25
@@ -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
|
||||
};
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
"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
|
||||
};
|
||||
+9
@@ -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;
|
||||
+14
@@ -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
|
||||
};
|
||||
+26
@@ -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
|
||||
};
|
||||
+14
@@ -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
|
||||
};
|
||||
+59
@@ -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(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(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
|
||||
};
|
||||
+12
@@ -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
|
||||
};
|
||||
Reference in New Issue
Block a user