diff --git a/src/util.js b/src/util.js index 72733db..7e9d39a 100644 --- a/src/util.js +++ b/src/util.js @@ -9,6 +9,9 @@ const UPPERCASE_RE = /([A-Z])/g; const UPPERCASE_RE_TO_KEBAB = (match /* : string */) /* : string */ => `-${match.toLowerCase()}`; export const kebabifyStyleName = (string /* : string */) /* : string */ => { + if (string[0] === '-' && string[1] === '-') { + return string; + } const result = string.replace(UPPERCASE_RE, UPPERCASE_RE_TO_KEBAB); if (result[0] === 'm' && result[1] === 's' && result[2] === '-') { return `-${result}`; diff --git a/tests/util_test.js b/tests/util_test.js index 1b2d774..7c61fc6 100644 --- a/tests/util_test.js +++ b/tests/util_test.js @@ -16,5 +16,8 @@ describe('Utils', () => { it('forces -ms-', () => { assert.equal(kebabifyStyleName('msFooBarBaz'), '-ms-foo-bar-baz'); }); + it('does not kebabify CSS Custom properties', () => { + assert.equal(kebabifyStyleName('--foo-Bar_Baz'), '--foo-Bar_Baz'); + }); }); });