mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 11:18:00 +01:00
Make things not explode.
This commit is contained in:
@@ -143,7 +143,7 @@ var Events = Module("events", {
|
||||
this.active.push(elem);
|
||||
}
|
||||
|
||||
this.active = this.active.filter(function (e) e.popupBoxObject.popupState != "closed");
|
||||
this.active = this.active.filter(function (e) e.popupBoxObject && e.popupBoxObject.popupState != "closed");
|
||||
|
||||
if (!this.active.length && !this.activeMenubar)
|
||||
modes.remove(modes.MENU, true);
|
||||
|
||||
@@ -803,13 +803,32 @@ var DOM = Class("DOM", {
|
||||
if (isObject(event))
|
||||
capture = listener;
|
||||
else
|
||||
event = array.toObject([[key, val]]);
|
||||
event = array.toObject([[event, listener]]);
|
||||
|
||||
return this.each(function (elem) {
|
||||
for (let [k, v] in Iterator(event))
|
||||
elem.removeEventListener(k, v.wrapper || v, capture);
|
||||
});
|
||||
},
|
||||
once: function once(event, listener, capture) {
|
||||
if (isObject(event))
|
||||
capture = listener;
|
||||
else
|
||||
event = array.toObject([[event, listener]]);
|
||||
|
||||
for (let pair in Iterator(event)) {
|
||||
let [evt, callback] = pair;
|
||||
event[evt] = util.wrapCallback(function wrapper(event) {
|
||||
this.removeEventListener(evt, wrapper.wrapper, capture);
|
||||
return callback.apply(this, arguments);
|
||||
}, true);
|
||||
}
|
||||
|
||||
return this.each(function (elem) {
|
||||
for (let [k, v] in Iterator(event))
|
||||
elem.addEventListener(k, v, capture);
|
||||
});
|
||||
},
|
||||
|
||||
dispatch: function dispatch(event, params, extraProps) {
|
||||
this.canceled = false;
|
||||
|
||||
@@ -55,7 +55,7 @@ var JavaScript = Module("javascript", {
|
||||
|
||||
newContext: function () this.modules.newContext(this.modules.userContext, true),
|
||||
|
||||
get completers() JavaScript.completers, // For backward compatibility
|
||||
completers: Class.Memoize(function () Object.create(JavaScript.completers)),
|
||||
|
||||
// Some object members are only accessible as function calls
|
||||
getKey: function (obj, key) {
|
||||
@@ -550,7 +550,7 @@ var JavaScript = Module("javascript", {
|
||||
}
|
||||
catch (e) {}
|
||||
if (!completer)
|
||||
completer = JavaScript.completers[funcName];
|
||||
completer = this.completers[funcName];
|
||||
if (!completer)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -710,6 +710,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
* responseType: {string} Override the type of the "response"
|
||||
* property.
|
||||
*
|
||||
* headers: {objects} Extra request headers.
|
||||
*
|
||||
* user: {string} The user name to send via HTTP Authentication.
|
||||
* pass: {string} The password to send via HTTP Authentication.
|
||||
*
|
||||
@@ -749,12 +751,18 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
params.data = data;
|
||||
}
|
||||
|
||||
|
||||
if (params.mimeType)
|
||||
xmlhttp.overrideMimeType(params.mimeType);
|
||||
|
||||
xmlhttp.open(params.method || "GET", url, async,
|
||||
params.user, params.pass);
|
||||
let args = [params.method || "GET", url, async];
|
||||
if (params.user != null || params.pass != null)
|
||||
args.push(params.user);
|
||||
if (params.pass != null)
|
||||
args.push(prams.pass);
|
||||
xmlhttp.open.apply(xmlhttp, args);
|
||||
|
||||
for (let [header, val] in Iterator(params.headers || {}))
|
||||
xmlhttp.setRequestHeader(header, val);
|
||||
|
||||
if (params.responseType)
|
||||
xmlhttp.responseType = params.responseType;
|
||||
|
||||
Reference in New Issue
Block a user