fix: switch to native :focus-visible for firefox 88+ (#2039)
This commit is contained in:
parent
f9ac31465d
commit
3971f9a636
|
@ -1,7 +1,7 @@
|
||||||
import { thunk } from './thunk'
|
import { thunk } from './thunk'
|
||||||
import { supportsSelector } from './supportsSelector'
|
import { supportsSelector } from './supportsSelector'
|
||||||
import { isFirefox } from './userAgent/isFirefox'
|
import { isFirefoxPre88 } from './userAgent/isFirefoxPre88'
|
||||||
|
|
||||||
// TODO: remove the Firefox check once this bug is fixed
|
// Firefox pre-88 had a focus-visible bug:
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1699154
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1699154
|
||||||
export const supportsFocusVisible = thunk(() => (!isFirefox() && supportsSelector(':focus-visible')))
|
export const supportsFocusVisible = thunk(() => (!isFirefoxPre88() && supportsSelector(':focus-visible')))
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
export function isFirefox () {
|
import { thunk } from '../thunk'
|
||||||
return typeof InstallTrigger !== 'undefined' // https://stackoverflow.com/a/9851769/680742
|
|
||||||
}
|
export const isFirefox = thunk(() => {
|
||||||
|
return process.browser && typeof InstallTrigger !== 'undefined' // https://stackoverflow.com/a/9851769/680742
|
||||||
|
})
|
||||||
|
|
17
src/routes/_utils/userAgent/isFirefoxPre88.js
Normal file
17
src/routes/_utils/userAgent/isFirefoxPre88.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import { isFirefox } from './isFirefox'
|
||||||
|
import { thunk } from '../thunk'
|
||||||
|
|
||||||
|
export const isFirefoxPre88 = thunk(() => {
|
||||||
|
if (!isFirefox()) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/88#javascript
|
||||||
|
// https://github.com/tc39/proposal-regexp-match-indices
|
||||||
|
// eslint-disable-next-line no-invalid-regexp,prefer-regex-literals
|
||||||
|
RegExp('', 'd')
|
||||||
|
return false
|
||||||
|
} catch (e) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
Loading…
Reference in a new issue