跳到主要内容

is unitless number

一、作用

二、默认导出

export default function (name: string): boolean {
return unitlessNumbers.has(name);
}

常量

1. 无单位数字

/**
* CSS properties which accept numbers but are not in units of "px".
*
* 接受数字但不以“px”为单位的 CSS 属性。
*/
const unitlessNumbers = new Set([
'animationIterationCount',
'aspectRatio',
'borderImageOutset',
'borderImageSlice',
'borderImageWidth',
'boxFlex',
'boxFlexGroup',
'boxOrdinalGroup',
'columnCount',
'columns',
'flex',
'flexGrow',
'flexPositive',
'flexShrink',
'flexNegative',
'flexOrder',
'gridArea',
'gridRow',
'gridRowEnd',
'gridRowSpan',
'gridRowStart',
'gridColumn',
'gridColumnEnd',
'gridColumnSpan',
'gridColumnStart',
'fontWeight',
'lineClamp',
'lineHeight',
'opacity',
'order',
'orphans',
'scale',
'tabSize',
'widows',
'zIndex',
'zoom',
// 与 SVG 相关的属性
'fillOpacity', // SVG-related properties
'floodOpacity',
'stopOpacity',
'strokeDasharray',
'strokeDashoffset',
'strokeMiterlimit',
'strokeOpacity',
'strokeWidth',
// 已知的带前缀属性
'MozAnimationIterationCount', // Known Prefixed Properties
// TODO: 删除这些,因为它们不应该在现代代码中使用
'MozBoxFlex', // TODO: Remove these since they shouldn't be used in modern code
'MozBoxFlexGroup',
'MozLineClamp',
'msAnimationIterationCount',
'msFlex',
'msZoom',
'msFlexGrow',
'msFlexNegative',
'msFlexOrder',
'msFlexPositive',
'msFlexShrink',
'msGridColumn',
'msGridColumnSpan',
'msGridRow',
'msGridRowSpan',
'WebkitAnimationIterationCount',
'WebkitBoxFlex',
'WebKitBoxFlexGroup',
'WebkitBoxOrdinalGroup',
'WebkitColumnCount',
'WebkitColumns',
'WebkitFlex',
'WebkitFlexGrow',
'WebkitFlexPositive',
'WebkitFlexShrink',
'WebkitLineClamp',
]);