Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Memoize call expressions in optional chains in loose mode (#11261)
* Memoize in loose mode when callee is a CallExpression * Handle more complex OptionalCallExpressions where memoization is needed * Convert calls to Function#call when member needs memoization * Only update call context for member expressions
- Loading branch information
1 parent
2e6f958
commit 693a5df
Showing
3 changed files
with
32 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 10 additions & 5 deletions
15
...ges/babel-plugin-proposal-optional-chaining/test/fixtures/general/memoize-loose/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
function test(foo) { | ||
var _foo$bar, _foo$bar2, _foo$bar3, _foo$bar4, _foo$bar5; | ||
var _foo$bar, _foo$get, _foo$bar2, _foo$bar3, _foo$bar$baz, _foo$bar4, _foo$bar$baz2, _foo$bar5, _foo$bar6, _foo$bar7, _foo$bar8, _foo$bar9; | ||
|
||
foo == null ? void 0 : foo.bar; | ||
foo == null ? void 0 : (_foo$bar = foo.bar) == null ? void 0 : _foo$bar.baz; | ||
foo == null ? void 0 : foo(foo); | ||
foo == null ? void 0 : foo.bar(); | ||
(_foo$get = foo.get(bar)) == null ? void 0 : _foo$get(); | ||
(_foo$bar2 = foo.bar()) == null ? void 0 : _foo$bar2(); | ||
(_foo$bar3 = foo[bar]()) == null ? void 0 : _foo$bar3(); | ||
(_foo$bar$baz = (_foo$bar4 = foo.bar()).baz) == null ? void 0 : _foo$bar$baz.call(_foo$bar4); | ||
(_foo$bar$baz2 = (_foo$bar5 = foo[bar]()).baz) == null ? void 0 : _foo$bar$baz2.call(_foo$bar5); | ||
foo.bar == null ? void 0 : foo.bar(foo.bar, false); | ||
foo == null ? void 0 : foo.bar == null ? void 0 : foo.bar(foo.bar, true); | ||
(_foo$bar2 = foo.bar) == null ? void 0 : _foo$bar2.baz(foo.bar, false); | ||
foo == null ? void 0 : (_foo$bar3 = foo.bar) == null ? void 0 : _foo$bar3.baz(foo.bar, true); | ||
(_foo$bar4 = foo.bar) == null ? void 0 : _foo$bar4.baz == null ? void 0 : _foo$bar4.baz(foo.bar, false); | ||
foo == null ? void 0 : (_foo$bar5 = foo.bar) == null ? void 0 : _foo$bar5.baz == null ? void 0 : _foo$bar5.baz(foo.bar, true); | ||
(_foo$bar6 = foo.bar) == null ? void 0 : _foo$bar6.baz(foo.bar, false); | ||
foo == null ? void 0 : (_foo$bar7 = foo.bar) == null ? void 0 : _foo$bar7.baz(foo.bar, true); | ||
(_foo$bar8 = foo.bar) == null ? void 0 : _foo$bar8.baz == null ? void 0 : _foo$bar8.baz(foo.bar, false); | ||
foo == null ? void 0 : (_foo$bar9 = foo.bar) == null ? void 0 : _foo$bar9.baz == null ? void 0 : _foo$bar9.baz(foo.bar, true); | ||
} |