fix(js): add global PromiseRejectionEvent and StorageEvent constructors
Obscura lacked these two standard event constructors on globalThis. The missing PromiseRejectionEvent caused core-js to misdetect the environment and override native Promise with a broken polyfill, breaking Vue application rendering. StorageEvent completes the localStorage/sessionStorage API surface. Both are also registered in document.createEvent() for legacy callers. Fixes #521, fixes #522.
This commit is contained in:
1 parent
e78b5e6026
commit
776c915c8c
1 file changed
+31
Vendored
+31
@@ -2627,6 +2627,8 @@ class Document extends Node {
|
|||||||
'popstateevent': PopStateEvent,
|
'popstateevent': PopStateEvent,
|
||||||
'animationevent': AnimationEvent,
|
'animationevent': AnimationEvent,
|
||||||
'transitionevent': TransitionEvent,
|
'transitionevent': TransitionEvent,
|
||||||
|
'promiserejectionevent': PromiseRejectionEvent,
|
||||||
|
'storageevent': StorageEvent,
|
||||||
};
|
};
|
||||||
const Cls = map[String(type || '').toLowerCase()] || Event;
|
const Cls = map[String(type || '').toLowerCase()] || Event;
|
||||||
return new Cls('');
|
return new Cls('');
|
||||||
@@ -5007,6 +5009,35 @@ globalThis.ToggleEvent = class ToggleEvent extends Event {
|
|||||||
};
|
};
|
||||||
_markNative(globalThis.ToggleEvent);
|
_markNative(globalThis.ToggleEvent);
|
||||||
|
|
||||||
|
globalThis.PromiseRejectionEvent = class PromiseRejectionEvent extends Event {
|
||||||
|
constructor(type, init = {}) {
|
||||||
|
super(type, init);
|
||||||
|
this.promise = init.promise;
|
||||||
|
this.reason = init.reason;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
_markNative(globalThis.PromiseRejectionEvent);
|
||||||
|
|
||||||
|
globalThis.StorageEvent = class StorageEvent extends Event {
|
||||||
|
constructor(type, init = {}) {
|
||||||
|
super(type, init);
|
||||||
|
this.key = init.key !== undefined ? init.key : null;
|
||||||
|
this.oldValue = init.oldValue !== undefined ? init.oldValue : null;
|
||||||
|
this.newValue = init.newValue !== undefined ? init.newValue : null;
|
||||||
|
this.url = init.url || "";
|
||||||
|
this.storageArea = init.storageArea || null;
|
||||||
|
}
|
||||||
|
initStorageEvent(type, bubbles, cancelable, key, oldValue, newValue, url, storageArea) {
|
||||||
|
this.initEvent(type, bubbles, cancelable);
|
||||||
|
this.key = key !== undefined ? key : null;
|
||||||
|
this.oldValue = oldValue !== undefined ? oldValue : null;
|
||||||
|
this.newValue = newValue !== undefined ? newValue : null;
|
||||||
|
this.url = url || "";
|
||||||
|
this.storageArea = storageArea || null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
_markNative(globalThis.StorageEvent);
|
||||||
|
|
||||||
// AbortController / AbortSignal. AbortSignal is a real constructor with a
|
// AbortController / AbortSignal. AbortSignal is a real constructor with a
|
||||||
// prototype, so feature-detection and `AbortSignal.prototype` access work. It
|
// prototype, so feature-detection and `AbortSignal.prototype` access work. It
|
||||||
// carries aborted/reason, supports throwIfAborted(), and fires "abort" to
|
// carries aborted/reason, supports throwIfAborted(), and fires "abort" to
|
||||||
|
|||||||
Reference in new issue
Block a user