Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/__tests__/native/variables.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ test("combined inline variables", () => {
});
});

test("a custom property declared as 0 keeps its value", () => {
// Two definitions, so the compiler cannot inline `--my-var`.
registerCSS(`
.zero { --my-var: 0; }
.one { --my-var: 1; }
.test { opacity: var(--my-var, 0.5); }
`);

render(<View testID={testID} className="test zero" />);

const component = screen.getByTestId(testID);
expect(component.props.style).toStrictEqual({ opacity: 0 });
});

test("inherit variables", () => {
registerCSS(`
.my-class-1 { width: var(--my-var); }
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ export function parseUnparsed(
property,
allowAuto,
);
if (!args) return;
if (args === undefined) return;
if (Array.isArray(args) && args.length === 1) {
return args[0];
} else if (
Expand Down