benchmark/packages/302/dynamic/plugins/flexboxOld.js
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = flexboxOld;
var _getPrefixedValue = require('../../utils/getPrefixedValue');
var _getPrefixedValue2 = _interopRequireDefault(_getPrefixedValue);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var alternativeValues = {
'space-around': 'justify',
'space-between': 'justify',
'flex-start': 'start',
'flex-end': 'end',
'wrap-reverse': 'multiple',
wrap: 'multiple',
flex: 'box',
'inline-flex': 'inline-box'
};
var alternativeProps = {
alignItems: 'WebkitBoxAlign',
justifyContent: 'WebkitBoxPack',
flexWrap: 'WebkitBoxLines'
};
var otherProps = ['alignContent', 'alignSelf', 'order', 'flexGrow', 'flexShrink', 'flexBasis', 'flexDirection'];
var properties = Object.keys(alternativeProps).concat(otherProps);
function flexboxOld(property, value, style, _ref) {
var browserName = _ref.browserName,
browserVersion = _ref.browserVersion,
cssPrefix = _ref.cssPrefix,
keepUnprefixed = _ref.keepUnprefixed,
requiresPrefix = _ref.requiresPrefix;
if ((properties.indexOf(property) > -1 || property === 'display' && typeof value === 'string' && value.indexOf('flex') > -1) && (browserName === 'firefox' && browserVersion < 22 || browserName === 'chrome' && browserVersion < 21 || (browserName === 'safari' || browserName === 'ios_saf') && browserVersion <= 6.1 || browserName === 'android' && browserVersion < 4.4 || browserName === 'and_uc')) {
delete requiresPrefix[property];
if (!keepUnprefixed && !Array.isArray(style[property])) {
delete style[property];
}
if (property === 'flexDirection' && typeof value === 'string') {
if (value.indexOf('column') > -1) {
style.WebkitBoxOrient = 'vertical';
} else {
style.WebkitBoxOrient = 'horizontal';
}
if (value.indexOf('reverse') > -1) {
style.WebkitBoxDirection = 'reverse';
} else {
style.WebkitBoxDirection = 'normal';
}
}
if (property === 'display' && alternativeValues.hasOwnProperty(value)) {
return (0, _getPrefixedValue2.default)(cssPrefix + alternativeValues[value], value, keepUnprefixed);
}
if (alternativeProps.hasOwnProperty(property)) {
style[alternativeProps[property]] = alternativeValues[value] || value;
}
}
}
module.exports = exports['default'];