UNPKG

1.18 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _types = require("@babel/types");
9
10const handleSpreadClassName = (path, destinationName, classNamesFromSpread) => {
11 const destinationAttribute = path.node.openingElement.attributes.find(attribute => {
12 return typeof attribute.name !== 'undefined' && attribute.name.name === destinationName;
13 });
14
15 if (!destinationAttribute) {
16 return;
17 }
18
19 if ((0, _types.isStringLiteral)(destinationAttribute.value)) {
20 destinationAttribute.value = (0, _types.jsxExpressionContainer)((0, _types.binaryExpression)('+', destinationAttribute.value, (0, _types.binaryExpression)('+', (0, _types.stringLiteral)(' '), classNamesFromSpread)));
21 } else if ((0, _types.isJSXExpressionContainer)(destinationAttribute.value)) {
22 destinationAttribute.value = (0, _types.jsxExpressionContainer)((0, _types.binaryExpression)('+', destinationAttribute.value.expression, (0, _types.binaryExpression)('+', (0, _types.stringLiteral)(' '), classNamesFromSpread)));
23 }
24};
25
26var _default = handleSpreadClassName;
27exports.default = _default;
28//# sourceMappingURL=handleSpreadClassName.js.map
\No newline at end of file