Skip to content

Commit 5aefa95

Browse files
committed
Allow optional chaining in JS library code
This change verifies that closure can successfully lower the optional chaining away on older browsers. This also requires bumping of chrome and safari minimum versions.. so maybe its not worth it?
1 parent 499d5ee commit 5aefa95

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/settings.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,10 +1747,10 @@ var AUTO_NATIVE_LIBRARIES = true;
17471747
// versions >= MIN_FIREFOX_VERSION
17481748
// are desired to work. Pass -sMIN_FIREFOX_VERSION=majorVersion to drop support
17491749
// for Firefox versions older than < majorVersion.
1750-
// Firefox ESR 68 was released on July 9, 2019.
1750+
// Firefox ESR 74 was released on March 10, 2020
17511751
// MAX_INT (0x7FFFFFFF, or -1) specifies that target is not supported.
17521752
// [link]
1753-
var MIN_FIREFOX_VERSION = 68;
1753+
var MIN_FIREFOX_VERSION = 74;
17541754

17551755
// Specifies the oldest version of desktop Safari to target. Version is encoded
17561756
// in MMmmVV, e.g. 70101 denotes Safari 7.1.1.
@@ -1789,10 +1789,10 @@ var MIN_EDGE_VERSION = 0x7FFFFFFF;
17891789

17901790
// Specifies the oldest version of Chrome. E.g. pass -sMIN_CHROME_VERSION=58 to
17911791
// drop support for Chrome 57 and older.
1792-
// Chrome 75.0.3770 was released on 2019-06-04
1792+
// Chrome 80 was released on February 4, 2020
17931793
// MAX_INT (0x7FFFFFFF, or -1) specifies that target is not supported.
17941794
// [link]
1795-
var MIN_CHROME_VERSION = 75;
1795+
var MIN_CHROME_VERSION = 80;
17961796

17971797
// Specifies minimum node version to target for the generated code. This is
17981798
// distinct from the minimum version required run the emscripten compiler.

test/test_other.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12621,6 +12621,10 @@ def test_es5_transpile(self, args):
1262112621
[key]: 42,
1262212622
};
1262312623
err('value: ' + obj2[key]);
12624+
12625+
// optional chaining
12626+
let result = Module.foo?.doSomething();
12627+
err('result: ' + result);
1262412628
}
1262512629
});
1262612630
''')
@@ -12635,13 +12639,15 @@ def check_for_es6(filename, expect):
1263512639
self.assertContained(['() => 2', '()=>2'], js)
1263612640
self.assertContained('const ', js)
1263712641
self.assertContained('let ', js)
12642+
self.assertContained('foo?.doSomething()', js)
1263812643
else:
1263912644
self.verify_es5(filename)
1264012645
self.assertNotContained('foo(arg=', js)
1264112646
self.assertNotContained('() => 2', js)
1264212647
self.assertNotContained('()=>2', js)
1264312648
self.assertNotContained('const ', js)
1264412649
self.assertNotContained('let ', js)
12650+
self.assertNotContained('foo?.doSomething()', js)
1264512651

1264612652
# Check that under normal circumstances none of these features get
1264712653
# removed / transpiled.

tools/feature_matrix.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Feature(IntEnum):
2323
THREADS = auto()
2424
GLOBALTHIS = auto()
2525
PROMISE_ANY = auto()
26+
OPTIONAL_CHAINING = auto()
2627

2728

2829
default_features = {Feature.SIGN_EXT, Feature.MUTABLE_GLOBALS}
@@ -71,6 +72,12 @@ class Feature(IntEnum):
7172
'safari': 140000,
7273
'node': 150000,
7374
},
75+
Feature.OPTIONAL_CHAINING: {
76+
'chrome': 80,
77+
'firefox': 74,
78+
'safari': 130400,
79+
'node': 140000,
80+
},
7481
}
7582

7683

0 commit comments

Comments
 (0)