react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / browser / ui / dom / CSSProperty.js
81159 views/**1* Copyright 2013-2014, Facebook, Inc.2* All rights reserved.3*4* This source code is licensed under the BSD-style license found in the5* LICENSE file in the root directory of this source tree. An additional grant6* of patent rights can be found in the PATENTS file in the same directory.7*8* @providesModule CSSProperty9*/1011"use strict";1213/**14* CSS properties which accept numbers but are not in units of "px".15*/16var isUnitlessNumber = {17columnCount: true,18flex: true,19flexGrow: true,20flexShrink: true,21fontWeight: true,22lineClamp: true,23lineHeight: true,24opacity: true,25order: true,26orphans: true,27widows: true,28zIndex: true,29zoom: true,3031// SVG-related properties32fillOpacity: true,33strokeOpacity: true34};3536/**37* @param {string} prefix vendor-specific prefix, eg: Webkit38* @param {string} key style name, eg: transitionDuration39* @return {string} style name prefixed with `prefix`, properly camelCased, eg:40* WebkitTransitionDuration41*/42function prefixKey(prefix, key) {43return prefix + key.charAt(0).toUpperCase() + key.substring(1);44}4546/**47* Support style names that may come passed in prefixed by adding permutations48* of vendor prefixes.49*/50var prefixes = ['Webkit', 'ms', 'Moz', 'O'];5152// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an53// infinite loop, because it iterates over the newly added props too.54Object.keys(isUnitlessNumber).forEach(function(prop) {55prefixes.forEach(function(prefix) {56isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];57});58});5960/**61* Most style properties can be unset by doing .style[prop] = '' but IE862* doesn't like doing that with shorthand properties so for the properties that63* IE8 breaks on, which are listed here, we instead unset each of the64* individual properties. See http://bugs.jquery.com/ticket/12385.65* The 4-value 'clock' properties like margin, padding, border-width seem to66* behave without any problems. Curiously, list-style works too without any67* special prodding.68*/69var shorthandPropertyExpansions = {70background: {71backgroundImage: true,72backgroundPosition: true,73backgroundRepeat: true,74backgroundColor: true75},76border: {77borderWidth: true,78borderStyle: true,79borderColor: true80},81borderBottom: {82borderBottomWidth: true,83borderBottomStyle: true,84borderBottomColor: true85},86borderLeft: {87borderLeftWidth: true,88borderLeftStyle: true,89borderLeftColor: true90},91borderRight: {92borderRightWidth: true,93borderRightStyle: true,94borderRightColor: true95},96borderTop: {97borderTopWidth: true,98borderTopStyle: true,99borderTopColor: true100},101font: {102fontStyle: true,103fontVariant: true,104fontWeight: true,105fontSize: true,106lineHeight: true,107fontFamily: true108}109};110111var CSSProperty = {112isUnitlessNumber: isUnitlessNumber,113shorthandPropertyExpansions: shorthandPropertyExpansions114};115116module.exports = CSSProperty;117118119