UNPKG

1.22 kBJavaScriptView Raw
1// Same as https://github.com/SimenB/react-vendor-prefixes/blob/master/src/index.js,
2// but dumber
3const vendorSpecificProperties = [
4 'animation',
5 'animationDelay',
6 'animationDirection',
7 'animationDuration',
8 'animationFillMode',
9 'animationIterationCount',
10 'animationName',
11 'animationPlayState',
12 'animationTimingFunction',
13 'appearance',
14 'backfaceVisibility',
15 'backgroundClip',
16 'borderImage',
17 'borderImageSlice',
18 'boxSizing',
19 'boxShadow',
20 'contentColumns',
21 'transform',
22 'transformOrigin',
23 'transformStyle',
24 'transition',
25 'transitionDelay',
26 'transitionDuration',
27 'transitionProperty',
28 'transitionTimingFunction',
29 'perspective',
30 'perspectiveOrigin',
31 'userSelect',
32];
33const prefixes = ['Moz', 'Webkit', 'ms', 'O'];
34function prefixProp(key, value) {
35 return prefixes.reduce((obj, pre) => ((obj[pre + key[0].toUpperCase() + key.substr(1)] = value), obj), {});
36}
37export default function autoprefix(style) {
38 return Object.keys(style).reduce((obj, key) => vendorSpecificProperties.indexOf(key) !== -1
39 ? {
40 ...obj,
41 ...prefixProp(key, style[key]),
42 }
43 : obj, style);
44}