Skip to content

Commit 2f33fd9

Browse files
committed
Remove automatic camel-casing of CSS custom properties
Fix #50
1 parent 429e2fe commit 2f33fd9

File tree

2 files changed

+1
-30
lines changed

2 files changed

+1
-30
lines changed

packages/react-strict-dom/src/native/stylex/customProperties.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@ import { errorMsg } from '../../shared/errorMsg';
1414
export type MutableCustomProperties = { [string]: string | number };
1515
export type CustomProperties = $ReadOnly<MutableCustomProperties>;
1616

17-
function camelize(s: string): string {
18-
return s.replace(/-./g, (x) => x.toUpperCase()[1]);
19-
}
20-
2117
function normalizeVariableName(name: string): string {
2218
if (!name.startsWith('--')) {
2319
throw new Error("Invalid variable name, must begin with '--'");
2420
}
25-
return camelize(name.substring(2));
21+
return name.substring(2);
2622
}
2723

2824
export function stringContainsVariables(input: string): boolean {

packages/react-strict-dom/tests/css-test.native.js

-25
Original file line numberDiff line numberDiff line change
@@ -1119,31 +1119,6 @@ describe('properties: custom property', () => {
11191119
).toEqual('blue');
11201120
});
11211121

1122-
// TODO: this transform should not be supported. Custom properties are case sensitive.
1123-
test('parses kebab case var to camel case', () => {
1124-
const customProperties = { testVar: 'red' };
1125-
expect(
1126-
resolveCustomPropertyValue(customProperties, ['color', 'var(--test-var)'])
1127-
).toEqual('red');
1128-
});
1129-
1130-
// TODO: this transform should not be supported. Custom properties are case sensitive.
1131-
test('parses kebab case var with a default value', () => {
1132-
const customProperties = { testVar: 'red' };
1133-
expect(
1134-
resolveCustomPropertyValue(customProperties, [
1135-
'color',
1136-
'var(--test-var, blue)'
1137-
])
1138-
).toEqual('red');
1139-
expect(
1140-
resolveCustomPropertyValue(customProperties, [
1141-
'color',
1142-
'var(--not-found, blue)'
1143-
])
1144-
).toEqual('blue');
1145-
});
1146-
11471122
test('parses a var with a default value containing spaces', () => {
11481123
const customProperties = { color: 'rgb(0,0,0)' };
11491124
expect(

0 commit comments

Comments
 (0)