Skip to content

Commit ffaab44

Browse files
authored
Merge pull request #368 from fs-webdev/rileytb/outdated_browser_feature_update
prevent private field feature check from just erroring out
2 parents fe25cc3 + 5e017e9 commit ffaab44

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

CHANGELOG-FRONTIER.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 8.7.11
2+
3+
- Feature detection for private class fields was erroring out before running the check, now it will be within `eval` so it will run even if the browser doesn't support it.
4+
15
## 8.7.10
26

37
- Have jest configuration use browser-resolve for requires in splitio packages. Only affects jest tests, nothing else.

packages/react-scripts/layout/views/partials/featureDetection.ejs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
if (Modernizr) {
22
const unsupportedBrowserHeader = document.getElementById('unsupported-browser');
33

4+
<%# Handles Chrome/Edge v84 and lower %>
45
Modernizr.addTest('replaceAll', () => {
56
return typeof String.prototype.replaceAll === 'function';
67
});
78

9+
<%# Handles Firefox v90/Safari v15 and lower %>
10+
<%# Written with eval because declaring a function with private class fields threw an error outside of the catch %>
811
Modernizr.addTest('privateFields', () => {
912
try {
10-
class Test {
11-
#privateField = 42;
12-
getPrivateField() {
13-
return this.#privateField;
14-
}
15-
}
16-
17-
const instance = new Test();
18-
return instance.getPrivateField() === 42;
13+
eval("class Test { #privateField; }");
14+
return true;
1915
} catch (e) {
20-
return false;
16+
return false;
2117
}
2218
});
2319
24-
const outdatedFeatures = Object.keys(Modernizr).filter(feature => !Modernizr[feature]);
25-
2620
if (unsupportedBrowserHeader) {
27-
if (outdatedFeatures.length > 0) {
21+
if (Object.keys(Modernizr).filter(feature => !Modernizr[feature]).length > 0) {
2822
unsupportedBrowserHeader.style.display = 'block';
2923
} else {
3024
unsupportedBrowserHeader.remove();

packages/react-scripts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fs/react-scripts",
3-
"version": "8.7.10",
3+
"version": "8.7.11",
44
"upstreamVersion": "5.0.1",
55
"description": "Configuration and scripts for Create React App.",
66
"repository": {

0 commit comments

Comments
 (0)