Skip to content

Commit cdc1202

Browse files
committed
Add custom browser checks outside of Modernizr
1 parent bceca49 commit cdc1202

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

‎src/vector/app.js‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ import CallHandler from 'matrix-react-sdk/src/CallHandler';
5454
let lastLocationHashSet = null;
5555

5656
function checkBrowserFeatures(featureList) {
57+
// custom checks atop Modernizr because it doesn't have ES2018/ES2019 checks in it for some features we depend on:
58+
// ran prior to Modernizr so the missing features are logged even if Modernizr is broken
59+
// ES2018: http://www.ecma-international.org/ecma-262/9.0/#sec-promise.prototype.finally
60+
if (typeof Promise.prototype.finally !== "function") {
61+
console.error("Browser missing feature: Promise.prototype.finally");
62+
featureComplete = false;
63+
}
64+
// ES2019: http://www.ecma-international.org/ecma-262/10.0/#sec-object.fromentries
65+
if (typeof Object.fromEntries !== "function") {
66+
console.error("Browser missing feature: Object.fromEntries");
67+
featureComplete = false;
68+
}
69+
5770
if (!window.Modernizr) {
5871
console.error("Cannot check features - Modernizr global is missing.");
5972
return false;
@@ -69,11 +82,11 @@ function checkBrowserFeatures(featureList) {
6982
}
7083
if (window.Modernizr[featureList[i]] === false) {
7184
console.error("Browser missing feature: '%s'", featureList[i]);
72-
// toggle flag rather than return early so we log all missing features
73-
// rather than just the first.
85+
// toggle flag rather than return early so we log all missing features rather than just the first.
7486
featureComplete = false;
7587
}
7688
}
89+
7790
return featureComplete;
7891
}
7992

0 commit comments

Comments
 (0)