lifecycle
code:sh
code:sh
code:main.ts
import "./imported.ts"
const handler = (e: Event): void => {
console.log([main.ts]\twindow.addEventListener\t"${e.type}")
}
// 5
window.addEventListener("load", handler)
// 8 (last)
window.addEventListener("unload", handler)
// 4
window.onload = (e: Event): void => {
console.log([main.ts]\twindow.onload\t"${e.type}")
}
// 7 (last - 1)
window.onunload = (e: Event): void => {
console.log([main.ts]\twindow.onunload\t"${e.type}")
}
// 2
console.log("main.ts\tlog from main script") code:imported.ts
const handler = (e: Event): void => {
console.log([imported.ts]\twindow.addEventListener\t"${e.type}")
}
// 3
window.addEventListener("load", handler)
// 6 (last - 2)
window.addEventListener("unload", handler)
// 実行されない
window.onload = (e: Event): void => {
console.log([imported.ts]\twindow.onload\t"${e.type}")
}
// 実行されない
window.onunload = (e: Event): void => {
console.log([imported.ts]\twindow.onunload\t"${e.type}")
}
// 1