/**
 * Copyright 2013-present, 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.
 */ import { Plugin } from '../PluginsRegistry' ; /**
 * CSS properties which accept numbers but are not in units of "px".
 */ const isUnitlessNumber = { animationIterationCount : true , borderImageOutset : true , borderImageSlice : true , borderImageWidth : true , boxFlex : true , boxFlexGroup : true , boxOrdinalGroup : true , columnCount : true , flex : true , flexGrow : true , flexPositive : true , flexShrink : true , flexNegative : true , flexOrder : true , gridRow : true , gridColumn : true , fontWeight : true , lineClamp : true , lineHeight : true , opacity : true , order : true , orphans : true , tabSize : true , widows : true , zIndex : true , zoom : true , fillOpacity : true , floodOpacity : true , stopOpacity : true , strokeDasharray : true , strokeDashoffset : true , strokeMiterlimit : true , strokeOpacity : true , strokeWidth : true , } ; param prefix param key return 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.
 */ const prefixes = [ 'Webkit' , 'ms' , 'Moz' , 'O' ] ; Object . keys ( isUnitlessNumber ) . forEach ( prop => { prefixes . forEach ( ( prefix ) => { isUnitlessNumber [ prefixKey ( prefix , prop ) ] = isUnitlessNumber [ prop ] ; } ) ; } ) ; export type DefaultUnitOptions = { unit : string ; [ index ] : string ; } ; export default function defaultUnit ( options = { unit : 'px' } ) { const unit = options && options . unit || 'px' ; return ( _ , style ) => { for ( const prop in style ) { if ( style . hasOwnProperty ( prop ) ) { const value = style [ prop ] ; if ( typeof value === 'number' && ! isUnitlessNumber [ prop ] ) { style [ prop ] = value + ( options [ prop ] || unit ) ; } } } } ; }