devtools-modules
Advanced tools
Comparing version 1.1.1 to 1.1.2
{ | ||
"name": "devtools-modules", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "DevTools Modules from M-C", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -47,2 +47,7 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
// Copied from m-c DevToolsUtils. | ||
function getTopWindow(win) { | ||
return win.windowRoot ? win.windowRoot.ownerGlobal : win.top; | ||
} | ||
/** | ||
@@ -99,7 +104,12 @@ * A partial implementation of the Menu API provided by electron: | ||
* @param {int} screenY | ||
* @param Toolbox toolbox (non standard) | ||
* Needed so we in which window to inject XUL | ||
* @param {Document} doc | ||
* The document that should own the context menu. | ||
*/ | ||
Menu.prototype.popup = function (screenX, screenY, toolbox) { | ||
let doc = toolbox.doc; | ||
Menu.prototype.popup = function (screenX, screenY, doc) { | ||
// The context-menu will be created in the topmost window to preserve keyboard | ||
// navigation. See Bug 1543940. Keep a reference on the window owning the menu to hide | ||
// the popup on unload. | ||
const win = doc.defaultView; | ||
doc = getTopWindow(doc.defaultView).document; | ||
let popupset = doc.querySelector("popupset"); | ||
@@ -127,5 +137,11 @@ if (!popupset) { | ||
// The context menu will be created in the topmost chrome window. Hide it manually when | ||
// the owner document is unloaded. | ||
const onWindowUnload = () => popup.hidePopup(); | ||
win.addEventListener("unload", onWindowUnload); | ||
// Remove the menu from the DOM once it's hidden. | ||
popup.addEventListener("popuphidden", (e) => { | ||
if (e.target === popup) { | ||
win.removeEventListener("unload", onWindowUnload); | ||
popup.remove(); | ||
@@ -132,0 +148,0 @@ this.emit("close", popup); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
121881
3027
112