summaryrefslogtreecommitdiff
path: root/js/event.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/event.ts')
-rw-r--r--js/event.ts109
1 files changed, 107 insertions, 2 deletions
diff --git a/js/event.ts b/js/event.ts
index dc39a3c83..92d2b5fef 100644
--- a/js/event.ts
+++ b/js/event.ts
@@ -21,7 +21,7 @@ export class EventInit implements domTypes.EventInit {
export class Event implements domTypes.Event {
// Each event has the following associated flags
private _canceledFlag = false;
- private dispatchedFlag = false;
+ private _dispatchedFlag = false;
private _initializedFlag = false;
private _inPassiveListenerFlag = false;
private _stopImmediatePropagationFlag = false;
@@ -42,6 +42,7 @@ export class Event implements domTypes.Event {
currentTarget: null,
eventPhase: domTypes.EventPhase.NONE,
isTrusted: false,
+ relatedTarget: null,
target: null,
timeStamp: Date.now()
});
@@ -55,10 +56,18 @@ export class Event implements domTypes.Event {
return this._stopPropagationFlag;
}
+ set cancelBubble(value: boolean) {
+ this._stopPropagationFlag = value;
+ }
+
get cancelBubbleImmediately(): boolean {
return this._stopImmediatePropagationFlag;
}
+ set cancelBubbleImmediately(value: boolean) {
+ this._stopImmediatePropagationFlag = value;
+ }
+
get cancelable(): boolean {
return getPrivateValue(this, eventAttributes, "cancelable");
}
@@ -71,30 +80,125 @@ export class Event implements domTypes.Event {
return getPrivateValue(this, eventAttributes, "currentTarget");
}
+ set currentTarget(value: domTypes.EventTarget) {
+ eventAttributes.set(this, {
+ type: this.type,
+ bubbles: this.bubbles,
+ cancelable: this.cancelable,
+ composed: this.composed,
+ currentTarget: value,
+ eventPhase: this.eventPhase,
+ isTrusted: this.isTrusted,
+ relatedTarget: this.relatedTarget,
+ target: this.target,
+ timeStamp: this.timeStamp
+ });
+ }
+
get defaultPrevented(): boolean {
return this._canceledFlag;
}
get dispatched(): boolean {
- return this.dispatchedFlag;
+ return this._dispatchedFlag;
+ }
+
+ set dispatched(value: boolean) {
+ this._dispatchedFlag = value;
}
get eventPhase(): number {
return getPrivateValue(this, eventAttributes, "eventPhase");
}
+ set eventPhase(value: number) {
+ eventAttributes.set(this, {
+ type: this.type,
+ bubbles: this.bubbles,
+ cancelable: this.cancelable,
+ composed: this.composed,
+ currentTarget: this.currentTarget,
+ eventPhase: value,
+ isTrusted: this.isTrusted,
+ relatedTarget: this.relatedTarget,
+ target: this.target,
+ timeStamp: this.timeStamp
+ });
+ }
+
get initialized(): boolean {
return this._initializedFlag;
}
+ set inPassiveListener(value: boolean) {
+ this._inPassiveListenerFlag = value;
+ }
+
get isTrusted(): boolean {
return getPrivateValue(this, eventAttributes, "isTrusted");
}
+ set isTrusted(value: boolean) {
+ eventAttributes.set(this, {
+ type: this.type,
+ bubbles: this.bubbles,
+ cancelable: this.cancelable,
+ composed: this.composed,
+ currentTarget: this.currentTarget,
+ eventPhase: this.eventPhase,
+ isTrusted: value,
+ relatedTarget: this.relatedTarget,
+ target: this.target,
+ timeStamp: this.timeStamp
+ });
+ }
+
+ get path(): domTypes.EventPath[] {
+ return this._path;
+ }
+
+ set path(value: domTypes.EventPath[]) {
+ this._path = value;
+ }
+
+ get relatedTarget(): domTypes.EventTarget {
+ return getPrivateValue(this, eventAttributes, "relatedTarget");
+ }
+
+ set relatedTarget(value: domTypes.EventTarget) {
+ eventAttributes.set(this, {
+ type: this.type,
+ bubbles: this.bubbles,
+ cancelable: this.cancelable,
+ composed: this.composed,
+ currentTarget: this.currentTarget,
+ eventPhase: this.eventPhase,
+ isTrusted: this.isTrusted,
+ relatedTarget: value,
+ target: this.target,
+ timeStamp: this.timeStamp
+ });
+ }
+
get target(): domTypes.EventTarget {
return getPrivateValue(this, eventAttributes, "target");
}
+ set target(value: domTypes.EventTarget) {
+ eventAttributes.set(this, {
+ type: this.type,
+ bubbles: this.bubbles,
+ cancelable: this.cancelable,
+ composed: this.composed,
+ currentTarget: this.currentTarget,
+ eventPhase: this.eventPhase,
+ isTrusted: this.isTrusted,
+ relatedTarget: this.relatedTarget,
+ target: value,
+ timeStamp: this.timeStamp
+ });
+ }
+
get timeStamp(): Date {
return getPrivateValue(this, eventAttributes, "timeStamp");
}
@@ -257,6 +361,7 @@ Reflect.defineProperty(Event.prototype, "currentTarget", { enumerable: true });
Reflect.defineProperty(Event.prototype, "defaultPrevented", {
enumerable: true
});
+Reflect.defineProperty(Event.prototype, "dispatched", { enumerable: true });
Reflect.defineProperty(Event.prototype, "eventPhase", { enumerable: true });
Reflect.defineProperty(Event.prototype, "isTrusted", { enumerable: true });
Reflect.defineProperty(Event.prototype, "target", { enumerable: true });