From a3556fb621404e7ac041bae71c915ca51c16fbc1 Mon Sep 17 00:00:00 2001 From: krister Date: Mon, 18 Jun 2018 14:59:00 +0300 Subject: [PATCH] Allow CSS custom properties to be used without converting to camel case --- src/__tests__/index.js | 4 ++++ src/index.js | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/__tests__/index.js b/src/__tests__/index.js index 75bc10f..1f32b83 100644 --- a/src/__tests__/index.js +++ b/src/__tests__/index.js @@ -47,6 +47,10 @@ it('allows undefined values', () => { }) }) +it('allows CSS custom properties to pass through', () => { + expect(transformCss([['--my-prop', '0%']])).toEqual({ '--my-prop': '0%' }) +}) + it('allows percent in unspecialized transform', () => { expect(transformCss([['top', '0%']])).toEqual({ top: '0%' }) }) diff --git a/src/index.js b/src/index.js index 2b678f6..0f1ad9c 100644 --- a/src/index.js +++ b/src/index.js @@ -59,7 +59,13 @@ export const getStylesForProperty = (propName, inputValue, allowShorthand) => { : { [propName]: propValue } } -export const getPropertyName = camelizeStyleName +export const getPropertyName = propName => { + const isCustomProp = /^--\w+/.test(propName) + if (isCustomProp) { + return propName + } + return camelizeStyleName(propName) +} export default (rules, shorthandBlacklist = []) => rules.reduce((accum, rule) => {