New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-jsx-stylesheet

Package Overview
Dependencies
Maintainers
3
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-jsx-stylesheet - npm Package Compare versions

Comparing version 0.6.1 to 0.6.2

2

lib/index.js

@@ -12,3 +12,3 @@ 'use strict';

var mergeStylesFunctionTemplate = template('\nfunction ' + MERGE_STYLES_FUNC_NAME + '() {\n var newTarget = {};\n\n for (var index = 0; index < arguments.length; index++) {\n var target = arguments[index];\n\n for (var key in target) {\n newTarget[key] = Object.assign(newTarget[key] || {}, target[key]);\n }\n }\n\n return newTarget;\n}\n ');
var getClassNameFunctionTemplate = template('\nfunction ' + GET_CLS_NAME_FUNC_NAME + '() {\n var className = [];\n var args = arguments[0];\n var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();\n\n if (type === \'string\') {\n args = args.trim();\n args && className.push(args);\n } else if (type === \'array\') {\n args.forEach(function (cls) {\n cls = ' + GET_CLS_NAME_FUNC_NAME + '(cls).trim();\n cls && className.push(cls);\n });\n } else if (type === \'object\') {\n for (var k in args) {\n k = k.trim();\n if (k && object.hasOwnProperty(k) && object[k]) {\n className.push(k);\n }\n }\n }\n\n return className.join(\' \').trim();\n}\n ');
var getClassNameFunctionTemplate = template('\nfunction ' + GET_CLS_NAME_FUNC_NAME + '() {\n var className = [];\n var args = arguments[0];\n var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();\n\n if (type === \'string\') {\n args = args.trim();\n args && className.push(args);\n } else if (type === \'array\') {\n args.forEach(function (cls) {\n cls = ' + GET_CLS_NAME_FUNC_NAME + '(cls).trim();\n cls && className.push(cls);\n });\n } else if (type === \'object\') {\n for (var k in args) {\n k = k.trim();\n if (k && args.hasOwnProperty(k) && args[k]) {\n className.push(k);\n }\n }\n }\n\n return className.join(\' \').trim();\n}\n ');
var getStyleFunctionTemplete = template('\nfunction ' + GET_STYLE_FUNC_NAME + '(classNameExpression) { \n var cache = ' + STYLE_SHEET_NAME + '.__cache || (' + STYLE_SHEET_NAME + '.__cache = {});\n var className = ' + GET_CLS_NAME_FUNC_NAME + '(classNameExpression);\n var classNameArr = className.split(/\\s+/);\n var style = cache[className];\n\n if (!style) {\n style = {};\n if (classNameArr.length === 1) {\n style = ' + STYLE_SHEET_NAME + '[classNameArr[0].trim()];\n } else {\n classNameArr.forEach(function(cls) {\n style = Object.assign(style, ' + STYLE_SHEET_NAME + '[cls.trim()]);\n });\n }\n cache[className] = style;\n }\n\n return style;\n}\n ');

@@ -15,0 +15,0 @@

{
"name": "babel-plugin-transform-jsx-stylesheet",
"version": "0.6.1",
"version": "0.6.2",
"description": "Transform stylesheet selector to style in JSX Elements.",

@@ -5,0 +5,0 @@ "license": "BSD-3-Clause",

@@ -80,3 +80,3 @@ # babel-plugin-transform-jsx-stylesheet

Also support array, object and expressions like this: **(since 0.5.5)**
Also support array, object and expressions like this: **(since 0.6.0)**

@@ -91,5 +91,5 @@ ```js

<div className={'header'}>
<div className={{ active: props.isActive }} />
<div className={['header1 header2', 'header3', { active: props.isActive }]} />
<div className={props.visible ? 'show' : 'hide'} />
<div className={{ active: this.props.isActive }} />
<div className={['header1 header2', 'header3', { active: this.props.isActive }]} />
<div className={this.props.visible ? 'show' : 'hide'} />
<div className={getClassName()} />

@@ -112,5 +112,5 @@ </div>

<div style={styleSheet.header}>
<div style={_getStyle({ active: props.isActive })} />
<div style={_getStyle(['header1 header2', 'header3', { active: props.isActive }])} />
<div style={_getStyle(props.visible ? 'show' : 'hide')} />
<div style={_getStyle({ active: this.props.isActive })} />
<div style={_getStyle(['header1 header2', 'header3', { active: this.props.isActive }])} />
<div style={_getStyle(this.props.visible ? 'show' : 'hide')} />
<div style={_getStyle(getClassName())} />

@@ -117,0 +117,0 @@ </div>

@@ -36,3 +36,3 @@ import jSXStylePlugin from '../index';

if (k && object.hasOwnProperty(k) && object[k]) {
if (k && args.hasOwnProperty(k) && args[k]) {
className.push(k);

@@ -39,0 +39,0 @@ }

@@ -44,3 +44,3 @@ import path from 'path';

k = k.trim();
if (k && object.hasOwnProperty(k) && object[k]) {
if (k && args.hasOwnProperty(k) && args[k]) {
className.push(k);

@@ -47,0 +47,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc