forked from robinweser/inline-style-prefixer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflexboxOld.js
More file actions
80 lines (74 loc) · 2.16 KB
/
flexboxOld.js
File metadata and controls
80 lines (74 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* @flow */
import getPrefixedValue from '../../utils/getPrefixedValue'
import type { PluginMetaData } from '../../../flowtypes/PluginMetaData'
const alternativeValues = {
'space-around': 'justify',
'space-between': 'justify',
'flex-start': 'start',
'flex-end': 'end',
'wrap-reverse': 'multiple',
wrap: 'multiple',
flex: 'box',
'inline-flex': 'inline-box'
}
const alternativeProps = {
alignItems: 'WebkitBoxAlign',
justifyContent: 'WebkitBoxPack',
flexWrap: 'WebkitBoxLines'
}
const otherProps = [
'alignContent',
'alignSelf',
'order',
'flexGrow',
'flexShrink',
'flexBasis',
'flexDirection'
]
const properties = Object.keys(alternativeProps).concat(otherProps)
export default function flexboxOld(
property: string,
value: any,
style: Object,
{
browserName,
browserVersion,
cssPrefix,
keepUnprefixed,
requiresPrefix
}:
PluginMetaData
): ?Array<any> | ?any {
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 getPrefixedValue(cssPrefix + alternativeValues[value], value, keepUnprefixed)
}
if (alternativeProps.hasOwnProperty(property)) {
style[alternativeProps[property]] = alternativeValues[value] || value
}
}
}