fix: switch to native :focus-visible for firefox 88+ (#2039)

update-lod
Nolan Lawson 2021-05-11 21:40:40 -07:00 zatwierdzone przez GitHub
rodzic f9ac31465d
commit 3971f9a636
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 25 dodań i 6 usunięć

Wyświetl plik

@ -1,7 +1,7 @@
import { thunk } from './thunk'
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
export const supportsFocusVisible = thunk(() => (!isFirefox() && supportsSelector(':focus-visible')))
export const supportsFocusVisible = thunk(() => (!isFirefoxPre88() && supportsSelector(':focus-visible')))

Wyświetl plik

@ -1,3 +1,5 @@
export function isFirefox () {
return typeof InstallTrigger !== 'undefined' // https://stackoverflow.com/a/9851769/680742
}
import { thunk } from '../thunk'
export const isFirefox = thunk(() => {
return process.browser && typeof InstallTrigger !== 'undefined' // https://stackoverflow.com/a/9851769/680742
})

Wyświetl plik

@ -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
}
})