You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.1 KiB
123 lines
3.1 KiB
/** |
|
* Copyright 2013-2015, Facebook, Inc. |
|
* All rights reserved. |
|
* |
|
* This source code is licensed under the BSD-style license found in the |
|
* LICENSE file in the root directory of this source tree. An additional grant |
|
* of patent rights can be found in the PATENTS file in the same directory. |
|
* |
|
* @providesModule CSSProperty |
|
*/ |
|
|
|
'use strict'; |
|
|
|
/** |
|
* CSS properties which accept numbers but are not in units of "px". |
|
*/ |
|
var isUnitlessNumber = { |
|
boxFlex: true, |
|
boxFlexGroup: true, |
|
columnCount: true, |
|
flex: true, |
|
flexGrow: true, |
|
flexPositive: true, |
|
flexShrink: true, |
|
flexNegative: true, |
|
fontWeight: true, |
|
lineClamp: true, |
|
lineHeight: true, |
|
opacity: true, |
|
order: true, |
|
orphans: true, |
|
widows: true, |
|
zIndex: true, |
|
zoom: true, |
|
|
|
// SVG-related properties |
|
fillOpacity: true, |
|
strokeDashoffset: true, |
|
strokeOpacity: true, |
|
strokeWidth: true |
|
}; |
|
|
|
/** |
|
* @param {string} prefix vendor-specific prefix, eg: Webkit |
|
* @param {string} key style name, eg: transitionDuration |
|
* @return {string} style name prefixed with `prefix`, properly camelCased, eg: |
|
* WebkitTransitionDuration |
|
*/ |
|
function prefixKey(prefix, key) { |
|
return prefix + key.charAt(0).toUpperCase() + key.substring(1); |
|
} |
|
|
|
/** |
|
* Support style names that may come passed in prefixed by adding permutations |
|
* of vendor prefixes. |
|
*/ |
|
var prefixes = ['Webkit', 'ms', 'Moz', 'O']; |
|
|
|
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an |
|
// infinite loop, because it iterates over the newly added props too. |
|
Object.keys(isUnitlessNumber).forEach(function(prop) { |
|
prefixes.forEach(function(prefix) { |
|
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop]; |
|
}); |
|
}); |
|
|
|
/** |
|
* Most style properties can be unset by doing .style[prop] = '' but IE8 |
|
* doesn't like doing that with shorthand properties so for the properties that |
|
* IE8 breaks on, which are listed here, we instead unset each of the |
|
* individual properties. See http://bugs.jquery.com/ticket/12385. |
|
* The 4-value 'clock' properties like margin, padding, border-width seem to |
|
* behave without any problems. Curiously, list-style works too without any |
|
* special prodding. |
|
*/ |
|
var shorthandPropertyExpansions = { |
|
background: { |
|
backgroundImage: true, |
|
backgroundPosition: true, |
|
backgroundRepeat: true, |
|
backgroundColor: true |
|
}, |
|
border: { |
|
borderWidth: true, |
|
borderStyle: true, |
|
borderColor: true |
|
}, |
|
borderBottom: { |
|
borderBottomWidth: true, |
|
borderBottomStyle: true, |
|
borderBottomColor: true |
|
}, |
|
borderLeft: { |
|
borderLeftWidth: true, |
|
borderLeftStyle: true, |
|
borderLeftColor: true |
|
}, |
|
borderRight: { |
|
borderRightWidth: true, |
|
borderRightStyle: true, |
|
borderRightColor: true |
|
}, |
|
borderTop: { |
|
borderTopWidth: true, |
|
borderTopStyle: true, |
|
borderTopColor: true |
|
}, |
|
font: { |
|
fontStyle: true, |
|
fontVariant: true, |
|
fontWeight: true, |
|
fontSize: true, |
|
lineHeight: true, |
|
fontFamily: true |
|
} |
|
}; |
|
|
|
var CSSProperty = { |
|
isUnitlessNumber: isUnitlessNumber, |
|
shorthandPropertyExpansions: shorthandPropertyExpansions |
|
}; |
|
|
|
module.exports = CSSProperty;
|
|
|