-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
FocusTrap
event listeners once document has loaded (#2389)
* feat: addEventListener on document loaded * Refactor * Fix import * Update changelog * use function instead of arrow function * make callback in `onDocumentReady` mandatory --------- Co-authored-by: lkr <lkr@bytedance.com> Co-authored-by: Jordan Pittman <jordan@cryptica.me> Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
- Loading branch information
1 parent
d55c77e
commit d0888b0
Showing
6 changed files
with
32 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export function onDocumentReady(cb: () => void) { | ||
function check() { | ||
if (document.readyState === 'loading') return | ||
cb() | ||
document.removeEventListener('DOMContentLoaded', check) | ||
} | ||
|
||
if (typeof window !== 'undefined' && typeof document !== 'undefined') { | ||
document.addEventListener('DOMContentLoaded', check) | ||
check() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export function onDocumentReady(cb: () => void) { | ||
function check() { | ||
if (document.readyState === 'loading') return | ||
cb() | ||
document.removeEventListener('DOMContentLoaded', check) | ||
} | ||
|
||
if (typeof window !== 'undefined' && typeof document !== 'undefined') { | ||
document.addEventListener('DOMContentLoaded', check) | ||
check() | ||
} | ||
} |