|
1 | 1 | /* @flow */ |
2 | | -import isUnitlessCSSProperty from 'unitless-css-property' |
| 2 | +import hyphenateProperty from './hyphenateProperty' |
| 3 | + |
| 4 | +const unitlessProperties = { |
| 5 | + borderImageOutset: true, |
| 6 | + borderImageSlice: true, |
| 7 | + borderImageWidth: true, |
| 8 | + fontWeight: true, |
| 9 | + lineHeight: true, |
| 10 | + opacity: true, |
| 11 | + orphans: true, |
| 12 | + tabSize: true, |
| 13 | + widows: true, |
| 14 | + zIndex: true, |
| 15 | + zoom: true, |
| 16 | + |
| 17 | + // SVG-related properties |
| 18 | + fillOpacity: true, |
| 19 | + floodOpacity: true, |
| 20 | + stopOpacity: true, |
| 21 | + strokeDasharray: true, |
| 22 | + strokeDashoffset: true, |
| 23 | + strokeMiterlimit: true, |
| 24 | + strokeOpacity: true, |
| 25 | + strokeWidth: true |
| 26 | +} |
| 27 | + |
| 28 | +const prefixedUnitlessProperties = [ |
| 29 | +'animationIterationCount', |
| 30 | + 'boxFlex', |
| 31 | + 'boxFlexGroup', |
| 32 | + 'boxOrdinalGroup', |
| 33 | + 'columnCount', |
| 34 | + 'flex', |
| 35 | + 'flexGrow', |
| 36 | + 'flexPositive', |
| 37 | + 'flexShrink', |
| 38 | + 'flexNegative', |
| 39 | + 'flexOrder', |
| 40 | + 'gridRow', |
| 41 | + 'gridColumn', |
| 42 | + 'order', |
| 43 | + 'lineClamp' |
| 44 | +] |
| 45 | + |
| 46 | +const prefixes = ['Webkit', 'ms', 'Moz', 'O'] |
| 47 | + |
| 48 | +function getPrefixedProperty(prefix, property) { |
| 49 | + return prefix + property.charAt(0).toUpperCase() + property.slice(1) |
| 50 | +} |
| 51 | + |
| 52 | +// add all prefixed properties to the unitless properties |
| 53 | +for (let i = 0, len = prefixedUnitlessProperties.length; i < len; ++i) { |
| 54 | + unitlessProperties[property] = true |
| 55 | + |
| 56 | + for (let j = 0, jLen = prefixes.length; j < jLen; ++i) { |
| 57 | + unitlessProperties[getPrefixedProperty(prefix, property)] = true |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | + |
| 62 | +// add all hypenated properties as well |
| 63 | +for (const property in unitlessProperties) { |
| 64 | + unitlessProperties[hyphenateStyleName(property)] = true |
| 65 | +} |
3 | 66 |
|
4 | 67 | export default function isUnitlessProperty(property: string): boolean { |
5 | | - return isUnitlessCSSProperty(property) |
| 68 | + return unitlessProperties.hasOwnProperty(property) |
6 | 69 | } |
0 commit comments