babel-plugin-split-styles
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -51,8 +51,2 @@ "use strict"; | ||
let cssProp = path.parentPath.node.attributes.find(node => node.name.name === 'css'); // if there is a cssProp it must contain a objectExpression | ||
if (cssProp && !t.isObjectExpression(cssProp.value.expression)) { | ||
return; | ||
} | ||
if (t.isJSXExpressionContainer(path.node.value)) { | ||
@@ -75,8 +69,3 @@ const extracted = extractStylesFromPath(t, path.get('value.expression'), state); | ||
if (staticStyle.length !== 0) { | ||
if (!cssProp) { | ||
cssProp = t.jsxAttribute(t.jsxIdentifier('css'), t.jsxExpressionContainer(t.objectExpression([]))); | ||
path.parentPath.node.attributes.unshift(cssProp); | ||
} | ||
cssProp.value.expression.properties.push(...staticStyle); | ||
path.parentPath.node.attributes.unshift(t.jsxAttribute(t.jsxIdentifier('css'), t.jsxExpressionContainer(t.objectExpression(staticStyle)))); | ||
} | ||
@@ -83,0 +72,0 @@ } |
{ | ||
"name": "babel-plugin-split-styles", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Splitting dynamic and static styles into style and css prop.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -50,3 +50,4 @@ // Path is an object expression; | ||
!t.isObjectExpression(path.node.value.expression) || | ||
path.node.name.name !== 'style' | ||
path.node.name.name !== 'style' || | ||
path.parent.attributes.some(node => node.name.name === 'css') | ||
) { | ||
@@ -56,11 +57,2 @@ return; | ||
let cssProp = path.parentPath.node.attributes.find( | ||
node => node.name.name === 'css' | ||
); | ||
// if there is a cssProp it must contain a objectExpression | ||
if (cssProp && !t.isObjectExpression(cssProp.value.expression)) { | ||
return; | ||
} | ||
if (t.isJSXExpressionContainer(path.node.value)) { | ||
@@ -83,11 +75,8 @@ const extracted = extractStylesFromPath( | ||
if (staticStyle.length !== 0) { | ||
if (!cssProp) { | ||
cssProp = t.jsxAttribute( | ||
path.parentPath.node.attributes.unshift( | ||
t.jsxAttribute( | ||
t.jsxIdentifier('css'), | ||
t.jsxExpressionContainer(t.objectExpression([])) | ||
); | ||
path.parentPath.node.attributes.unshift(cssProp); | ||
} | ||
cssProp.value.expression.properties.push(...staticStyle); | ||
t.jsxExpressionContainer(t.objectExpression(staticStyle)) | ||
) | ||
); | ||
} | ||
@@ -94,0 +83,0 @@ } |
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
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
10629
150