diff --git a/src/__tests__/native/variables.test.tsx b/src/__tests__/native/variables.test.tsx index 25ac30f5..15a2c5c2 100644 --- a/src/__tests__/native/variables.test.tsx +++ b/src/__tests__/native/variables.test.tsx @@ -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(); + + const component = screen.getByTestId(testID); + expect(component.props.style).toStrictEqual({ opacity: 0 }); +}); + test("inherit variables", () => { registerCSS(` .my-class-1 { width: var(--my-var); } diff --git a/src/compiler/declarations.ts b/src/compiler/declarations.ts index 2f0b8a4a..efdd9a50 100644 --- a/src/compiler/declarations.ts +++ b/src/compiler/declarations.ts @@ -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 (