Skip to content

Commit bdb5c3d

Browse files
authored
fix: variables with ratio values (#88)
1 parent 085efa4 commit bdb5c3d

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/compiler/declarations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ export function parseUnparsed(
12101210
case "comma":
12111211
return CommaSeparator as unknown as StyleDescriptor;
12121212
case "delim": {
1213-
if (property === "aspect-ratio" && tokenOrValue.value.value === "/") {
1213+
if (tokenOrValue.value.value === "/") {
12141214
return tokenOrValue.value.value;
12151215
}
12161216
return;

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,17 @@ test("useUnsafeVariable", () => {
217217

218218
expect(component.props.style).toStrictEqual({ color: "red" });
219219
});
220+
221+
test("ratio values", () => {
222+
registerCSS(`
223+
:root { --my-var: 16 / 9; }
224+
.test { aspect-ratio: var(--my-var); }
225+
`);
226+
227+
// Since we can't directly test the hook in isolation with the render approach,
228+
// we'll test that a component using the variable gets the correct value
229+
render(<View testID={testID} className="test" />);
230+
const component = screen.getByTestId(testID);
231+
232+
expect(component.props.style).toStrictEqual({ aspectRatio: "16 / 9" });
233+
});

src/runtime/native/styles/resolve.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export function resolveValue(
178178
}
179179
return arg;
180180
})
181+
.filter((value) => value !== "/")
181182
.join(", ");
182183

183184
if (name === "radial-gradient") {

0 commit comments

Comments
 (0)