diff --git a/packages/@stylexjs/stylex/__tests__/stylex-test.js b/packages/@stylexjs/stylex/__tests__/stylex-test.js index 87996f107..89342c10e 100644 --- a/packages/@stylexjs/stylex/__tests__/stylex-test.js +++ b/packages/@stylexjs/stylex/__tests__/stylex-test.js @@ -317,6 +317,7 @@ describe('stylex', () => { marginTop: '10px', opacity: 0.5, '--foo': 2, + '--fooBar': 3, MsTransition: 'none', WebkitTapHighlightColor: 'transparent', }, @@ -325,7 +326,7 @@ describe('stylex', () => { { "class": "backgroundColor-red", "data-style-src": "components/Foo.react.js:1", - "style": "color:red;margin-top:10px;opacity:0.5;--foo:2;-ms-transition:none;-webkit-tap-highlight-color:transparent", + "style": "color:red;margin-top:10px;opacity:0.5;--foo:2;--fooBar:3;-ms-transition:none;-webkit-tap-highlight-color:transparent", } `); }); diff --git a/packages/@stylexjs/stylex/src/stylex.js b/packages/@stylexjs/stylex/src/stylex.js index e7a505c43..1ebbc5661 100644 --- a/packages/@stylexjs/stylex/src/stylex.js +++ b/packages/@stylexjs/stylex/src/stylex.js @@ -193,7 +193,13 @@ export function attrs( } if (style != null) { result.style = Object.entries(style) - .map(([key, value]) => `${toKebabCase(key)}:${value}`) + .map(([key, value]) => { + if (key.startsWith('--')) { + return `${key}:${value}`; + } + + return `${toKebabCase(key)}:${value}`; + }) .join(';'); } if (dataStyleSrc != null) {