From 60710ee2cf34b5e6f922bab47adb38439d74b512 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Wed, 3 Apr 2024 16:08:57 -0700 Subject: [PATCH] Remove automatic camel-casing of CSS custom properties Fix #50 --- .../src/native/stylex/customProperties.js | 6 +---- .../react-strict-dom/tests/css-test.native.js | 25 ------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/packages/react-strict-dom/src/native/stylex/customProperties.js b/packages/react-strict-dom/src/native/stylex/customProperties.js index 33f8731..cd8b595 100644 --- a/packages/react-strict-dom/src/native/stylex/customProperties.js +++ b/packages/react-strict-dom/src/native/stylex/customProperties.js @@ -14,15 +14,11 @@ import { errorMsg } from '../../shared/errorMsg'; export type MutableCustomProperties = { [string]: string | number }; export type CustomProperties = $ReadOnly; -function camelize(s: string): string { - return s.replace(/-./g, (x) => x.toUpperCase()[1]); -} - function normalizeVariableName(name: string): string { if (!name.startsWith('--')) { throw new Error("Invalid variable name, must begin with '--'"); } - return camelize(name.substring(2)); + return name.substring(2); } export function stringContainsVariables(input: string): boolean { diff --git a/packages/react-strict-dom/tests/css-test.native.js b/packages/react-strict-dom/tests/css-test.native.js index 3a4707a..cda60f7 100644 --- a/packages/react-strict-dom/tests/css-test.native.js +++ b/packages/react-strict-dom/tests/css-test.native.js @@ -1119,31 +1119,6 @@ describe('properties: custom property', () => { ).toEqual('blue'); }); - // TODO: this transform should not be supported. Custom properties are case sensitive. - test('parses kebab case var to camel case', () => { - const customProperties = { testVar: 'red' }; - expect( - resolveCustomPropertyValue(customProperties, ['color', 'var(--test-var)']) - ).toEqual('red'); - }); - - // TODO: this transform should not be supported. Custom properties are case sensitive. - test('parses kebab case var with a default value', () => { - const customProperties = { testVar: 'red' }; - expect( - resolveCustomPropertyValue(customProperties, [ - 'color', - 'var(--test-var, blue)' - ]) - ).toEqual('red'); - expect( - resolveCustomPropertyValue(customProperties, [ - 'color', - 'var(--not-found, blue)' - ]) - ).toEqual('blue'); - }); - test('parses a var with a default value containing spaces', () => { const customProperties = { color: 'rgb(0,0,0)' }; expect(