mirror of
https://github.com/discourse/discourse.git
synced 2025-06-15 18:01:33 +08:00
FIX: Detect firefox < 89 as an unsupported browser (#17443)
Prior to v89, Firefox has bugs with document.execCommand("insertText"): https://bugzil.la/1220696 This commit introduces some variables to browser-detect, and therefore wraps the entire logic in an IIFE to avoid state leaking. (`let`/`const` are not supported on older browsers)
This commit is contained in:
@ -1,6 +1,9 @@
|
|||||||
if (!window.WeakMap || !window.Promise || typeof globalThis === "undefined") {
|
/* eslint-disable no-var */ // `let` is not supported in very old browsers
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
if (!window.WeakMap || !window.Promise || typeof globalThis === "undefined") {
|
||||||
window.unsupportedBrowser = true;
|
window.unsupportedBrowser = true;
|
||||||
} else {
|
} else {
|
||||||
// Some implementations of `WeakMap.prototype.has` do not accept false
|
// Some implementations of `WeakMap.prototype.has` do not accept false
|
||||||
// values and Ember's `isClassicDecorator` sometimes does that (it only
|
// values and Ember's `isClassicDecorator` sometimes does that (it only
|
||||||
// checks for `null` and `undefined`).
|
// checks for `null` and `undefined`).
|
||||||
@ -9,4 +12,13 @@ if (!window.WeakMap || !window.Promise || typeof globalThis === "undefined") {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
window.unsupportedBrowser = true;
|
window.unsupportedBrowser = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
var match = window.navigator.userAgent.match(/Firefox\/([0-9]+)\./);
|
||||||
|
var firefoxVersion = match ? parseInt(match[1], 10) : null;
|
||||||
|
if (firefoxVersion && firefoxVersion < 89) {
|
||||||
|
// prior to v89, Firefox has bugs with document.execCommand("insertText")
|
||||||
|
// https://bugzil.la/1220696
|
||||||
|
window.unsupportedBrowser = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
Reference in New Issue
Block a user