Skip to content

Instantly share code, notes, and snippets.

@bgrins
Created October 16, 2017 18:39
Show Gist options
  • Save bgrins/da00d9c90c89d652e2881362ca8a92b0 to your computer and use it in GitHub Desktop.
Save bgrins/da00d9c90c89d652e2881362ca8a92b0 to your computer and use it in GitHub Desktop.
// 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