Skip to content

Commit

Permalink
Extract regular expression into constant
Browse files Browse the repository at this point in the history
Replace inline regular expression used for capturing CSS custom property
names.
  • Loading branch information
necolas committed Jan 23, 2025
1 parent 8ffacbf commit c8f9de8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/react-strict-dom/src/native/stylex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ export function props(

type Tokens = { [string]: string };
let count = 1;
const RE_CAPTURE_VAR_NAME = /^var\(--(.*)\)$/;

export const __customProperties: MutableCustomProperties = {};

Expand All @@ -672,7 +673,7 @@ export const createTheme = (
const result: MutableCustomProperties = { $$theme: 'theme' };
for (const key in baseTokens) {
const varName: string = baseTokens[key];
const normalizedKey = varName.replace(/^var\(--(.*)\)$/, '$1');
const normalizedKey = varName.replace(RE_CAPTURE_VAR_NAME, '$1');
result[normalizedKey] = overrides[key];
}
return result;
Expand Down

0 comments on commit c8f9de8

Please sign in to comment.