Skip to content

Commit 1a6f354

Browse files
authored
fix: nested variables set via class rules (#162)
1 parent fed6be0 commit 1a6f354

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/__tests__/native/variables.test.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,33 @@ test("VariableContextProvider", () => {
241241
const component = screen.getByTestId(testID);
242242
expect(component.props.style).toStrictEqual({ color: "red" });
243243
});
244+
245+
test("variable overriding with classes", () => {
246+
registerCSS(`
247+
:root {
248+
--tier-red-500: red;
249+
--tier-red-700: red;
250+
251+
--tier-blue-500: blue;
252+
--tier-blue-700: blue;
253+
}
254+
255+
.tier-red {
256+
--tier-500: var(--tier-red-500);
257+
--tier-700: var(--tier-red-700);
258+
}
259+
260+
.test {
261+
color: var(--tier-500)
262+
}
263+
`);
264+
265+
render(
266+
<View className="tier-red">
267+
<View testID={testID} className="test" />
268+
</View>,
269+
);
270+
271+
const component = screen.getByTestId(testID);
272+
expect(component.props.style).toStrictEqual({ color: "red" });
273+
});

src/runtime/native/styles/variables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function varResolver(
4848

4949
if (name in variables) {
5050
renderGuards?.push(["v", name, variables[name]]);
51-
return variables[name];
51+
return resolve(variables[name]);
5252
}
5353

5454
variableHistory.add(name);

0 commit comments

Comments
 (0)