Skip to content

Commit 7d49078

Browse files
committed
Change them to Modernizr tests and add more rules
1 parent 032efaf commit 7d49078

3 files changed

Lines changed: 26 additions & 21 deletions

File tree

‎.modernizr.json‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
"test/css/objectfit",
1212
"test/storage/localstorage",
1313
"test/workers/webworkers",
14-
"test/indexeddb"
14+
"test/indexeddb",
15+
"test/es6/array",
16+
"test/es6/collections",
17+
"test/es6/promises",
18+
"test/serviceworker",
19+
"test/svg",
20+
"test/svg/asimg",
21+
"test/svg/filters",
22+
"test/css/animations",
23+
"test/css/filters",
24+
"test/network/fetch"
1525
]
1626
}

‎src/vector/app.js‎

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,23 @@ import CallHandler from 'matrix-react-sdk/src/CallHandler';
5353

5454
let lastLocationHashSet = null;
5555

56-
function checkBrowserFeatures(featureList) {
56+
function checkBrowserFeatures() {
5757
if (!window.Modernizr) {
5858
console.error("Cannot check features - Modernizr global is missing.");
5959
return false;
6060
}
6161

62+
// custom checks atop Modernizr because it doesn't have ES2018/ES2019 checks in it for some features we depend on,
63+
// Modernizr requires rules to be lowercase with no punctuation:
64+
// ES2018: http://www.ecma-international.org/ecma-262/9.0/#sec-promise.prototype.finally
65+
window.Modernizr.addTest("promiseprototypefinally", () =>
66+
window.Promise && window.Promise.prototype && typeof window.Promise.prototype.finally === "function");
67+
// ES2019: http://www.ecma-international.org/ecma-262/10.0/#sec-object.fromentries
68+
window.Modernizr.addTest("objectfromentries", () =>
69+
window.Object && typeof window.Object.fromEntries === "function");
70+
71+
const featureList = Object.keys(window.Modernizr);
72+
6273
let featureComplete = true;
6374
for (let i = 0; i < featureList.length; i++) {
6475
if (window.Modernizr[featureList[i]] === undefined) {
@@ -74,19 +85,6 @@ function checkBrowserFeatures(featureList) {
7485
featureComplete = false;
7586
}
7687
}
77-
78-
// custom checks atop Modernizr because it doesn't have ES2018/ES2019 checks in it for some features we depend on:
79-
// ES2018: http://www.ecma-international.org/ecma-262/9.0/#sec-promise.prototype.finally
80-
if (!Promise || !Promise.prototype || typeof Promise.prototype.finally !== "function") {
81-
console.error("Browser missing feature: Promise.prototype.finally");
82-
featureComplete = false;
83-
}
84-
// ES2019: http://www.ecma-international.org/ecma-262/10.0/#sec-object.fromentries
85-
if (!Object || typeof Object.fromEntries !== "function") {
86-
console.error("Browser missing feature: Object.fromEntries");
87-
featureComplete = false;
88-
}
89-
9088
return featureComplete;
9189
}
9290

@@ -273,10 +271,7 @@ export async function loadApp() {
273271
return;
274272
}
275273

276-
const validBrowser = checkBrowserFeatures([
277-
"displaytable", "flexbox", "es5object", "es5function", "localstorage",
278-
"objectfit", "indexeddb", "webworkers",
279-
]);
274+
const validBrowser = checkBrowserFeatures();
280275

281276
const acceptInvalidBrowser = window.localStorage && window.localStorage.getItem('mx_accepts_unsupported_browser');
282277

0 commit comments

Comments
 (0)