jss-plugin-camel-case
Advanced tools
Comparing version 10.0.0-alpha.10 to 10.0.0-alpha.11
@@ -0,1 +1,2 @@ | ||
/* eslint-disable no-var, prefer-template */ | ||
var uppercasePattern = /[A-Z]/g; | ||
@@ -5,13 +6,15 @@ var msPattern = /^ms-/; | ||
function hyphenateStyleName(string) { | ||
return string in cache | ||
? cache[string] | ||
: cache[string] = string | ||
.replace(uppercasePattern, '-$&') | ||
.toLowerCase() | ||
.replace(msPattern, '-ms-'); | ||
function toHyphenLower(match) { | ||
return '-' + match.toLowerCase() | ||
} | ||
var hyphenateStyleName_1 = hyphenateStyleName; | ||
function hyphenateStyleName(name) { | ||
if (cache.hasOwnProperty(name)) { | ||
return cache[name] | ||
} | ||
var hName = name.replace(uppercasePattern, toHyphenLower); | ||
return (cache[name] = msPattern.test(hName) ? '-' + hName : hName) | ||
} | ||
/** | ||
@@ -28,3 +31,3 @@ * Convert camel cased property names to dash separated. | ||
for (var prop in style) { | ||
var key = prop.startsWith('--') ? prop : hyphenateStyleName_1(prop); | ||
var key = prop.startsWith('--') ? prop : hyphenateStyleName(prop); | ||
converted[key] = style[prop]; | ||
@@ -65,3 +68,3 @@ } | ||
var hyphenatedProp = hyphenateStyleName_1(prop); // There was no camel case in place | ||
var hyphenatedProp = hyphenateStyleName(prop); // There was no camel case in place | ||
@@ -68,0 +71,0 @@ if (prop === hyphenatedProp) return value; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.jssPluginCamelCase = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = global || self, factory(global.jssPluginCamelCase = {})); | ||
}(this, function (exports) { 'use strict'; | ||
var uppercasePattern = /[A-Z]/g; | ||
var msPattern = /^ms-/; | ||
var cache = {}; | ||
/* eslint-disable no-var, prefer-template */ | ||
var uppercasePattern = /[A-Z]/g; | ||
var msPattern = /^ms-/; | ||
var cache = {}; | ||
function hyphenateStyleName(string) { | ||
return string in cache | ||
? cache[string] | ||
: cache[string] = string | ||
.replace(uppercasePattern, '-$&') | ||
.toLowerCase() | ||
.replace(msPattern, '-ms-'); | ||
function toHyphenLower(match) { | ||
return '-' + match.toLowerCase() | ||
} | ||
function hyphenateStyleName(name) { | ||
if (cache.hasOwnProperty(name)) { | ||
return cache[name] | ||
} | ||
var hyphenateStyleName_1 = hyphenateStyleName; | ||
var hName = name.replace(uppercasePattern, toHyphenLower); | ||
return (cache[name] = msPattern.test(hName) ? '-' + hName : hName) | ||
} | ||
/** | ||
* Convert camel cased property names to dash separated. | ||
* | ||
* @param {Object} style | ||
* @return {Object} | ||
*/ | ||
/** | ||
* Convert camel cased property names to dash separated. | ||
* | ||
* @param {Object} style | ||
* @return {Object} | ||
*/ | ||
function convertCase(style) { | ||
var converted = {}; | ||
function convertCase(style) { | ||
var converted = {}; | ||
for (var prop in style) { | ||
var key = prop.startsWith('--') ? prop : hyphenateStyleName_1(prop); | ||
converted[key] = style[prop]; | ||
} | ||
for (var prop in style) { | ||
var key = prop.startsWith('--') ? prop : hyphenateStyleName(prop); | ||
converted[key] = style[prop]; | ||
} | ||
if (style.fallbacks) { | ||
if (Array.isArray(style.fallbacks)) converted.fallbacks = style.fallbacks.map(convertCase);else converted.fallbacks = convertCase(style.fallbacks); | ||
} | ||
return converted; | ||
if (style.fallbacks) { | ||
if (Array.isArray(style.fallbacks)) converted.fallbacks = style.fallbacks.map(convertCase);else converted.fallbacks = convertCase(style.fallbacks); | ||
} | ||
/** | ||
* Allow camel cased property names by converting them back to dasherized. | ||
* | ||
* @param {Rule} rule | ||
*/ | ||
return converted; | ||
} | ||
/** | ||
* Allow camel cased property names by converting them back to dasherized. | ||
* | ||
* @param {Rule} rule | ||
*/ | ||
function camelCase() { | ||
function onProcessStyle(style) { | ||
if (Array.isArray(style)) { | ||
// Handle rules like @font-face, which can have multiple styles in an array | ||
for (var index = 0; index < style.length; index++) { | ||
style[index] = convertCase(style[index]); | ||
} | ||
return style; | ||
function camelCase() { | ||
function onProcessStyle(style) { | ||
if (Array.isArray(style)) { | ||
// Handle rules like @font-face, which can have multiple styles in an array | ||
for (var index = 0; index < style.length; index++) { | ||
style[index] = convertCase(style[index]); | ||
} | ||
return convertCase(style); | ||
return style; | ||
} | ||
function onChangeValue(value, prop, rule) { | ||
if (prop.startsWith('--')) { | ||
return value; | ||
} | ||
return convertCase(style); | ||
} | ||
var hyphenatedProp = hyphenateStyleName_1(prop); // There was no camel case in place | ||
function onChangeValue(value, prop, rule) { | ||
if (prop.startsWith('--')) { | ||
return value; | ||
} | ||
if (prop === hyphenatedProp) return value; | ||
rule.prop(hyphenatedProp, value); // Core will ignore that property value we set the proper one above. | ||
var hyphenatedProp = hyphenateStyleName(prop); // There was no camel case in place | ||
return null; | ||
} | ||
if (prop === hyphenatedProp) return value; | ||
rule.prop(hyphenatedProp, value); // Core will ignore that property value we set the proper one above. | ||
return { | ||
onProcessStyle: onProcessStyle, | ||
onChangeValue: onChangeValue | ||
}; | ||
return null; | ||
} | ||
exports.default = camelCase; | ||
return { | ||
onProcessStyle: onProcessStyle, | ||
onChangeValue: onChangeValue | ||
}; | ||
} | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
exports.default = camelCase; | ||
}))); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); | ||
//# sourceMappingURL=jss-plugin-camel-case.js.map |
@@ -1,1 +0,1 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.jssPluginCamelCase={})}(this,function(e){"use strict";var r=/[A-Z]/g,n=/^ms-/,t={};var a=function(e){return e in t?t[e]:t[e]=e.replace(r,"-$&").toLowerCase().replace(n,"-ms-")};function f(e){var r={};for(var n in e){r[n.startsWith("--")?n:a(n)]=e[n]}return e.fallbacks&&(Array.isArray(e.fallbacks)?r.fallbacks=e.fallbacks.map(f):r.fallbacks=f(e.fallbacks)),r}e.default=function(){return{onProcessStyle:function(e){if(Array.isArray(e)){for(var r=0;r<e.length;r++)e[r]=f(e[r]);return e}return f(e)},onChangeValue:function(e,r,n){if(r.startsWith("--"))return e;var t=a(r);return r===t?e:(n.prop(t,e),null)}}},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).jssPluginCamelCase={})}(this,function(e){"use strict";var r=/[A-Z]/g,t=/^ms-/,n={};function a(e){return"-"+e.toLowerCase()}function f(e){if(n.hasOwnProperty(e))return n[e];var f=e.replace(r,a);return n[e]=t.test(f)?"-"+f:f}function s(e){var r={};for(var t in e){r[t.startsWith("--")?t:f(t)]=e[t]}return e.fallbacks&&(Array.isArray(e.fallbacks)?r.fallbacks=e.fallbacks.map(s):r.fallbacks=s(e.fallbacks)),r}e.default=function(){return{onProcessStyle:function(e){if(Array.isArray(e)){for(var r=0;r<e.length;r++)e[r]=s(e[r]);return e}return s(e)},onChangeValue:function(e,r,t){if(r.startsWith("--"))return e;var n=f(r);return r===n?e:(t.prop(n,e),null)}}},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "jss-plugin-camel-case", | ||
"description": "JSS plugin that allows to write camel cased rule properties", | ||
"version": "10.0.0-alpha.10", | ||
"version": "10.0.0-alpha.11", | ||
"license": "MIT", | ||
@@ -40,10 +40,10 @@ "homepage": "https://cssinjs.org/jss-camel-case", | ||
"devDependencies": { | ||
"jss-plugin-rule-value-function": "10.0.0-alpha.10" | ||
"jss-plugin-rule-value-function": "10.0.0-alpha.11" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.0.0", | ||
"hyphenate-style-name": "^1.0.2", | ||
"jss": "10.0.0-alpha.10" | ||
"@babel/runtime": "^7.3.1", | ||
"hyphenate-style-name": "^1.0.3", | ||
"jss": "10.0.0-alpha.11" | ||
}, | ||
"gitHead": "953234ad4e69b2f3d00fb9d683fba24865d2c4dd" | ||
"gitHead": "79343bda7df92609218aea1c9907297051cfc6ed" | ||
} |
@@ -12,3 +12,3 @@ # jss-plugin-camel-case | ||
See our website [jss-plugin-camel-case](https://cssinjs.org/jss-plugin-camel-case?v=v10.0.0-alpha.10) for more information. | ||
See our website [jss-plugin-camel-case](https://cssinjs.org/jss-plugin-camel-case?v=v10.0.0-alpha.11) for more information. | ||
@@ -15,0 +15,0 @@ ## Install |
Sorry, the diff of this file is not supported yet
22183
468
+ Addedjss@10.0.0-alpha.11(transitive)
- Removedjss@10.0.0-alpha.10(transitive)
Updated@babel/runtime@^7.3.1
Updatedhyphenate-style-name@^1.0.3
Updatedjss@10.0.0-alpha.11