diff options
author | crowlKats <13135287+crowlKats@users.noreply.github.com> | 2020-09-05 16:39:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-05 10:39:25 -0400 |
commit | 8c880d32612c562795d8cd539c662a0cfdcbb8c8 (patch) | |
tree | 1d4df2ffb263860d0cd227cbe5dce745a5e3e2a7 /op_crates/web/01_event.js | |
parent | 34e98fa59cd70f7ce64e587bef41fac536a3076b (diff) |
feat: Implement WebSocket API (#7051)
Diffstat (limited to 'op_crates/web/01_event.js')
-rw-r--r-- | op_crates/web/01_event.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/op_crates/web/01_event.js b/op_crates/web/01_event.js index 48899e6fd..5b21d4402 100644 --- a/op_crates/web/01_event.js +++ b/op_crates/web/01_event.js @@ -1011,6 +1011,55 @@ "error", ]); + class CloseEvent extends Event { + #wasClean = ""; + #code = ""; + #reason = ""; + + get wasClean() { + return this.#wasClean; + } + get code() { + return this.#code; + } + get reason() { + return this.#reason; + } + + constructor(type, { + bubbles, + cancelable, + composed, + wasClean = false, + code = 0, + reason = "", + } = {}) { + super(type, { + bubbles: bubbles, + cancelable: cancelable, + composed: composed, + }); + + this.#wasClean = wasClean; + this.#code = code; + this.#reason = reason; + } + } + + class MessageEvent extends Event { + constructor(type, eventInitDict) { + super(type, { + bubbles: eventInitDict?.bubbles ?? false, + cancelable: eventInitDict?.cancelable ?? false, + composed: eventInitDict?.composed ?? false, + }); + + this.data = eventInitDict?.data ?? null; + this.origin = eventInitDict?.origin ?? ""; + this.lastEventId = eventInitDict?.lastEventId ?? ""; + } + } + class CustomEvent extends Event { #detail = null; @@ -1037,6 +1086,8 @@ window.Event = Event; window.EventTarget = EventTarget; window.ErrorEvent = ErrorEvent; + window.CloseEvent = CloseEvent; + window.MessageEvent = MessageEvent; window.CustomEvent = CustomEvent; window.dispatchEvent = EventTarget.prototype.dispatchEvent; window.addEventListener = EventTarget.prototype.addEventListener; |