diff options
author | Kris Maglione <maglione.k@gmail.com> | 2011-09-13 15:16:37 -0400 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2011-09-13 15:16:37 -0400 |
commit | 9f4b3ec3a71d4bba1f66ff1f88b776f8dbcd810e (patch) | |
tree | 9e5be0dc90ad12b3fe3ceae6f23b33327407422e | |
parent | 50f0901412d004840753246cef5b913734861a7a (diff) | |
download | pentadactyl-9f4b3ec3a71d4bba1f66ff1f88b776f8dbcd810e.tar.gz |
Minor cleanup.
-rw-r--r-- | common/modules/util.jsm | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 60296404..cf2e59d3 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -119,8 +119,10 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), if (!obj.observers) obj.observers = obj.observe; + let cleanup = ["dactyl-cleanup-modules", "quit-application"]; + function register(meth) { - for (let target in Set(["dactyl-cleanup-modules", "quit-application"].concat(Object.keys(obj.observers)))) + for (let target in Set(cleanup.concat(Object.keys(obj.observers)))) try { services.observer[meth](obj, target, true); } @@ -130,7 +132,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), Class.replaceProperty(obj, "observe", function (subject, target, data) { try { - if (target == "quit-application" || target == "dactyl-cleanup-modules") + if (!cleanup.indexOf(target)) register("removeObserver"); if (obj.observers[target]) obj.observers[target].call(obj, subject, data); @@ -540,22 +542,6 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), return delimiter + str.replace(/([\\'"])/g, "\\$1").replace("\n", "\\n", "g").replace("\t", "\\t", "g") + delimiter; }, - extend: function extend(dest) { - Array.slice(arguments, 1).filter(util.identity).forEach(function (src) { - for (let [k, v] in Iterator(src)) { - let get = src.__lookupGetter__(k), - set = src.__lookupSetter__(k); - if (!get && !set) - dest[k] = v; - if (get) - dest.__defineGetter__(k, get); - if (set) - dest.__defineSetter__(k, set); - } - }); - return dest; - }, - /** * Converts *bytes* to a pretty printed data size string. * |