@babel/plugin-proposal-optional-chaining
Advanced tools
Comparing version 7.6.0 to 7.7.4
@@ -8,35 +8,11 @@ "use strict"; | ||
function _helperPluginUtils() { | ||
const data = require("@babel/helper-plugin-utils"); | ||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); | ||
_helperPluginUtils = function () { | ||
return data; | ||
}; | ||
var _pluginSyntaxOptionalChaining = _interopRequireDefault(require("@babel/plugin-syntax-optional-chaining")); | ||
return data; | ||
} | ||
var _core = require("@babel/core"); | ||
function _pluginSyntaxOptionalChaining() { | ||
const data = _interopRequireDefault(require("@babel/plugin-syntax-optional-chaining")); | ||
_pluginSyntaxOptionalChaining = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _core() { | ||
const data = require("@babel/core"); | ||
_core = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _default = (0, _helperPluginUtils().declare)((api, options) => { | ||
var _default = (0, _helperPluginUtils.declare)((api, options) => { | ||
api.assertVersion(7); | ||
@@ -48,3 +24,3 @@ const { | ||
name: "proposal-optional-chaining", | ||
inherits: _pluginSyntaxOptionalChaining().default, | ||
inherits: _pluginSyntaxOptionalChaining.default, | ||
visitor: { | ||
@@ -88,3 +64,3 @@ "OptionalCallExpression|OptionalMemberExpression"(path) { | ||
const isCall = _core().types.isCallExpression(node); | ||
const isCall = _core.types.isCallExpression(node); | ||
@@ -102,3 +78,3 @@ const replaceKey = isCall ? "callee" : "object"; | ||
if (ref) { | ||
check = _core().types.assignmentExpression("=", _core().types.cloneNode(ref), chain); | ||
check = _core.types.assignmentExpression("=", _core.types.cloneNode(ref), chain); | ||
node[replaceKey] = ref; | ||
@@ -110,3 +86,3 @@ } else { | ||
if (isCall && _core().types.isMemberExpression(chain)) { | ||
if (isCall && _core.types.isMemberExpression(chain)) { | ||
if (loose) { | ||
@@ -121,3 +97,5 @@ node.callee = chain; | ||
if (context) { | ||
chain.object = _core().types.assignmentExpression("=", context, object); | ||
chain.object = _core.types.assignmentExpression("=", context, object); | ||
} else if (_core.types.isSuper(object)) { | ||
context = _core.types.thisExpression(); | ||
} else { | ||
@@ -127,8 +105,8 @@ context = object; | ||
node.arguments.unshift(_core().types.cloneNode(context)); | ||
node.callee = _core().types.memberExpression(node.callee, _core().types.identifier("call")); | ||
node.arguments.unshift(_core.types.cloneNode(context)); | ||
node.callee = _core.types.memberExpression(node.callee, _core.types.identifier("call")); | ||
} | ||
} | ||
replacementPath.replaceWith(_core().types.conditionalExpression(loose ? _core().types.binaryExpression("==", _core().types.cloneNode(check), _core().types.nullLiteral()) : _core().types.logicalExpression("||", _core().types.binaryExpression("===", _core().types.cloneNode(check), _core().types.nullLiteral()), _core().types.binaryExpression("===", _core().types.cloneNode(ref), scope.buildUndefinedNode())), scope.buildUndefinedNode(), replacementPath.node)); | ||
replacementPath.replaceWith(_core.types.conditionalExpression(loose ? _core.types.binaryExpression("==", _core.types.cloneNode(check), _core.types.nullLiteral()) : _core.types.logicalExpression("||", _core.types.binaryExpression("===", _core.types.cloneNode(check), _core.types.nullLiteral()), _core.types.binaryExpression("===", _core.types.cloneNode(ref), scope.buildUndefinedNode())), scope.buildUndefinedNode(), replacementPath.node)); | ||
replacementPath = replacementPath.get("alternate"); | ||
@@ -135,0 +113,0 @@ } |
{ | ||
"name": "@babel/plugin-proposal-optional-chaining", | ||
"version": "7.6.0", | ||
"version": "7.7.4", | ||
"description": "Transform optional chaining operators into a series of nil checks", | ||
@@ -16,3 +16,3 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-optional-chaining", | ||
"@babel/helper-plugin-utils": "^7.0.0", | ||
"@babel/plugin-syntax-optional-chaining": "^7.2.0" | ||
"@babel/plugin-syntax-optional-chaining": "^7.7.4" | ||
}, | ||
@@ -23,7 +23,7 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@babel/core": "^7.6.0", | ||
"@babel/helper-plugin-test-runner": "^7.0.0", | ||
"@babel/plugin-transform-block-scoping": "^7.6.0" | ||
"@babel/core": "^7.7.4", | ||
"@babel/helper-plugin-test-runner": "^7.7.4", | ||
"@babel/plugin-transform-block-scoping": "^7.7.4" | ||
}, | ||
"gitHead": "cbd5a26e57758e3f748174ff84aa570e8780e85d" | ||
"gitHead": "75767d87cb147709b9bd9b99bf44daa6688874a9" | ||
} |
6068
91