Skip to content

Commit a27ba6f

Browse files
authored
Merge pull request #85 from kristerkari/bugfix/dont-use-camel-case-for-css-custom-properties
Allow CSS custom properties to be used without converting to camel case
2 parents e8ec489 + a3556fb commit a27ba6f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/__tests__/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ it('allows undefined values', () => {
4747
})
4848
})
4949

50+
it('allows CSS custom properties to pass through', () => {
51+
expect(transformCss([['--my-prop', '0%']])).toEqual({ '--my-prop': '0%' })
52+
})
53+
5054
it('allows percent in unspecialized transform', () => {
5155
expect(transformCss([['top', '0%']])).toEqual({ top: '0%' })
5256
})

src/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ export const getStylesForProperty = (propName, inputValue, allowShorthand) => {
5959
: { [propName]: propValue }
6060
}
6161

62-
export const getPropertyName = camelizeStyleName
62+
export const getPropertyName = propName => {
63+
const isCustomProp = /^--\w+/.test(propName)
64+
if (isCustomProp) {
65+
return propName
66+
}
67+
return camelizeStyleName(propName)
68+
}
6369

6470
export default (rules, shorthandBlacklist = []) =>
6571
rules.reduce((accum, rule) => {

0 commit comments

Comments
 (0)