Use a package for style name hyphenation

The 'hyphenate-style-name' packages is already a dependency of
'inline-style-prefixer', so we don't need our own implementation.
This commit is contained in:
Nicolas Gallagher
2017-03-02 19:10:02 -08:00
parent a2f25a46c4
commit b408bc5537
3 changed files with 3 additions and 14 deletions

View File

@@ -30,6 +30,7 @@
"debounce": "^1.0.0",
"deep-assign": "^2.0.0",
"fbjs": "^0.8.8",
"hyphenate-style-name": "^1.0.2",
"inline-style-prefixer": "^3.0.0",
"normalize-css-color": "^1.0.2",
"react-dom": "~15.4.1",

View File

@@ -1,10 +1,10 @@
import hyphenate from './hyphenate';
import hyphenateStyleName from 'hyphenate-style-name';
import mapKeyValue from '../../modules/mapKeyValue';
import normalizeValue from './normalizeValue';
import prefixAll from 'inline-style-prefixer/static';
const createDeclarationString = (prop, val) => {
const name = hyphenate(prop);
const name = hyphenateStyleName(prop);
const value = normalizeValue(prop, val);
if (Array.isArray(val)) {
return val.map(v => `${name}:${v}`).join(';');

View File

@@ -1,12 +0,0 @@
const cache = {};
const MS_REGEXP = /^ms-/;
const UPPERCASE_REGEXP = /([A-Z])/g;
const hyphenateStyleProp = prop => {
if (!cache.hasOwnProperty(prop)) {
cache[prop] = prop.replace(UPPERCASE_REGEXP, '-$&').toLowerCase().replace(MS_REGEXP, '-ms-');
}
return cache[prop];
};
module.exports = hyphenateStyleProp;