Created
January 23, 2024 11:35
-
-
Save simenbrekken-visma/0f5385d8b21429ae84c2c11f75620e2a to your computer and use it in GitHub Desktop.
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
/** | |
* Redispatch event with composed flag to propagate it through the shadow DOM. | |
* | |
* @see https://developer.mozilla.org/en-US/docs/Web/API/Event/composed | |
*/ | |
function redispatchComposedEvent(event: Event) { | |
event.stopPropagation(); | |
const composedEvent = new Event(event.type, { | |
bubbles: event.bubbles, | |
cancelable: event.cancelable, | |
composed: true, | |
}); | |
event.target.dispatchEvent(composedEvent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment