Skip to content

Commit f76ef74

Browse files
committed
fix(browser-check): disable es2020 syntax probes
1 parent 8ea6098 commit f76ef74

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

‎public/browser-check.js‎

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*
88
* Required features (determined from caniuse-lite against the app's CSS/JS):
99
* CSS Grid, CSS Custom Properties, position:sticky (or -webkit-sticky)
10-
* ES2020 syntax used by the bundle, currently optional chaining and nullish coalescing
1110
*
1211
* Chromium version is still checked via UA for WebView2 on Windows, where the
1312
* version string is accurate and ES module support (Chrome 61+) is the constraint.
@@ -16,15 +15,6 @@
1615
var unsupported = false;
1716
var body = '';
1817

19-
function canParse(source) {
20-
try {
21-
new Function(source);
22-
return true;
23-
} catch (e) {
24-
return false;
25-
}
26-
}
27-
2818
/* CSS feature detection -------------------------------------------------- */
2919
if (typeof CSS === 'undefined' || !CSS.supports) {
3020
unsupported = true;
@@ -42,15 +32,30 @@
4232
}
4333
}
4434

45-
if (!unsupported) {
46-
var missingJs = [];
47-
if (!canParse('var value = ({ a: 1 })?.a;')) missingJs.push('optional chaining');
48-
if (!canParse('var value = null ?? 1;')) missingJs.push('nullish coalescing');
49-
if (missingJs.length > 0) {
50-
unsupported = true;
51-
body = 'Missing required JavaScript features: <strong style="color:#e2e4eb;">' + missingJs.join(', ') + '</strong>.';
52-
}
53-
}
35+
/*
36+
* ES2020 syntax probes are disabled for now. Tauri's CSP can block
37+
* Function() even when the webview supports the syntax, which makes this
38+
* check report a false unsupported browser.
39+
*
40+
* function canParse(source) {
41+
* try {
42+
* new Function(source);
43+
* return true;
44+
* } catch (e) {
45+
* return false;
46+
* }
47+
* }
48+
*
49+
* if (!unsupported) {
50+
* var missingJs = [];
51+
* if (!canParse('var value = ({ a: 1 })?.a;')) missingJs.push('optional chaining');
52+
* if (!canParse('var value = null ?? 1;')) missingJs.push('nullish coalescing');
53+
* if (missingJs.length > 0) {
54+
* unsupported = true;
55+
* body = 'Missing required JavaScript features: <strong style="color:#e2e4eb;">' + missingJs.join(', ') + '</strong>.';
56+
* }
57+
* }
58+
*/
5459

5560
/* Chromium version check (WebView2 on Windows only) ---------------------- */
5661
if (!unsupported) {

0 commit comments

Comments
 (0)