babel-plugin-transform-jsx-stylesheet
Advanced tools
Comparing version 1.0.4 to 1.0.5-beta.1
@@ -74,1 +74,2 @@ "use strict"; | ||
}); | ||
//# sourceMappingURL=index.js.map |
@@ -28,2 +28,6 @@ "use strict"; | ||
}); | ||
it('should transform code correctly when `retainClassName` is true', function () { | ||
expect(getTransformCode("\nimport { createElement, render } from 'rax';\nimport styles from './app.css';\n\nrender(<div className={styles.header} />);\n", { retainClassName: true })).toBe("\nimport { createElement, render } from 'rax';\nimport styles from './app.css';\n\nrender(<div style={styles.header} />);"); | ||
}); | ||
}); | ||
//# sourceMappingURL=module.js.map |
@@ -18,1 +18,2 @@ "use strict"; | ||
exports.getStyleFunctionString = function () { return "function " + exports.GET_STYLE_FUNC_NAME + "(classNameExpression) {\n var cache = " + exports.styleSheetName + ".__cache || (" + exports.styleSheetName + ".__cache = {});\n\n var className = " + exports.GET_CLS_NAME_FUNC_NAME + "(classNameExpression);\n\n var classNameArr = className.split(/\\s+/);\n var style = cache[className];\n\n if (!style) {\n style = {};\n\n if (classNameArr.length === 1) {\n style = " + exports.styleSheetName + "[classNameArr[0].trim()];\n } else {\n classNameArr.forEach(function (cls) {\n var value = " + exports.styleSheetName + "[cls.trim()];\n\n if (typeof value === 'object') {\n style = Object.assign(style, " + exports.styleSheetName + "[cls.trim()]);\n }\n });\n }\n\n cache[className] = style;\n }\n\n return style;\n}"; }; | ||
//# sourceMappingURL=constants.js.map |
@@ -148,2 +148,11 @@ "use strict"; | ||
classNameAttribute.name.name = 'style'; | ||
// `className` is already transformed to `style` | ||
// `hasStyleAttribute` should equal `true` | ||
// and `styleAttribute` should equal `classNameAttribute` | ||
if (retainClassName) { | ||
hasStyleAttribute = true; | ||
styleAttribute = classNameAttribute; | ||
hasClassName = false; | ||
classNameAttribute = t.jSXAttribute(t.jSXIdentifier('className'), null); | ||
} | ||
file.set('injectGetStyle', false); | ||
@@ -221,1 +230,2 @@ } | ||
exports.default = default_1; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "babel-plugin-transform-jsx-stylesheet", | ||
"version": "1.0.4", | ||
"version": "1.0.5-beta.1", | ||
"description": "Transform stylesheet selector to style in JSX Elements.", | ||
"license": "BSD-3-Clause", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"lib", | ||
"!lib/**/*.map" | ||
], | ||
"repository": { | ||
@@ -25,2 +29,2 @@ "type": "git", | ||
} | ||
} | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
31696
10
414
1