source: imaps-frontend/node_modules/inline-style-prefixer/es/createPrefixer.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.4 KB
Line 
1import prefixProperty from './utils/prefixProperty';
2import prefixValue from './utils/prefixValue';
3
4import addNewValuesOnly from './utils/addNewValuesOnly';
5import isObject from './utils/isObject';
6
7export default function createPrefixer(_ref) {
8 var prefixMap = _ref.prefixMap,
9 plugins = _ref.plugins;
10
11 return function prefix(style) {
12 for (var property in style) {
13 var value = style[property];
14
15 // handle nested objects
16 if (isObject(value)) {
17 style[property] = prefix(value);
18 // handle array values
19 } else if (Array.isArray(value)) {
20 var combinedValue = [];
21
22 for (var i = 0, len = value.length; i < len; ++i) {
23 var processedValue = prefixValue(plugins, property, value[i], style, prefixMap);
24
25 addNewValuesOnly(combinedValue, processedValue || value[i]);
26 }
27
28 // only modify the value if it was touched
29 // by any plugin to prevent unnecessary mutations
30 if (combinedValue.length > 0) {
31 style[property] = combinedValue;
32 }
33 } else {
34 var _processedValue = prefixValue(plugins, property, value, style, prefixMap);
35
36 // only modify the value if it was touched
37 // by any plugin to prevent unnecessary mutations
38 if (_processedValue) {
39 style[property] = _processedValue;
40 }
41
42 style = prefixProperty(prefixMap, property, style);
43 }
44 }
45
46 return style;
47 };
48}
Note: See TracBrowser for help on using the repository browser.