-
Notifications
You must be signed in to change notification settings - Fork 124
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
Don't enable polyfill if browser supports ":focus-visible" #237
Comments
Drive by, but that's a really really expensive way to test for a pseudo-element. |
I’m afraid this requires double your style declarations for |
Yeap, that will require a double style declaration. But on the other hand, when browsers start to support his feature (Chrome is going to start supporting it from v.86), no js run will be needed. Currently, polyfill does a lot of background work that isn't good for performance. |
Very good points from everyone. It sounds like if we land this then we should use @emilio's implementation, but also land a note in the README which explains the need to double up your style declarations. We could also add a note that if folks would prefer, they can use the postcss plugin (https://github.com/csstools/postcss-focus-visible) which I think will let them write their CSS using |
Related to #244 This condition could help if (!window.CSS?.supports?.("selector(:focus-visible)")) {
// Apply the polyfill
} |
Currently Chrome with experimental flag enabled supports ":focus-visible" polyfill. It would be nice if polyfill could be enabled only if current browser doesn' support ":focus-visible".
To do that, I propose to check pseudo-class support using this method:
And then in polyfill modify code on the line 306 with:
After that we will be able to write css rules for both native ":focus-visible" and polyfill version:
The text was updated successfully, but these errors were encountered: