mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-23 11:05:47 +01:00
Add util.weakReference that won't crash if you pass null.
This commit is contained in:
@@ -1550,6 +1550,15 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
return res.filter(function (h) !Set.add(seen, h.spec));
|
||||
},
|
||||
|
||||
/**
|
||||
* Like Cu.getWeakReference, but won't crash if you pass null.
|
||||
*/
|
||||
weakReference: function weakReference(jsval) {
|
||||
if (jsval == null)
|
||||
return { get: function get() null };
|
||||
return Cu.getWeakReference(jsval);
|
||||
},
|
||||
|
||||
/**
|
||||
* Wraps native exceptions thrown by the called function so that a
|
||||
* proper stack trace may be retrieved from them.
|
||||
|
||||
Reference in New Issue
Block a user