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) => {