Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function addUnit(
style: Object,
defaultUnit: string,
propertyMap: Object
): Object {
for (const property in style) {
if (!isUnitlessProperty(property)) {
const cssValue = style[property]
const propertyUnit = propertyMap[property] || defaultUnit
if (isPlainObject(cssValue)) {
style[property] = addUnit(cssValue, defaultUnit, propertyMap)
} else if (Array.isArray(cssValue)) {
style[property] = cssValue.map(val =>
addUnitIfNeeded(property, val, propertyUnit)
)
} else {
style[property] = addUnitIfNeeded(property, cssValue, propertyUnit)
}
}
}
return style
function addUnit(
style: Object,
defaultUnit: string,
propertyMap: Object
): Object {
for (const property in style) {
if (!isUnitlessProperty(property)) {
const cssValue = style[property]
const propertyUnit = propertyMap[property] || defaultUnit
if (isObject(cssValue)) {
style[property] = addUnit(cssValue, defaultUnit, propertyMap)
} else if (Array.isArray(cssValue)) {
style[property] = cssValue.map(val =>
addUnitIfNeeded(property, val, propertyUnit))
} else {
style[property] = addUnitIfNeeded(property, cssValue, propertyUnit)
}
}
}
return style
}