1
// https://github.com/facebook/react/blob/master/packages/react-dom/src/shared/CSSProperty.js
2

3
/**
4
 * CSS properties which accept numbers but are not in units of "px".
5
 */
6 3
export const isUnitlessNumber: { [key: string]: boolean } = {
7
  animationIterationCount: true,
8
  borderImageOutset: true,
9
  borderImageSlice: true,
10
  borderImageWidth: true,
11
  boxFlex: true,
12
  boxFlexGroup: true,
13
  boxOrdinalGroup: true,
14
  columnCount: true,
15
  columns: true,
16
  flex: true,
17
  flexGrow: true,
18
  flexPositive: true,
19
  flexShrink: true,
20
  flexNegative: true,
21
  flexOrder: true,
22
  gridArea: true,
23
  gridRow: true,
24
  gridRowEnd: true,
25
  gridRowSpan: true,
26
  gridRowStart: true,
27
  gridColumn: true,
28
  gridColumnEnd: true,
29
  gridColumnSpan: true,
30
  gridColumnStart: true,
31
  fontWeight: true,
32
  lineClamp: true,
33
  lineHeight: true,
34
  opacity: true,
35
  order: true,
36
  orphans: true,
37
  tabSize: true,
38
  widows: true,
39
  zIndex: true,
40
  zoom: true,
41

42
  // SVG-related properties
43
  fillOpacity: true,
44
  floodOpacity: true,
45
  stopOpacity: true,
46
  strokeDasharray: true,
47
  strokeDashoffset: true,
48
  strokeMiterlimit: true,
49
  strokeOpacity: true,
50
  strokeWidth: true,
51
};
52

53
/**
54
 * @param {string} prefix vendor-specific prefix, eg: Webkit
55
 * @param {string} key style name, eg: transitionDuration
56
 * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
57
 * WebkitTransitionDuration
58
 */
59 3
function prefixKey(prefix: string, key: string) {
60 3
  return prefix + key.charAt(0).toUpperCase() + key.substring(1);
61
}
62

63
/**
64
 * Support style names that may come passed in prefixed by adding permutations
65
 * of vendor prefixes.
66
 */
67 3
const prefixes = ['Webkit', 'ms', 'Moz', 'O'];
68

69 3
for (const prop in isUnitlessNumber) {
70 3
  prefixes.forEach(function (prefix) {
71 3
    isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
72
  });
73
}

Read our documentation on viewing source code .

Loading