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