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

Fix #2838, unload uicontrol event handlers properly #2942

Merged
merged 1 commit into from
May 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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