Comparing version 3.0.3 to 3.0.4
@@ -29,16 +29,19 @@ 'use strict'; | ||
function addUnit(style, unit) { | ||
function addUnit(style, unit, propertyMap) { | ||
Object.keys(style).forEach(function (property) { | ||
if (!(0, _unitlessCssProperty2.default)(property)) { | ||
(function () { | ||
var value = style[property]; | ||
if (Array.isArray(value)) { | ||
style[property] = value.map(function (value) { | ||
return addUnitIfNeeded(property, value, unit); | ||
}); | ||
} else if (value instanceof Object) { | ||
style[property] = addUnit(value, unit); | ||
} else { | ||
style[property] = addUnitIfNeeded(property, value, unit); | ||
} | ||
var value = style[property]; | ||
var propertyUnit = propertyMap[property] || unit; | ||
if (Array.isArray(value)) { | ||
style[property] = value.map(function (value) { | ||
return addUnitIfNeeded(property, value, propertyUnit); | ||
}); | ||
} else if (value instanceof Object) { | ||
style[property] = addUnit(value, unit, propertyMap); | ||
} else { | ||
style[property] = addUnitIfNeeded(property, value, propertyUnit); | ||
} | ||
})(); | ||
} | ||
@@ -52,2 +55,3 @@ }); | ||
var unit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'px'; | ||
var propertyMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
@@ -57,3 +61,3 @@ process.env.NODE_ENV !== "production" ? (0, _warning2.default)(unit.match(/ch|em|ex|rem|vh|vw|vmin|vmax|px|cm|mm|in|pc|pt|mozmm|%/) !== null, 'You are using an invalid unit `' + unit + '`. Consider using one of the following ch, em, ex, rem, vh, vw, vmin, vmax, px, cm, mm, in, pc, pt, mozmm or %.') : void 0; | ||
return function (style) { | ||
return addUnit(style, unit); | ||
return addUnit(style, unit, propertyMap); | ||
}; | ||
@@ -60,0 +64,0 @@ }; |
{ | ||
"name": "fela", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"description": "Fast & Dynamic Styling in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
127594
44
1961
52962