classnames.macro
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -88,4 +88,8 @@ "use strict"; | ||
if (babel.types.isNullLiteral(node)) { | ||
return babel.types.stringLiteral(""); | ||
} | ||
if (babel.types.isMemberExpression(node) || babel.types.isIdentifier(node)) { | ||
return babel.types.binaryExpression("+", babel.types.stringLiteral(" "), node); | ||
return babel.types.binaryExpression("+", babel.types.stringLiteral(" "), babel.types.logicalExpression("||", node, babel.types.stringLiteral(""))); | ||
} // TODO: This probably does not belong here | ||
@@ -131,2 +135,3 @@ | ||
} = unpackArray(input); | ||
const filteredElements = elements.filter(element => !babel.types.isNullLiteral(element) && !(babel.types.isIdentifier(element) && element.name === 'undefined') && !(babel.types.isBooleanLiteral(element) && element.value === false)); | ||
const values = groupBy(node => { | ||
@@ -138,3 +143,3 @@ if (babel.types.isStringLiteral(node)) { | ||
return "dynamic"; | ||
}, elements); | ||
}, filteredElements); | ||
return concatNodes([concatStringNodes(values.static), ...(values.dynamic ?? [])]); | ||
@@ -141,0 +146,0 @@ } // Return input data if macro was called correctly |
{ | ||
"name": "classnames.macro", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Babel Macro for conditionally joining CSS class names together", | ||
@@ -84,2 +84,3 @@ "keywords": [ | ||
"ava": "^3.15.0", | ||
"c8": "^7.10.0", | ||
"common-tags": "^1.4.0", | ||
@@ -86,0 +87,0 @@ "eslint": "^8.4.1", |
9500
135
14