Bug 1198235 - abuse of bind(this) with add/removeEventListener in downloads.js. r=mak

This commit is contained in:
Nazim Can Altinova 2015-08-31 14:04:00 +02:00
Родитель 5286a5716f
Коммит 5483bf7f34
1 изменённых файлов: 12 добавлений и 8 удалений

Просмотреть файл

@ -287,8 +287,14 @@ const DownloadsPanel = {
* visualization.
*/
handleEvent(aEvent) {
if (aEvent.type == "mousemove") {
this.keyFocusing = false;
switch (aEvent.type) {
case "mousemove":
this.keyFocusing = false;
break;
case "keydown":
return this._onKeyDown(aEvent);
case "keypress":
return this._onKeyPress(aEvent);
}
},
@ -378,10 +384,10 @@ const DownloadsPanel = {
*/
_attachEventListeners() {
// Handle keydown to support accel-V.
this.panel.addEventListener("keydown", this._onKeyDown.bind(this), false);
this.panel.addEventListener("keydown", this, false);
// Handle keypress to be able to preventDefault() events before they reach
// the richlistbox, for keyboard navigation.
this.panel.addEventListener("keypress", this._onKeyPress.bind(this), false);
this.panel.addEventListener("keypress", this, false);
},
/**
@ -389,10 +395,8 @@ const DownloadsPanel = {
* is called automatically on panel termination.
*/
_unattachEventListeners() {
this.panel.removeEventListener("keydown", this._onKeyDown.bind(this),
false);
this.panel.removeEventListener("keypress", this._onKeyPress.bind(this),
false);
this.panel.removeEventListener("keydown", this, false);
this.panel.removeEventListener("keypress", this, false);
},
_onKeyPress(aEvent) {