1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-03 16:14:13 +01:00

Automatically track and remove long-lived event listeners.

This commit is contained in:
Kris Maglione
2009-11-13 16:12:50 -05:00
parent 569bef73bd
commit a4dced6911
5 changed files with 84 additions and 77 deletions

View File

@@ -67,6 +67,8 @@ Module.list = [];
Module.constructors = {};
window.addEventListener("load", function () {
window.removeEventListener("load", arguments.callee, false);
function dump(str) window.dump(String.replace(str, /\n?$/, "\n").replace(/^/m, Config.prototype.name.toLowerCase() + ": "));
const start = Date.now();
const deferredInit = { load: [] };
@@ -124,6 +126,7 @@ window.addEventListener("load", function () {
}, false);
window.addEventListener("unload", function () {
window.removeEventListener("unload", arguments.callee, false);
for (let [, mod] in iter(modules))
if (mod instanceof ModuleBase && "destroy" in mod)
mod.destroy();