Add custom browser checks outside of Modernizr

This commit is contained in:
Michael Telatynski 2020-02-04 11:08:52 +00:00
parent bceca49cdc
commit cdc1202bbe

View File

@ -54,6 +54,19 @@ import CallHandler from 'matrix-react-sdk/src/CallHandler';
let lastLocationHashSet = null;
function checkBrowserFeatures(featureList) {
// custom checks atop Modernizr because it doesn't have ES2018/ES2019 checks in it for some features we depend on:
// ran prior to Modernizr so the missing features are logged even if Modernizr is broken
// ES2018: http://www.ecma-international.org/ecma-262/9.0/#sec-promise.prototype.finally
if (typeof Promise.prototype.finally !== "function") {
console.error("Browser missing feature: Promise.prototype.finally");
featureComplete = false;
}
// ES2019: http://www.ecma-international.org/ecma-262/10.0/#sec-object.fromentries
if (typeof Object.fromEntries !== "function") {
console.error("Browser missing feature: Object.fromEntries");
featureComplete = false;
}
if (!window.Modernizr) {
console.error("Cannot check features - Modernizr global is missing.");
return false;
@ -69,11 +82,11 @@ function checkBrowserFeatures(featureList) {
}
if (window.Modernizr[featureList[i]] === false) {
console.error("Browser missing feature: '%s'", featureList[i]);
// toggle flag rather than return early so we log all missing features
// rather than just the first.
// toggle flag rather than return early so we log all missing features rather than just the first.
featureComplete = false;
}
}
return featureComplete;
}