babel-plugin-styled-components
Advanced tools
Comparing version 1.10.1 to 1.10.2-ej0
@@ -135,3 +135,7 @@ "use strict"; | ||
return function (path, state) { | ||
if (path.node.tag ? (0, _detectors.isStyled)(t)(path.node.tag, state) : (0, _detectors.isStyled)(t)(path.node.callee, state) && path.node.callee.property && path.node.callee.property.name !== 'withConfig') { | ||
if (path.node.tag ? (0, _detectors.isStyled)(t)(path.node.tag, state) : | ||
/* styled()`` */ | ||
(0, _detectors.isStyled)(t)(path.node.callee, state) && path.node.callee.property && path.node.callee.property.name !== 'withConfig' || // styled(x)({}) | ||
(0, _detectors.isStyled)(t)(path.node.callee, state) && !t.isMemberExpression(path.node.callee.callee) || // styled(x).attrs()({}) | ||
(0, _detectors.isStyled)(t)(path.node.callee, state) && t.isMemberExpression(path.node.callee.callee) && path.node.callee.callee.property && path.node.callee.callee.property.name && path.node.callee.callee.property.name !== 'withConfig') { | ||
var displayName = (0, _options.useDisplayName)(state) && getDisplayName(t)(path, (0, _options.useFileName)(state) && state); | ||
@@ -138,0 +142,0 @@ addConfig(t)(path, displayName && displayName.replace(/[^_a-zA-Z0-9-]/g, ''), (0, _options.useSSR)(state) && getComponentId(state)); |
@@ -68,2 +68,4 @@ "use strict"; | ||
css = path.node.value.expression.quasi; | ||
} else if (t.isObjectExpression(path.node.value.expression)) { | ||
css = path.node.value.expression; | ||
} else { | ||
@@ -90,23 +92,29 @@ css = t.templateLiteral([t.templateElement({ | ||
css.expressions = css.expressions.reduce(function (acc, ex) { | ||
if (Object.keys(bindings).some(function (key) { | ||
return bindings[key].referencePaths.find(function (p) { | ||
return p.node === ex; | ||
}); | ||
}) || t.isFunctionExpression(ex) || t.isArrowFunctionExpression(ex)) { | ||
acc.push(ex); | ||
} else { | ||
var _name = path.scope.generateUidIdentifier('css'); | ||
if (!t.isObjectExpression(css)) { | ||
css.expressions = css.expressions.reduce(function (acc, ex) { | ||
if (Object.keys(bindings).some(function (key) { | ||
return bindings[key].referencePaths.find(function (p) { | ||
return p.node === ex; | ||
}); | ||
}) || t.isFunctionExpression(ex) || t.isArrowFunctionExpression(ex)) { | ||
acc.push(ex); | ||
} else { | ||
var _name = path.scope.generateUidIdentifier('css'); | ||
var p = t.identifier('p'); | ||
elem.node.attributes.push(t.jSXAttribute(t.jSXIdentifier(_name.name), t.jSXExpressionContainer(ex))); | ||
acc.push(t.arrowFunctionExpression([p], t.memberExpression(p, _name))); | ||
} | ||
var p = t.identifier('p'); | ||
elem.node.attributes.push(t.jSXAttribute(t.jSXIdentifier(_name.name), t.jSXExpressionContainer(ex))); | ||
acc.push(t.arrowFunctionExpression([p], t.memberExpression(p, _name))); | ||
} | ||
return acc; | ||
}, []); // Add the tagged template expression and then requeue the newly added node | ||
// so Babel runs over it again | ||
return acc; | ||
}, []); | ||
} | ||
var length = program.node.body.push(t.variableDeclaration('var', [t.variableDeclarator(id, t.taggedTemplateExpression(styled, css))])); | ||
program.requeue(program.get('body')[length - 1]); | ||
var parent = elem; | ||
while (!t.isProgram(parent.parentPath)) { | ||
parent = parent.parentPath; | ||
} | ||
parent.insertBefore(t.variableDeclaration('var', [t.variableDeclarator(id, t.isObjectExpression(css) ? t.callExpression(styled, [css]) : t.taggedTemplateExpression(styled, css))])); | ||
}; | ||
@@ -113,0 +121,0 @@ }; |
{ | ||
"version": "1.10.1", | ||
"version": "1.10.2-ej0", | ||
"name": "babel-plugin-styled-components", | ||
@@ -4,0 +4,0 @@ "description": "Improve the debugging experience and add server-side rendering support to styled-components", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36912
723
2