UNPKG

astx

Version:

super powerful structural search and replace for JavaScript and TypeScript to automate your refactoring

31 lines (25 loc) 1.14 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = compileJSXAttributeMatcher; var _Placeholder = _interopRequireDefault(require("./Placeholder")); function compileJSXAttributeMatcher(path, compileOptions) { var pattern = path.value; var n = compileOptions.backend.t.namedTypes; if (n.JSXIdentifier.check(pattern.name)) { if (pattern.value == null) { var placeholderMatcher = (0, _Placeholder["default"])(path, pattern.name.name, compileOptions, { nodeType: 'JSX', getCondition: function getCondition() { return function (path) { var _path$parent, _path$parentPath; return n.JSXOpeningElement.check((_path$parent = path.parent) === null || _path$parent === void 0 ? void 0 : _path$parent.value) && ((_path$parentPath = path.parentPath) === null || _path$parentPath === void 0 ? void 0 : _path$parentPath.name) === 'attributes'; }; } }); if (placeholderMatcher) return placeholderMatcher; } } }