@remote-dom/polyfill 1.4.5 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/build/cjs/ClipboardEvent.cjs +15 -0
- package/build/cjs/ErrorEvent.cjs +19 -0
- package/build/cjs/FocusEvent.cjs +15 -0
- package/build/cjs/PromiseRejectionEvent.cjs +16 -0
- package/build/cjs/ToggleEvent.cjs +16 -0
- package/build/cjs/Window.cjs +50 -0
- package/build/esm/ClipboardEvent.mjs +11 -0
- package/build/esm/ErrorEvent.mjs +15 -0
- package/build/esm/FocusEvent.mjs +11 -0
- package/build/esm/PromiseRejectionEvent.mjs +12 -0
- package/build/esm/ToggleEvent.mjs +12 -0
- package/build/esm/Window.mjs +50 -0
- package/build/esnext/ClipboardEvent.esnext +11 -0
- package/build/esnext/ErrorEvent.esnext +19 -0
- package/build/esnext/FocusEvent.esnext +11 -0
- package/build/esnext/PromiseRejectionEvent.esnext +13 -0
- package/build/esnext/ToggleEvent.esnext +13 -0
- package/build/esnext/Window.esnext +57 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/ClipboardEvent.d.ts +6 -0
- package/build/typescript/ClipboardEvent.d.ts.map +1 -0
- package/build/typescript/ErrorEvent.d.ts +10 -0
- package/build/typescript/ErrorEvent.d.ts.map +1 -0
- package/build/typescript/FocusEvent.d.ts +6 -0
- package/build/typescript/FocusEvent.d.ts.map +1 -0
- package/build/typescript/PromiseRejectionEvent.d.ts +7 -0
- package/build/typescript/PromiseRejectionEvent.d.ts.map +1 -0
- package/build/typescript/ToggleEvent.d.ts +7 -0
- package/build/typescript/ToggleEvent.d.ts.map +1 -0
- package/build/typescript/Window.d.ts +17 -0
- package/build/typescript/Window.d.ts.map +1 -1
- package/build/typescript/tests/global-errors.test.d.ts +2 -0
- package/build/typescript/tests/global-errors.test.d.ts.map +1 -0
- package/package.json +1 -1
- package/source/ClipboardEvent.ts +12 -0
- package/source/ErrorEvent.ts +20 -0
- package/source/FocusEvent.ts +12 -0
- package/source/PromiseRejectionEvent.ts +14 -0
- package/source/ToggleEvent.ts +14 -0
- package/source/Window.ts +78 -0
- package/source/tests/global-errors.test.ts +149 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @remote-dom/polyfill
|
|
2
2
|
|
|
3
|
+
## 1.4.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#594](https://github.com/Shopify/remote-dom/pull/594) [`789a7c7`](https://github.com/Shopify/remote-dom/commit/789a7c7480a445d1e5973bd6e2aa4e8889ec6f85) Thanks [@robin-drexler](https://github.com/robin-drexler)! - add `FocusEvent`, `ClipboardEvent` and `ToggleEvent` to polyfill
|
|
8
|
+
|
|
9
|
+
## 1.4.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#590](https://github.com/Shopify/remote-dom/pull/590) [`8994a49`](https://github.com/Shopify/remote-dom/commit/8994a49913cd0122fdfbd21f971448afab3a3207) Thanks [@robin-drexler](https://github.com/robin-drexler)! - fix error events not working
|
|
14
|
+
|
|
3
15
|
## 1.4.5
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const Event = require('./Event.cjs');
|
|
6
|
+
|
|
7
|
+
// https://w3c.github.io/clipboard-apis/#clipboardevent-interface
|
|
8
|
+
class ClipboardEvent extends Event.Event {
|
|
9
|
+
constructor(type, eventInitDict = {}) {
|
|
10
|
+
super(type, eventInitDict);
|
|
11
|
+
this.clipboardData = eventInitDict.clipboardData ?? null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.ClipboardEvent = ClipboardEvent;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const Event = require('./Event.cjs');
|
|
6
|
+
|
|
7
|
+
// https://html.spec.whatwg.org/multipage/webappapis.html#errorevent
|
|
8
|
+
class ErrorEvent extends Event.Event {
|
|
9
|
+
constructor(type, eventInitDict) {
|
|
10
|
+
super(type, eventInitDict);
|
|
11
|
+
this.message = eventInitDict.message;
|
|
12
|
+
this.filename = eventInitDict.filename;
|
|
13
|
+
this.lineno = eventInitDict.lineno;
|
|
14
|
+
this.colno = eventInitDict.colno;
|
|
15
|
+
this.error = eventInitDict.error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.ErrorEvent = ErrorEvent;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const Event = require('./Event.cjs');
|
|
6
|
+
|
|
7
|
+
// https://w3c.github.io/uievents/#interface-focusevent
|
|
8
|
+
class FocusEvent extends Event.Event {
|
|
9
|
+
constructor(type, eventInitDict = {}) {
|
|
10
|
+
super(type, eventInitDict);
|
|
11
|
+
this.relatedTarget = eventInitDict.relatedTarget ?? null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.FocusEvent = FocusEvent;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const Event = require('./Event.cjs');
|
|
6
|
+
|
|
7
|
+
//https://html.spec.whatwg.org/multipage/webappapis.html#promiserejectionevent
|
|
8
|
+
class PromiseRejectionEvent extends Event.Event {
|
|
9
|
+
constructor(type, eventInitDict) {
|
|
10
|
+
super(type, eventInitDict);
|
|
11
|
+
this.promise = eventInitDict.promise;
|
|
12
|
+
this.reason = eventInitDict.reason;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.PromiseRejectionEvent = PromiseRejectionEvent;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const Event = require('./Event.cjs');
|
|
6
|
+
|
|
7
|
+
// https://html.spec.whatwg.org/multipage/popover.html#toggleevent
|
|
8
|
+
class ToggleEvent extends Event.Event {
|
|
9
|
+
constructor(type, eventInitDict) {
|
|
10
|
+
super(type, eventInitDict);
|
|
11
|
+
this.oldState = eventInitDict.oldState;
|
|
12
|
+
this.newState = eventInitDict.newState;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.ToggleEvent = ToggleEvent;
|
package/build/cjs/Window.cjs
CHANGED
|
@@ -6,6 +6,11 @@ const Document = require('./Document.cjs');
|
|
|
6
6
|
const Event = require('./Event.cjs');
|
|
7
7
|
const EventTarget = require('./EventTarget.cjs');
|
|
8
8
|
const CustomEvent = require('./CustomEvent.cjs');
|
|
9
|
+
const ErrorEvent = require('./ErrorEvent.cjs');
|
|
10
|
+
const PromiseRejectionEvent = require('./PromiseRejectionEvent.cjs');
|
|
11
|
+
const ToggleEvent = require('./ToggleEvent.cjs');
|
|
12
|
+
const FocusEvent = require('./FocusEvent.cjs');
|
|
13
|
+
const ClipboardEvent = require('./ClipboardEvent.cjs');
|
|
9
14
|
const Node = require('./Node.cjs');
|
|
10
15
|
const ParentNode = require('./ParentNode.cjs');
|
|
11
16
|
const ChildNode = require('./ChildNode.cjs');
|
|
@@ -33,6 +38,11 @@ class Window extends EventTarget.EventTarget {
|
|
|
33
38
|
location = (() => globalThis.location)();
|
|
34
39
|
navigator = (() => globalThis.navigator)();
|
|
35
40
|
Event = (() => Event.Event)();
|
|
41
|
+
ErrorEvent = (() => ErrorEvent.ErrorEvent)();
|
|
42
|
+
PromiseRejectionEvent = (() => PromiseRejectionEvent.PromiseRejectionEvent)();
|
|
43
|
+
ToggleEvent = (() => ToggleEvent.ToggleEvent)();
|
|
44
|
+
FocusEvent = (() => FocusEvent.FocusEvent)();
|
|
45
|
+
ClipboardEvent = (() => ClipboardEvent.ClipboardEvent)();
|
|
36
46
|
EventTarget = (() => EventTarget.EventTarget)();
|
|
37
47
|
CustomEvent = (() => CustomEvent.CustomEvent)();
|
|
38
48
|
Node = (() => Node.Node)();
|
|
@@ -48,6 +58,46 @@ class Window extends EventTarget.EventTarget {
|
|
|
48
58
|
SVGElement = (() => SVGElement.SVGElement)();
|
|
49
59
|
HTMLTemplateElement = (() => HTMLTemplateElement.HTMLTemplateElement)();
|
|
50
60
|
MutationObserver = (() => MutationObserver.MutationObserver)();
|
|
61
|
+
#currentOnErrorHandler = null;
|
|
62
|
+
#currentOriginalOnErrorHandler = null;
|
|
63
|
+
#currentOnUnhandledRejectionHandler = null;
|
|
64
|
+
get onerror() {
|
|
65
|
+
return this.#currentOriginalOnErrorHandler;
|
|
66
|
+
}
|
|
67
|
+
set onerror(handler) {
|
|
68
|
+
if (this.#currentOnErrorHandler) {
|
|
69
|
+
this.removeEventListener('error', this.#currentOnErrorHandler);
|
|
70
|
+
}
|
|
71
|
+
if (handler && typeof handler === 'function') {
|
|
72
|
+
// the event listener version receives an event object
|
|
73
|
+
// whereas winwow.onerror receives 5 arguments instead
|
|
74
|
+
// we need to wrap the handler to convert the event object to the 5 arguments
|
|
75
|
+
// and also make sure that when window.onerror is read to return the original handler
|
|
76
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/error_event#syntax
|
|
77
|
+
this.#currentOriginalOnErrorHandler = handler;
|
|
78
|
+
this.#currentOnErrorHandler = event => {
|
|
79
|
+
handler(event.message ?? 'Error', event.filename, event.lineno, event.colno, event.error);
|
|
80
|
+
};
|
|
81
|
+
this.addEventListener('error', this.#currentOnErrorHandler);
|
|
82
|
+
} else {
|
|
83
|
+
this.#currentOnErrorHandler = null;
|
|
84
|
+
this.#currentOriginalOnErrorHandler = null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
get onunhandledrejection() {
|
|
88
|
+
return this.#currentOnUnhandledRejectionHandler;
|
|
89
|
+
}
|
|
90
|
+
set onunhandledrejection(handler) {
|
|
91
|
+
if (this.#currentOnUnhandledRejectionHandler) {
|
|
92
|
+
this.removeEventListener('unhandledrejection', this.#currentOnUnhandledRejectionHandler);
|
|
93
|
+
}
|
|
94
|
+
if (handler && typeof handler === 'function') {
|
|
95
|
+
this.#currentOnUnhandledRejectionHandler = handler;
|
|
96
|
+
this.addEventListener('unhandledrejection', this.#currentOnUnhandledRejectionHandler);
|
|
97
|
+
} else {
|
|
98
|
+
this.#currentOnUnhandledRejectionHandler = null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
51
101
|
static setGlobal(window) {
|
|
52
102
|
const properties = Object.getOwnPropertyDescriptors(window);
|
|
53
103
|
delete properties.self;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Event } from './Event.mjs';
|
|
2
|
+
|
|
3
|
+
// https://w3c.github.io/clipboard-apis/#clipboardevent-interface
|
|
4
|
+
class ClipboardEvent extends Event {
|
|
5
|
+
constructor(type, eventInitDict = {}) {
|
|
6
|
+
super(type, eventInitDict);
|
|
7
|
+
this.clipboardData = eventInitDict.clipboardData ?? null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { ClipboardEvent };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Event } from './Event.mjs';
|
|
2
|
+
|
|
3
|
+
// https://html.spec.whatwg.org/multipage/webappapis.html#errorevent
|
|
4
|
+
class ErrorEvent extends Event {
|
|
5
|
+
constructor(type, eventInitDict) {
|
|
6
|
+
super(type, eventInitDict);
|
|
7
|
+
this.message = eventInitDict.message;
|
|
8
|
+
this.filename = eventInitDict.filename;
|
|
9
|
+
this.lineno = eventInitDict.lineno;
|
|
10
|
+
this.colno = eventInitDict.colno;
|
|
11
|
+
this.error = eventInitDict.error;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { ErrorEvent };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Event } from './Event.mjs';
|
|
2
|
+
|
|
3
|
+
// https://w3c.github.io/uievents/#interface-focusevent
|
|
4
|
+
class FocusEvent extends Event {
|
|
5
|
+
constructor(type, eventInitDict = {}) {
|
|
6
|
+
super(type, eventInitDict);
|
|
7
|
+
this.relatedTarget = eventInitDict.relatedTarget ?? null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { FocusEvent };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Event } from './Event.mjs';
|
|
2
|
+
|
|
3
|
+
//https://html.spec.whatwg.org/multipage/webappapis.html#promiserejectionevent
|
|
4
|
+
class PromiseRejectionEvent extends Event {
|
|
5
|
+
constructor(type, eventInitDict) {
|
|
6
|
+
super(type, eventInitDict);
|
|
7
|
+
this.promise = eventInitDict.promise;
|
|
8
|
+
this.reason = eventInitDict.reason;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { PromiseRejectionEvent };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Event } from './Event.mjs';
|
|
2
|
+
|
|
3
|
+
// https://html.spec.whatwg.org/multipage/popover.html#toggleevent
|
|
4
|
+
class ToggleEvent extends Event {
|
|
5
|
+
constructor(type, eventInitDict) {
|
|
6
|
+
super(type, eventInitDict);
|
|
7
|
+
this.oldState = eventInitDict.oldState;
|
|
8
|
+
this.newState = eventInitDict.newState;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { ToggleEvent };
|
package/build/esm/Window.mjs
CHANGED
|
@@ -2,6 +2,11 @@ import { Document } from './Document.mjs';
|
|
|
2
2
|
import { Event } from './Event.mjs';
|
|
3
3
|
import { EventTarget } from './EventTarget.mjs';
|
|
4
4
|
import { CustomEvent } from './CustomEvent.mjs';
|
|
5
|
+
import { ErrorEvent } from './ErrorEvent.mjs';
|
|
6
|
+
import { PromiseRejectionEvent } from './PromiseRejectionEvent.mjs';
|
|
7
|
+
import { ToggleEvent } from './ToggleEvent.mjs';
|
|
8
|
+
import { FocusEvent } from './FocusEvent.mjs';
|
|
9
|
+
import { ClipboardEvent } from './ClipboardEvent.mjs';
|
|
5
10
|
import { Node } from './Node.mjs';
|
|
6
11
|
import { ParentNode } from './ParentNode.mjs';
|
|
7
12
|
import { ChildNode } from './ChildNode.mjs';
|
|
@@ -29,6 +34,11 @@ class Window extends EventTarget {
|
|
|
29
34
|
location = (() => globalThis.location)();
|
|
30
35
|
navigator = (() => globalThis.navigator)();
|
|
31
36
|
Event = (() => Event)();
|
|
37
|
+
ErrorEvent = (() => ErrorEvent)();
|
|
38
|
+
PromiseRejectionEvent = (() => PromiseRejectionEvent)();
|
|
39
|
+
ToggleEvent = (() => ToggleEvent)();
|
|
40
|
+
FocusEvent = (() => FocusEvent)();
|
|
41
|
+
ClipboardEvent = (() => ClipboardEvent)();
|
|
32
42
|
EventTarget = (() => EventTarget)();
|
|
33
43
|
CustomEvent = (() => CustomEvent)();
|
|
34
44
|
Node = (() => Node)();
|
|
@@ -44,6 +54,46 @@ class Window extends EventTarget {
|
|
|
44
54
|
SVGElement = (() => SVGElement)();
|
|
45
55
|
HTMLTemplateElement = (() => HTMLTemplateElement)();
|
|
46
56
|
MutationObserver = (() => MutationObserver)();
|
|
57
|
+
#currentOnErrorHandler = null;
|
|
58
|
+
#currentOriginalOnErrorHandler = null;
|
|
59
|
+
#currentOnUnhandledRejectionHandler = null;
|
|
60
|
+
get onerror() {
|
|
61
|
+
return this.#currentOriginalOnErrorHandler;
|
|
62
|
+
}
|
|
63
|
+
set onerror(handler) {
|
|
64
|
+
if (this.#currentOnErrorHandler) {
|
|
65
|
+
this.removeEventListener('error', this.#currentOnErrorHandler);
|
|
66
|
+
}
|
|
67
|
+
if (handler && typeof handler === 'function') {
|
|
68
|
+
// the event listener version receives an event object
|
|
69
|
+
// whereas winwow.onerror receives 5 arguments instead
|
|
70
|
+
// we need to wrap the handler to convert the event object to the 5 arguments
|
|
71
|
+
// and also make sure that when window.onerror is read to return the original handler
|
|
72
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/error_event#syntax
|
|
73
|
+
this.#currentOriginalOnErrorHandler = handler;
|
|
74
|
+
this.#currentOnErrorHandler = event => {
|
|
75
|
+
handler(event.message ?? 'Error', event.filename, event.lineno, event.colno, event.error);
|
|
76
|
+
};
|
|
77
|
+
this.addEventListener('error', this.#currentOnErrorHandler);
|
|
78
|
+
} else {
|
|
79
|
+
this.#currentOnErrorHandler = null;
|
|
80
|
+
this.#currentOriginalOnErrorHandler = null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
get onunhandledrejection() {
|
|
84
|
+
return this.#currentOnUnhandledRejectionHandler;
|
|
85
|
+
}
|
|
86
|
+
set onunhandledrejection(handler) {
|
|
87
|
+
if (this.#currentOnUnhandledRejectionHandler) {
|
|
88
|
+
this.removeEventListener('unhandledrejection', this.#currentOnUnhandledRejectionHandler);
|
|
89
|
+
}
|
|
90
|
+
if (handler && typeof handler === 'function') {
|
|
91
|
+
this.#currentOnUnhandledRejectionHandler = handler;
|
|
92
|
+
this.addEventListener('unhandledrejection', this.#currentOnUnhandledRejectionHandler);
|
|
93
|
+
} else {
|
|
94
|
+
this.#currentOnUnhandledRejectionHandler = null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
47
97
|
static setGlobal(window) {
|
|
48
98
|
const properties = Object.getOwnPropertyDescriptors(window);
|
|
49
99
|
delete properties.self;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Event } from './Event.esnext';
|
|
2
|
+
|
|
3
|
+
class ClipboardEvent extends Event {
|
|
4
|
+
clipboardData;
|
|
5
|
+
constructor(type, eventInitDict = {}) {
|
|
6
|
+
super(type, eventInitDict);
|
|
7
|
+
this.clipboardData = eventInitDict.clipboardData ?? null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { ClipboardEvent };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Event } from './Event.esnext';
|
|
2
|
+
|
|
3
|
+
class ErrorEvent extends Event {
|
|
4
|
+
message;
|
|
5
|
+
filename;
|
|
6
|
+
lineno;
|
|
7
|
+
colno;
|
|
8
|
+
error;
|
|
9
|
+
constructor(type, eventInitDict) {
|
|
10
|
+
super(type, eventInitDict);
|
|
11
|
+
this.message = eventInitDict.message;
|
|
12
|
+
this.filename = eventInitDict.filename;
|
|
13
|
+
this.lineno = eventInitDict.lineno;
|
|
14
|
+
this.colno = eventInitDict.colno;
|
|
15
|
+
this.error = eventInitDict.error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { ErrorEvent };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Event } from './Event.esnext';
|
|
2
|
+
|
|
3
|
+
class FocusEvent extends Event {
|
|
4
|
+
relatedTarget;
|
|
5
|
+
constructor(type, eventInitDict = {}) {
|
|
6
|
+
super(type, eventInitDict);
|
|
7
|
+
this.relatedTarget = eventInitDict.relatedTarget ?? null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { FocusEvent };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Event } from './Event.esnext';
|
|
2
|
+
|
|
3
|
+
class PromiseRejectionEvent extends Event {
|
|
4
|
+
promise;
|
|
5
|
+
reason;
|
|
6
|
+
constructor(type, eventInitDict) {
|
|
7
|
+
super(type, eventInitDict);
|
|
8
|
+
this.promise = eventInitDict.promise;
|
|
9
|
+
this.reason = eventInitDict.reason;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { PromiseRejectionEvent };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Event } from './Event.esnext';
|
|
2
|
+
|
|
3
|
+
class ToggleEvent extends Event {
|
|
4
|
+
oldState;
|
|
5
|
+
newState;
|
|
6
|
+
constructor(type, eventInitDict) {
|
|
7
|
+
super(type, eventInitDict);
|
|
8
|
+
this.oldState = eventInitDict.oldState;
|
|
9
|
+
this.newState = eventInitDict.newState;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { ToggleEvent };
|
|
@@ -2,6 +2,11 @@ import { Document } from './Document.esnext';
|
|
|
2
2
|
import { Event } from './Event.esnext';
|
|
3
3
|
import { EventTarget } from './EventTarget.esnext';
|
|
4
4
|
import { CustomEvent } from './CustomEvent.esnext';
|
|
5
|
+
import { ErrorEvent } from './ErrorEvent.esnext';
|
|
6
|
+
import { PromiseRejectionEvent } from './PromiseRejectionEvent.esnext';
|
|
7
|
+
import { ToggleEvent } from './ToggleEvent.esnext';
|
|
8
|
+
import { FocusEvent } from './FocusEvent.esnext';
|
|
9
|
+
import { ClipboardEvent } from './ClipboardEvent.esnext';
|
|
5
10
|
import { Node } from './Node.esnext';
|
|
6
11
|
import { ParentNode } from './ParentNode.esnext';
|
|
7
12
|
import { ChildNode } from './ChildNode.esnext';
|
|
@@ -29,6 +34,11 @@ class Window extends EventTarget {
|
|
|
29
34
|
location = globalThis.location;
|
|
30
35
|
navigator = globalThis.navigator;
|
|
31
36
|
Event = Event;
|
|
37
|
+
ErrorEvent = ErrorEvent;
|
|
38
|
+
PromiseRejectionEvent = PromiseRejectionEvent;
|
|
39
|
+
ToggleEvent = ToggleEvent;
|
|
40
|
+
FocusEvent = FocusEvent;
|
|
41
|
+
ClipboardEvent = ClipboardEvent;
|
|
32
42
|
EventTarget = EventTarget;
|
|
33
43
|
CustomEvent = CustomEvent;
|
|
34
44
|
Node = Node;
|
|
@@ -44,6 +54,53 @@ class Window extends EventTarget {
|
|
|
44
54
|
SVGElement = SVGElement;
|
|
45
55
|
HTMLTemplateElement = HTMLTemplateElement;
|
|
46
56
|
MutationObserver = MutationObserver;
|
|
57
|
+
#currentOnErrorHandler = null;
|
|
58
|
+
#currentOriginalOnErrorHandler = null;
|
|
59
|
+
#currentOnUnhandledRejectionHandler = null;
|
|
60
|
+
get onerror() {
|
|
61
|
+
return this.#currentOriginalOnErrorHandler;
|
|
62
|
+
}
|
|
63
|
+
set onerror(handler) {
|
|
64
|
+
if (this.#currentOnErrorHandler) {
|
|
65
|
+
this.removeEventListener("error", this.#currentOnErrorHandler);
|
|
66
|
+
}
|
|
67
|
+
if (handler && typeof handler === "function") {
|
|
68
|
+
this.#currentOriginalOnErrorHandler = handler;
|
|
69
|
+
this.#currentOnErrorHandler = (event) => {
|
|
70
|
+
handler(
|
|
71
|
+
event.message ?? "Error",
|
|
72
|
+
event.filename,
|
|
73
|
+
event.lineno,
|
|
74
|
+
event.colno,
|
|
75
|
+
event.error
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
this.addEventListener("error", this.#currentOnErrorHandler);
|
|
79
|
+
} else {
|
|
80
|
+
this.#currentOnErrorHandler = null;
|
|
81
|
+
this.#currentOriginalOnErrorHandler = null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
get onunhandledrejection() {
|
|
85
|
+
return this.#currentOnUnhandledRejectionHandler;
|
|
86
|
+
}
|
|
87
|
+
set onunhandledrejection(handler) {
|
|
88
|
+
if (this.#currentOnUnhandledRejectionHandler) {
|
|
89
|
+
this.removeEventListener(
|
|
90
|
+
"unhandledrejection",
|
|
91
|
+
this.#currentOnUnhandledRejectionHandler
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
if (handler && typeof handler === "function") {
|
|
95
|
+
this.#currentOnUnhandledRejectionHandler = handler;
|
|
96
|
+
this.addEventListener(
|
|
97
|
+
"unhandledrejection",
|
|
98
|
+
this.#currentOnUnhandledRejectionHandler
|
|
99
|
+
);
|
|
100
|
+
} else {
|
|
101
|
+
this.#currentOnUnhandledRejectionHandler = null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
47
104
|
static setGlobal(window) {
|
|
48
105
|
const properties = Object.getOwnPropertyDescriptors(window);
|
|
49
106
|
delete properties.self;
|