mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-04-29 04:44:52 +08:00
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:
@@ -30,6 +30,7 @@
|
|||||||
"debounce": "^1.0.0",
|
"debounce": "^1.0.0",
|
||||||
"deep-assign": "^2.0.0",
|
"deep-assign": "^2.0.0",
|
||||||
"fbjs": "^0.8.8",
|
"fbjs": "^0.8.8",
|
||||||
|
"hyphenate-style-name": "^1.0.2",
|
||||||
"inline-style-prefixer": "^3.0.0",
|
"inline-style-prefixer": "^3.0.0",
|
||||||
"normalize-css-color": "^1.0.2",
|
"normalize-css-color": "^1.0.2",
|
||||||
"react-dom": "~15.4.1",
|
"react-dom": "~15.4.1",
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import hyphenate from './hyphenate';
|
import hyphenateStyleName from 'hyphenate-style-name';
|
||||||
import mapKeyValue from '../../modules/mapKeyValue';
|
import mapKeyValue from '../../modules/mapKeyValue';
|
||||||
import normalizeValue from './normalizeValue';
|
import normalizeValue from './normalizeValue';
|
||||||
import prefixAll from 'inline-style-prefixer/static';
|
import prefixAll from 'inline-style-prefixer/static';
|
||||||
|
|
||||||
const createDeclarationString = (prop, val) => {
|
const createDeclarationString = (prop, val) => {
|
||||||
const name = hyphenate(prop);
|
const name = hyphenateStyleName(prop);
|
||||||
const value = normalizeValue(prop, val);
|
const value = normalizeValue(prop, val);
|
||||||
if (Array.isArray(val)) {
|
if (Array.isArray(val)) {
|
||||||
return val.map(v => `${name}:${v}`).join(';');
|
return val.map(v => `${name}:${v}`).join(';');
|
||||||
|
|||||||
@@ -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;
|
|
||||||
Reference in New Issue
Block a user