From cef57fd3240295e677a956d4a96fb1fa9490010a Mon Sep 17 00:00:00 2001 From: Maja Wichrowska Date: Fri, 6 Oct 2017 13:59:52 -0700 Subject: [PATCH] Allow for boolean values for styles --- src/__tests__/index.js | 2 ++ src/core/utils.js | 5 +++++ src/index.js | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/__tests__/index.js b/src/__tests__/index.js index 8b002d4..42c531a 100644 --- a/src/__tests__/index.js +++ b/src/__tests__/index.js @@ -348,6 +348,8 @@ const unchanged = [ [{transform: 'translateZ(30px)'}], [{content: 'left'}], [{content: 'right'}], + [{foo: true}], + [{foo: false}], ] shortTests.forEach(shortTest => { diff --git a/src/core/utils.js b/src/core/utils.js index 10739cb..9f12df9 100644 --- a/src/core/utils.js +++ b/src/core/utils.js @@ -11,6 +11,10 @@ function arrayToObject(array) { }, {}) } +function isBoolean(val) { + return typeof val === 'boolean' +} + function isNumber(val) { return typeof val === 'number' } @@ -130,6 +134,7 @@ export { flipSign, handleQuartetValues, includes, + isBoolean, isNullOrUndefined, isNumber, isObject, diff --git a/src/index.js b/src/index.js index 1707add..b6904b2 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,7 @@ import { includes, arrayToObject, + isBoolean, isNumber, isObject, isString, @@ -108,8 +109,8 @@ function getPropertyDoppelganger(property) { * @return {String|Number|Object} the converted value */ function getValueDoppelganger(key, originalValue) { - /* eslint complexity:[2, 7] */ // let's try to keep the complexity down... If we have to do this much more, let's break this up - if (isNullOrUndefined(originalValue)) { + /* eslint complexity:[2, 8] */ // let's try to keep the complexity down... If we have to do this much more, let's break this up + if (isNullOrUndefined(originalValue) || isBoolean(originalValue)) { return originalValue }