From d30f7f4b1ac9b46044222a065e4633f1ab76de1d Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Fri, 16 Jul 2021 07:14:15 -0700 Subject: [PATCH] fix: enable focus-visible in Firefox 90 (#2075) --- src/routes/_utils/supportsFocusVisible.js | 6 +++--- src/routes/_utils/userAgent/isFirefox.js | 5 ----- src/routes/_utils/userAgent/isFirefoxPre90.js | 9 +++++++++ 3 files changed, 12 insertions(+), 8 deletions(-) delete mode 100644 src/routes/_utils/userAgent/isFirefox.js create mode 100644 src/routes/_utils/userAgent/isFirefoxPre90.js diff --git a/src/routes/_utils/supportsFocusVisible.js b/src/routes/_utils/supportsFocusVisible.js index fa99878b..005598a7 100644 --- a/src/routes/_utils/supportsFocusVisible.js +++ b/src/routes/_utils/supportsFocusVisible.js @@ -1,8 +1,8 @@ import { thunk } from './thunk.js' import { supportsSelector } from './supportsSelector.js' -import { isFirefox } from './userAgent/isFirefox.js' +import { isFirefoxPre90 } from './userAgent/isFirefoxPre90.js' -// Disabling for now in Firefox due to bugs: +// Disabling in Firefox <90 due to bugs: // https://bugzilla.mozilla.org/show_bug.cgi?id=1699154 // https://bugzilla.mozilla.org/show_bug.cgi?id=1711057 -export const supportsFocusVisible = thunk(() => (!isFirefox() && supportsSelector(':focus-visible'))) +export const supportsFocusVisible = thunk(() => (!isFirefoxPre90() && supportsSelector(':focus-visible'))) diff --git a/src/routes/_utils/userAgent/isFirefox.js b/src/routes/_utils/userAgent/isFirefox.js deleted file mode 100644 index 4fe8745b..00000000 --- a/src/routes/_utils/userAgent/isFirefox.js +++ /dev/null @@ -1,5 +0,0 @@ -import { thunk } from '../thunk.js' - -export const isFirefox = thunk(() => { - return process.browser && typeof InstallTrigger !== 'undefined' // https://stackoverflow.com/a/9851769/680742 -}) diff --git a/src/routes/_utils/userAgent/isFirefoxPre90.js b/src/routes/_utils/userAgent/isFirefoxPre90.js new file mode 100644 index 00000000..b6457191 --- /dev/null +++ b/src/routes/_utils/userAgent/isFirefoxPre90.js @@ -0,0 +1,9 @@ +import { thunk } from '../thunk.js' + +export const isFirefoxPre90 = thunk(() => { + return process.browser && + // https://stackoverflow.com/a/9851769/680742 + typeof InstallTrigger !== 'undefined' && + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at#browser_compatibility + !Array.prototype.at +})