forked from robinweser/inline-style-prefixer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflexboxIE.js
More file actions
55 lines (51 loc) · 1.49 KB
/
flexboxIE.js
File metadata and controls
55 lines (51 loc) · 1.49 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
/* @flow */
import getPrefixedValue from '../../utils/getPrefixedValue'
import type { PluginMetaData } from '../../../flowtypes/PluginMetaData'
const alternativeValues = {
'space-around': 'distribute',
'space-between': 'justify',
'flex-start': 'start',
'flex-end': 'end',
flex: 'flexbox',
'inline-flex': 'inline-flexbox'
}
const alternativeProps = {
alignContent: 'msFlexLinePack',
alignSelf: 'msFlexItemAlign',
alignItems: 'msFlexAlign',
justifyContent: 'msFlexPack',
order: 'msFlexOrder',
flexGrow: 'msFlexPositive',
flexShrink: 'msFlexNegative',
flexBasis: 'msPreferredSize'
}
export default function flexboxIE(
property: string,
value: any,
style: Object,
{
browserName,
browserVersion,
cssPrefix,
keepUnprefixed,
requiresPrefix
}:
PluginMetaData
): ?Array<any> | ?any {
if (
(alternativeProps.hasOwnProperty(property) ||
property === 'display' && typeof value === 'string' && value.indexOf('flex') > -1) &&
((browserName === 'ie_mob' || browserName === 'ie') && browserVersion === 10)
) {
delete requiresPrefix[property]
if (!keepUnprefixed && !Array.isArray(style[property])) {
delete style[property]
}
if (property === 'display' && alternativeValues.hasOwnProperty(value)) {
return getPrefixedValue(cssPrefix + alternativeValues[value], value, keepUnprefixed)
}
if (alternativeProps.hasOwnProperty(property)) {
style[alternativeProps[property]] = alternativeValues[value] || value
}
}
}