-
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.
fix: handle scroll events in custom scroll contexts
- Loading branch information
1 parent
fd55843
commit 0a8415a
Showing
20 changed files
with
129 additions
and
119 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
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): 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
Oops, something went wrong.