babel-plugin-styled-components-attr
Advanced tools
Comparing version 0.0.3 to 0.0.4
{ | ||
"name": "babel-plugin-styled-components-attr", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "CSS attr function in your styled components", | ||
@@ -10,3 +10,3 @@ "main": "src/index.js", | ||
"scripts": { | ||
"test": "standard src test && jest --coverage", | ||
"test": "standard src test && jest --coverage --no-cache", | ||
"test:watch": "jest --watch", | ||
@@ -13,0 +13,0 @@ "release": "npm run test && npm version patch && npm publish && git push --tags" |
@@ -77,4 +77,15 @@ module.exports = function (babel) { | ||
returnValue = t.conditionalExpression( | ||
createMemberExpression(), | ||
createMemberExpression(), | ||
t.logicalExpression( | ||
'||', | ||
t.binaryExpression( | ||
'===', | ||
t.identifier('undefined'), | ||
createMemberExpression() | ||
), | ||
t.binaryExpression( | ||
'===', | ||
t.nullLiteral(), | ||
createMemberExpression() | ||
) | ||
), | ||
t.parenthesizedExpression( | ||
@@ -86,3 +97,4 @@ t.binaryExpression( | ||
) | ||
) | ||
), | ||
createMemberExpression() | ||
) | ||
@@ -146,5 +158,5 @@ } | ||
// styled.h1`...` | ||
t.isMemberExpression(parentTag) && | ||
parentTag.object.name === 'styled' && | ||
t.isTemplateLiteral(path.node) | ||
t.isMemberExpression(parentTag) && | ||
parentTag.object.name === 'styled' && | ||
t.isTemplateLiteral(path.node) | ||
) { | ||
@@ -154,5 +166,5 @@ path.replaceWith(findAndReplaceAttrs(path)) | ||
// styled('h1')`...` | ||
t.isCallExpression(parentPath.node.tag) && | ||
parentPath.node.tag.callee.name === 'styled' && | ||
t.isTemplateLiteral(path.node) | ||
t.isCallExpression(parentPath.node.tag) && | ||
parentPath.node.tag.callee.name === 'styled' && | ||
t.isTemplateLiteral(path.node) | ||
) { | ||
@@ -159,0 +171,0 @@ path.replaceWith(findAndReplaceAttrs(path)) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
21991
368