Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #2838, unload uicontrol event handlers properly (#2942)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianb authored and jaredhirsch committed May 31, 2017
1 parent 4c7850a commit 2d064b7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions addon/webextension/selector/uicontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ this.uicontrol = (function() {
ui.Box.remove();
const handler = watchFunction(assertIsTrusted(keyupHandler));
document.addEventListener("keyup", handler);
registeredDocumentHandlers.push({name: "keyup", doc: document, handler});
registeredDocumentHandlers.push({name: "keyup", doc: document, handler, useCapture: false});
}));
},

Expand Down Expand Up @@ -874,15 +874,21 @@ this.uicontrol = (function() {
window.addEventListener('beforeunload', beforeunloadHandler);
}

let mousedownSetOnDocument = false;

function installHandlersOnDocument(docObj) {
for (let [eventName, handler] of primedDocumentHandlers) {
let watchHandler = watchFunction(handler);
docObj.addEventListener(eventName, watchHandler, eventName !== "keyup");
registeredDocumentHandlers.push({name: eventName, doc: docObj, watchHandler});
let useCapture = eventName !== "keyup";
docObj.addEventListener(eventName, watchHandler, useCapture);
registeredDocumentHandlers.push({name: eventName, doc: docObj, handler: watchHandler, useCapture});
}
if (!mousedownSetOnDocument) {
let mousedownHandler = primedDocumentHandlers.get("mousedown");
document.addEventListener("mousedown", mousedownHandler, true);
registeredDocumentHandlers.push({name: "mousedown", doc: document, handler: mousedownHandler, useCapture: true});
mousedownSetOnDocument = true;
}
let mousedownHandler = primedDocumentHandlers.get("mousedown");
document.addEventListener("mousedown", mousedownHandler, true);
registeredDocumentHandlers.push({name: "mousedown", doc: document, watchHandler: mousedownHandler, useCapture: true});
}

function beforeunloadHandler() {
Expand Down

0 comments on commit 2d064b7

Please sign in to comment.