Skip to content

Commit 7444258

Browse files
test: add regression test for Tailwind v4 rem propagation fix
1 parent a2190a6 commit 7444258

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/__tests__/native/units.test.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,31 @@ test("rem - css root font-size override", () => {
148148
});
149149
});
150150

151+
test("rem - via var() inlining picks up css root font-size (Tailwind v4 style)", () => {
152+
// Regression test for the second-pass parseLength bug.
153+
// Tailwind v4 emits utilities as `:root { --text-base: 1rem }` +
154+
// `.text-base { font-size: var(--text-base) }`. The `1rem` inside
155+
// the custom property is a token-list that skips the first-pass
156+
// Length visitor and gets resolved later by parseLength, which
157+
// reads inlineRem from the builder's options. Without the fix
158+
// that writes regex-discovered rem back to options, parseLength
159+
// falls back to 14 and this resolves to `fontSize: 14`.
160+
registerCSS(`
161+
:root { font-size: 16px; --text-base: 1rem; }
162+
.text-base { font-size: var(--text-base); }
163+
`);
164+
165+
const { result } = renderHook(() => {
166+
return useNativeCss(View, { className: "text-base" });
167+
});
168+
169+
expect(result.current.type).toBe(VariableContext.Provider);
170+
expect(result.current.props.children.type).toBe(View);
171+
expect(result.current.props.children.props).toStrictEqual({
172+
style: { fontSize: 16 },
173+
});
174+
});
175+
151176
test("rem - css override", () => {
152177
registerCSS(
153178
`

0 commit comments

Comments
 (0)