Skip to content

Commit

Permalink
refactor: address review comments [ci-skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Jun 4, 2020
1 parent 2ffc76a commit 99f7986
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/babel-plugin-proposal-optional-chaining/src/index.js
Expand Up @@ -128,6 +128,9 @@ export default declare((api, options) => {
}
let replacement = replacementPath.node;
// Ensure (a?.b)() has proper `this`
// The `parentIsCall` is constant within loop, we should check i === 0
// to ensure that it is only applied to the first optional chain element
// i.e. `?.b` in `(a?.b.c)()`
if (i === 0 && parentIsCall) {
// `(a?.b)()` to `(a == null ? undefined : a.b.bind(a))()`
const { object } = replacement;
Expand Down

0 comments on commit 99f7986

Please sign in to comment.