[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
---|
| 4 | value: true
|
---|
| 5 | });
|
---|
| 6 | exports.default = createPrefixer;
|
---|
| 7 |
|
---|
| 8 | var _prefixProperty = require('./utils/prefixProperty');
|
---|
| 9 |
|
---|
| 10 | var _prefixProperty2 = _interopRequireDefault(_prefixProperty);
|
---|
| 11 |
|
---|
| 12 | var _prefixValue = require('./utils/prefixValue');
|
---|
| 13 |
|
---|
| 14 | var _prefixValue2 = _interopRequireDefault(_prefixValue);
|
---|
| 15 |
|
---|
| 16 | var _addNewValuesOnly = require('./utils/addNewValuesOnly');
|
---|
| 17 |
|
---|
| 18 | var _addNewValuesOnly2 = _interopRequireDefault(_addNewValuesOnly);
|
---|
| 19 |
|
---|
| 20 | var _isObject = require('./utils/isObject');
|
---|
| 21 |
|
---|
| 22 | var _isObject2 = _interopRequireDefault(_isObject);
|
---|
| 23 |
|
---|
| 24 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
---|
| 25 |
|
---|
| 26 | function createPrefixer(_ref) {
|
---|
| 27 | var prefixMap = _ref.prefixMap,
|
---|
| 28 | plugins = _ref.plugins;
|
---|
| 29 |
|
---|
| 30 | return function prefix(style) {
|
---|
| 31 | for (var property in style) {
|
---|
| 32 | var value = style[property];
|
---|
| 33 |
|
---|
| 34 | // handle nested objects
|
---|
| 35 | if ((0, _isObject2.default)(value)) {
|
---|
| 36 | style[property] = prefix(value);
|
---|
| 37 | // handle array values
|
---|
| 38 | } else if (Array.isArray(value)) {
|
---|
| 39 | var combinedValue = [];
|
---|
| 40 |
|
---|
| 41 | for (var i = 0, len = value.length; i < len; ++i) {
|
---|
| 42 | var processedValue = (0, _prefixValue2.default)(plugins, property, value[i], style, prefixMap);
|
---|
| 43 |
|
---|
| 44 | (0, _addNewValuesOnly2.default)(combinedValue, processedValue || value[i]);
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | // only modify the value if it was touched
|
---|
| 48 | // by any plugin to prevent unnecessary mutations
|
---|
| 49 | if (combinedValue.length > 0) {
|
---|
| 50 | style[property] = combinedValue;
|
---|
| 51 | }
|
---|
| 52 | } else {
|
---|
| 53 | var _processedValue = (0, _prefixValue2.default)(plugins, property, value, style, prefixMap);
|
---|
| 54 |
|
---|
| 55 | // only modify the value if it was touched
|
---|
| 56 | // by any plugin to prevent unnecessary mutations
|
---|
| 57 | if (_processedValue) {
|
---|
| 58 | style[property] = _processedValue;
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | style = (0, _prefixProperty2.default)(prefixMap, property, style);
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | return style;
|
---|
| 66 | };
|
---|
| 67 | } |
---|