forked from glacambre/firenvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix firenvim on pages that remove its spans
Some pages (e.g. Jira) remove the span when they're created. This resulted in two issues: - Either the Firenvim element was never initialized (because its frame didn't have enough time to register with the background script and propagate its frame id). This resulted in the frameIdPromise timeout being triggered. This is fixed by re-appending the frame to the page until it gets a frameId or the span has been re-appended X times and firenvim gives up and logs an error. - Or the Firenvim element was initialized and when the corresponding textarea was focused, the Firenvim element that didn't exist in the page got focused instead of creating a new firenvim element. This is fixed by killing the firenvim element (because its websocket is broken when the iframe disappears from the page) that doesn't exist in the page and creating a new one. Should help with glacambre#323
- Loading branch information
Showing
6 changed files
with
169 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!doctype html> | ||
<html lang="en" id="html"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Test Page</title> | ||
<script> | ||
window.addEventListener("load", () => { | ||
const observer = new MutationObserver((mutations, observer) => { | ||
let removed = false; | ||
for (const mutation of mutations) { | ||
for (let node of mutation.addedNodes) { | ||
node.remove(); | ||
removed = true; | ||
} | ||
} | ||
if (removed) { | ||
observer.disconnect(); | ||
} | ||
}); | ||
observer.observe(document.body, { childList: true, subtree: true }); | ||
}); | ||
</script> | ||
</head> | ||
<body id="body"> | ||
<textarea id="content-input" rows="20" cols="80"></textarea> | ||
</body> | ||
</html> |