-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rename forwardEventToHost to forwardEvent
- Loading branch information
1 parent
5a6f71a
commit 053e699
Showing
9 changed files
with
30 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
/** | ||
* Forwards an event to the host element provided. | ||
* This way, an event triggered in the ShadowDOM can cross its boundary and can be listened on the host component. | ||
* Forwards an event to the element provided. | ||
* This way, an event triggered in the Shadow DOM can cross its boundary and can be listened on e.g. the host component. | ||
*/ | ||
export function forwardEventToHost(event: Event, host: HTMLElement | Document): void { | ||
export function forwardEvent(event: Event, element: HTMLElement | Document): void { | ||
const eventConstructor = Object.getPrototypeOf(event).constructor; | ||
const copiedEvent: Event = new eventConstructor(event.type, event); | ||
host.dispatchEvent(copiedEvent); | ||
element.dispatchEvent(copiedEvent); | ||
} | ||
|
||
/** | ||
* Forwards an event to the host element provided. | ||
* This way, an event triggered in the ShadowDOM can cross its boundary and can be listened on the host component. | ||
* @deprecated will be removed with next major version, use forwardEvent as alternative | ||
*/ | ||
export const forwardEventToHost = forwardEvent; |
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
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