diff --git a/package.json b/package.json index 02cead49..10844b6e 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/apis/StyleSheet/generateCss.js b/src/apis/StyleSheet/generateCss.js index 934a9b34..cdb29614 100644 --- a/src/apis/StyleSheet/generateCss.js +++ b/src/apis/StyleSheet/generateCss.js @@ -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(';'); diff --git a/src/apis/StyleSheet/hyphenate.js b/src/apis/StyleSheet/hyphenate.js deleted file mode 100644 index 492deb0c..00000000 --- a/src/apis/StyleSheet/hyphenate.js +++ /dev/null @@ -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;