diff --git a/src/__tests__/native/variables.test.tsx b/src/__tests__/native/variables.test.tsx index 18440ba3..dbdf150b 100644 --- a/src/__tests__/native/variables.test.tsx +++ b/src/__tests__/native/variables.test.tsx @@ -241,3 +241,33 @@ test("VariableContextProvider", () => { const component = screen.getByTestId(testID); expect(component.props.style).toStrictEqual({ color: "red" }); }); + +test("variable overriding with classes", () => { + registerCSS(` + :root { + --tier-red-500: red; + --tier-red-700: red; + + --tier-blue-500: blue; + --tier-blue-700: blue; + } + + .tier-red { + --tier-500: var(--tier-red-500); + --tier-700: var(--tier-red-700); + } + + .test { + color: var(--tier-500) + } +`); + + render( + + + , + ); + + const component = screen.getByTestId(testID); + expect(component.props.style).toStrictEqual({ color: "red" }); +}); diff --git a/src/runtime/native/styles/variables.ts b/src/runtime/native/styles/variables.ts index 8c6cabff..ecbe447f 100644 --- a/src/runtime/native/styles/variables.ts +++ b/src/runtime/native/styles/variables.ts @@ -48,7 +48,7 @@ export function varResolver( if (name in variables) { renderGuards?.push(["v", name, variables[name]]); - return variables[name]; + return resolve(variables[name]); } variableHistory.add(name);