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

Add util.weakReference that won't crash if you pass null.

This commit is contained in:
Kris Maglione
2011-10-01 23:02:00 -04:00
parent c9583ac72f
commit 84a68bff9a
12 changed files with 25 additions and 15 deletions

View File

@@ -127,11 +127,12 @@ var Buffer = Module("Buffer", {
*/
get lastInputField() {
let field = this.localStore.lastInputField && this.localStore.lastInputField.get();
let doc = field && field.ownerDocument;
let win = doc && doc.defaultView;
return win && doc === win.document ? field : null;
},
set lastInputField(value) { this.localStore.lastInputField = value && Cu.getWeakReference(value); },
set lastInputField(value) { this.localStore.lastInputField = util.weakReference(value); },
/**
* @property {nsIURI} The current top-level document.
@@ -241,7 +242,7 @@ var Buffer = Module("Buffer", {
return frame && frame.get() || this.win;
},
set focusedFrame(frame) {
this.localStore.focusedFrame = Cu.getWeakReference(frame);
this.localStore.focusedFrame = util.weakReference(frame);
},
/**