mirror of
https://github.com/tridactyl/tridactyl.git
synced 2026-09-10 07:16:33 -04:00
Merge pull request #5260 from Chic-Tweetz/cmdline-check-isconnected
Reinsert the iframe if it's removed before document.readyState "complete"
This commit is contained in:
commit
5b278be67e
|
|
@ -267,6 +267,7 @@ if (
|
|||
}
|
||||
|
||||
// Really bad status indicator
|
||||
let statusIndicator
|
||||
config.getAsync("modeindicator").then(mode => {
|
||||
if (mode !== "true") return
|
||||
|
||||
|
|
@ -284,7 +285,7 @@ config.getAsync("modeindicator").then(mode => {
|
|||
}
|
||||
}`
|
||||
|
||||
const statusIndicator = document.createElement("span")
|
||||
statusIndicator = document.createElement("span")
|
||||
const privateMode = browser.extension.inIncognitoContext
|
||||
? "TridactylPrivate"
|
||||
: ""
|
||||
|
|
@ -315,7 +316,7 @@ config.getAsync("modeindicator").then(mode => {
|
|||
|
||||
// This listener makes the modeindicator disappear when the mouse goes over it
|
||||
statusIndicator.addEventListener("mouseenter", ev => {
|
||||
const target = ev.target as any
|
||||
const target = ev.target
|
||||
const rect = target.getBoundingClientRect()
|
||||
target.classList.add("TridactylInvisible")
|
||||
const onMouseOut = ev => {
|
||||
|
|
@ -468,6 +469,20 @@ document.addEventListener("selectionchange", () => {
|
|||
}
|
||||
})
|
||||
|
||||
// Try to catch the iframe/status indicator being removed by a script (React again)
|
||||
const checkElemsSurvived = () => {
|
||||
if (document.readyState === "complete") {
|
||||
commandline_content.ensureIframeExists()
|
||||
|
||||
if (statusIndicator !== undefined)
|
||||
document.body.appendChild(statusIndicator)
|
||||
|
||||
// We only want to check the iframe survived between "interactive" and "complete"
|
||||
document.removeEventListener("readystatechange", checkElemsSurvived)
|
||||
}
|
||||
}
|
||||
document.addEventListener("readystatechange", checkElemsSurvived)
|
||||
|
||||
// Listen for statistics from each content script and send them to the
|
||||
// background for collection. Attach the observer to the window object
|
||||
// since there's apparently a bug that causes performance observers to
|
||||
|
|
|
|||
|
|
@ -99,6 +99,12 @@ init().catch(() => {
|
|||
)
|
||||
})
|
||||
|
||||
export function ensureIframeExists() {
|
||||
if (cmdline_iframe && !cmdline_iframe.isConnected) {
|
||||
document.documentElement.appendChild(cmdline_iframe)
|
||||
}
|
||||
}
|
||||
|
||||
export function show(hidehover = false) {
|
||||
try {
|
||||
/* Hide "hoverlink" pop-up which obscures command line
|
||||
|
|
@ -114,6 +120,7 @@ export function show(hidehover = false) {
|
|||
document.body.removeChild(a)
|
||||
}
|
||||
|
||||
ensureIframeExists()
|
||||
cmdline_iframe.inert = false;
|
||||
cmdline_iframe.classList.remove("hidden")
|
||||
const height =
|
||||
|
|
@ -156,7 +163,7 @@ export function hide_and_blur() {
|
|||
|
||||
export function executeWithoutCommandLine(fn) {
|
||||
let parent
|
||||
if (cmdline_iframe) {
|
||||
if (cmdline_iframe && cmdline_iframe.isConnected) {
|
||||
parent = cmdline_iframe.parentNode
|
||||
parent.removeChild(cmdline_iframe)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue