Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80536 views
1
/**
2
* Copyright 2013-2015, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule CSSProperty
10
*/
11
12
'use strict';
13
14
/**
15
* CSS properties which accept numbers but are not in units of "px".
16
*/
17
var isUnitlessNumber = {
18
boxFlex: true,
19
boxFlexGroup: true,
20
columnCount: true,
21
flex: true,
22
flexGrow: true,
23
flexPositive: true,
24
flexShrink: true,
25
flexNegative: true,
26
fontWeight: true,
27
lineClamp: true,
28
lineHeight: true,
29
opacity: true,
30
order: true,
31
orphans: true,
32
widows: true,
33
zIndex: true,
34
zoom: true,
35
36
// SVG-related properties
37
fillOpacity: true,
38
strokeDashoffset: true,
39
strokeOpacity: true,
40
strokeWidth: true
41
};
42
43
/**
44
* @param {string} prefix vendor-specific prefix, eg: Webkit
45
* @param {string} key style name, eg: transitionDuration
46
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
47
* WebkitTransitionDuration
48
*/
49
function prefixKey(prefix, key) {
50
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
51
}
52
53
/**
54
* Support style names that may come passed in prefixed by adding permutations
55
* of vendor prefixes.
56
*/
57
var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
58
59
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
60
// infinite loop, because it iterates over the newly added props too.
61
Object.keys(isUnitlessNumber).forEach(function(prop) {
62
prefixes.forEach(function(prefix) {
63
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
64
});
65
});
66
67
/**
68
* Most style properties can be unset by doing .style[prop] = '' but IE8
69
* doesn't like doing that with shorthand properties so for the properties that
70
* IE8 breaks on, which are listed here, we instead unset each of the
71
* individual properties. See http://bugs.jquery.com/ticket/12385.
72
* The 4-value 'clock' properties like margin, padding, border-width seem to
73
* behave without any problems. Curiously, list-style works too without any
74
* special prodding.
75
*/
76
var shorthandPropertyExpansions = {
77
background: {
78
backgroundImage: true,
79
backgroundPosition: true,
80
backgroundRepeat: true,
81
backgroundColor: true
82
},
83
border: {
84
borderWidth: true,
85
borderStyle: true,
86
borderColor: true
87
},
88
borderBottom: {
89
borderBottomWidth: true,
90
borderBottomStyle: true,
91
borderBottomColor: true
92
},
93
borderLeft: {
94
borderLeftWidth: true,
95
borderLeftStyle: true,
96
borderLeftColor: true
97
},
98
borderRight: {
99
borderRightWidth: true,
100
borderRightStyle: true,
101
borderRightColor: true
102
},
103
borderTop: {
104
borderTopWidth: true,
105
borderTopStyle: true,
106
borderTopColor: true
107
},
108
font: {
109
fontStyle: true,
110
fontVariant: true,
111
fontWeight: true,
112
fontSize: true,
113
lineHeight: true,
114
fontFamily: true
115
}
116
};
117
118
var CSSProperty = {
119
isUnitlessNumber: isUnitlessNumber,
120
shorthandPropertyExpansions: shorthandPropertyExpansions
121
};
122
123
module.exports = CSSProperty;
124
125