Skip to content

Commit c8f9de8

Browse files
committed
Extract regular expression into constant
Replace inline regular expression used for capturing CSS custom property names.
1 parent 8ffacbf commit c8f9de8

File tree

1 file changed

+2
-1
lines changed
  • packages/react-strict-dom/src/native/stylex

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ export function props(
648648

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

652653
export const __customProperties: MutableCustomProperties = {};
653654

@@ -672,7 +673,7 @@ export const createTheme = (
672673
const result: MutableCustomProperties = { $$theme: 'theme' };
673674
for (const key in baseTokens) {
674675
const varName: string = baseTokens[key];
675-
const normalizedKey = varName.replace(/^var\(--(.*)\)$/, '$1');
676+
const normalizedKey = varName.replace(RE_CAPTURE_VAR_NAME, '$1');
676677
result[normalizedKey] = overrides[key];
677678
}
678679
return result;

0 commit comments

Comments
 (0)