Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Tolerate multiple imports/loads of the script #245

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

maranomynet
Copy link

It may come up that multiple scripts import or load the polyfill into the same document.

In such cases we want to ensure the polyfill only runs once.

It may come up that multiple scripts import or load the polyfill into the same document.

In such cases we want to ensure the polyfill only runs once.
Comment on lines -298 to -300
}

if (typeof document !== 'undefined') {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming these conditional blocks can be safely joined, for simplicity+brevity

@@ -276,7 +276,7 @@ function applyFocusVisiblePolyfill(scope) {
// It is important to wrap all references to global window and document in
// these checks to support server-side rendering use cases
// @see https://github.com/WICG/focus-visible/issues/199
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
if (typeof window !== 'undefined' && typeof document !== 'undefined' && !window.applyFocusVisiblePolyfill) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking for applyFocusVisiblePolyfill is sufficiently safe as the function is always run right after it's assignment into the global Window scope

@yoavweiss
Copy link
Contributor

@maranomynet - can you join the WICG to appease the IPR bots?

@maranomynet
Copy link
Author

maranomynet commented Nov 5, 2020

I've ventured down that rabbit hole of bad onboarding UX, and emerged mostly unscathed.

  • IPR bots appeased

@yoavweiss yoavweiss changed the base branch from master to main March 5, 2021 21:37
@maranomynet
Copy link
Author

Any chance of seeing this merged?

@maranomynet
Copy link
Author

I can't believe it's been three years already. Time flies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants