UNPKG

zent

Version:

一套前端设计语言和基于React的实现

17 lines (16 loc) 552 B
import { isUnitlessNumber } from './CSSProperty'; import { hasOwnProperty } from '../hasOwn'; function dangerousStyleValue(name, value, isCustomProperty) { var isEmpty = value == null || typeof value === 'boolean' || value === ''; if (isEmpty) { return ''; } if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(hasOwnProperty(isUnitlessNumber, name) && isUnitlessNumber[name])) { return value + 'px'; } return ('' + value).trim(); } export default dangerousStyleValue;