Created
October 16, 2017 18:39
-
-
Save bgrins/da00d9c90c89d652e2881362ca8a92b0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Doesn't bubble to parentNode, but does fire on gBrowser (the bindingParent for gBrowser.selectedBrowser) | |
gBrowser.addEventListener("bar", () => { console.log("No explicit bubbling, but bubbled to gBrowser") }); | |
gBrowser.selectedBrowser.parentNode.addEventListener("bar", () => { console.log("No explicit bubbling, did not bubble to parentNode") }); | |
gBrowser.selectedBrowser.dispatchEvent(new CustomEvent("bar")); | |
// If you tell the CustomEvent to bubble, then it does bubble to the parentNode (and gBrowser): | |
gBrowser.addEventListener("bar", () => { console.log("Explicit bubbling, did bubble to gBrowser") }); | |
gBrowser.selectedBrowser.parentNode.addEventListener("bar", () => { console.log("Explicit bubbling, did bubble to parentNode") }); | |
gBrowser.selectedBrowser.dispatchEvent(new CustomEvent("bar", { bubbles: true })); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment