Support window.onload (#2643)

This commit is contained in:
Yoshiya Hinosawa 2019-07-16 13:19:26 +09:00 committed by Ryan Dahl
parent bd6ebb32df
commit 9c45499864
14 changed files with 162 additions and 88 deletions

View file

@ -69,6 +69,7 @@ window.console = console;
window.setTimeout = timers.setTimeout;
window.setInterval = timers.setInterval;
window.location = (undefined as unknown) as domTypes.Location;
window.onload = undefined as undefined | Function;
// The following Crypto interface implementation is not up to par with the
// standard https://www.w3.org/TR/WebCryptoAPI/#crypto-interface as it does not
// yet incorporate the SubtleCrypto interface as its "subtle" property.
@ -135,6 +136,28 @@ window.postMessage = workers.postMessage;
window.Worker = workers.WorkerImpl;
export type Worker = workers.Worker;
window[domTypes.eventTargetHost] = null;
window[domTypes.eventTargetListeners] = {};
window[domTypes.eventTargetMode] = "";
window[domTypes.eventTargetNodeType] = 0;
window[eventTarget.eventTargetAssignedSlot] = false;
window[eventTarget.eventTargetHasActivationBehavior] = false;
window.addEventListener = eventTarget.EventTarget.prototype.addEventListener;
window.dispatchEvent = eventTarget.EventTarget.prototype.dispatchEvent;
window.removeEventListener =
eventTarget.EventTarget.prototype.removeEventListener;
// Registers the handler for window.onload function.
window.addEventListener(
"load",
(e: domTypes.Event): void => {
const onload = window.onload;
if (typeof onload === "function") {
onload(e);
}
}
);
// below are interfaces that are available in TypeScript but
// have different signatures
export interface ImportMeta {