Skip to content

Commit 172a683

Browse files
authored
fix: styles using variables not being delayed (#85)
1 parent 1e88eb8 commit 172a683

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/compiler/stylesheet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ function postProcessStyleFunction(value: StyleDescriptor): [
614614
let [shouldDelay, usesVariables] = postProcessStyleFunction(value[2]);
615615

616616
usesVariables ||= value[1] === "var";
617-
shouldDelay ||= value[3] === 1;
617+
shouldDelay ||= value[3] === 1 || usesVariables;
618618

619619
if (shouldDelay) {
620620
return [true, usesVariables];

src/runtime/native/__tests__/colors.test.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,33 @@ describe("hsla", () => {
135135
});
136136
});
137137
});
138+
139+
describe("currentcolor", () => {
140+
test("currentcolor and global variables", () => {
141+
registerCSS(`
142+
@layer theme {
143+
:root {
144+
--color-red-500: red;
145+
}
146+
}
147+
@layer utilities {
148+
.bg-current {
149+
background-color: currentcolor;
150+
}
151+
.text-red-500 {
152+
color: var(--color-red-500);
153+
}
154+
}
155+
`);
156+
157+
render(<View testID={testID} className="bg-current text-red-500" />);
158+
const component = screen.getByTestId(testID);
159+
160+
expect(component.type).toBe("View");
161+
expect(component.props).toStrictEqual({
162+
children: undefined,
163+
style: { color: "red", backgroundColor: "red" },
164+
testID,
165+
});
166+
});
167+
});

0 commit comments

Comments
 (0)