Skip to content

Convert flexbox values for old specs regardless of case - #1586

Merged
ai merged 1 commit into
postcss:mainfrom
farisbasha:flex-values-case
Dec 4, 2026
Merged

ai merged 1 commit into
postcss:mainfrom
farisbasha:flex-values-case

Conversation

@farisbasha

Copy link
Copy Markdown
Contributor

CSS keywords are ASCII case-insensitive, but the flexbox hacks only converted values for the 2009 and 2012 specs when they were written in lowercase. FlexDirection and FlexFlow used a case-sensitive includes('row')/includes('reverse') (and wrap filter), and Flex, JustifyContent, AlignItems, AlignSelf and AlignContent looked up oldValues[decl.value] directly. Uppercase values therefore produced a wrong direction or invalid old-spec values.

With overrideBrowserslist: ['Chrome 20', 'Firefox 20', 'IE 10']:

Input CSS

a { flex-direction: ROW-REVERSE }
b { flex: NONE }
c { justify-content: SPACE-BETWEEN }
d { justify-content: Space-Around }
e { align-items: FLEX-START }

Current output CSS

a { -webkit-box-orient: vertical; -webkit-box-direction: normal; -moz-box-orient: vertical; -moz-box-direction: normal; -ms-flex-direction: ROW-REVERSE; flex-direction: ROW-REVERSE }
b { -webkit-box-flex: NONE; -moz-box-flex: NONE; -ms-flex: NONE; flex: NONE }
c { -webkit-box-pack: SPACE-BETWEEN; -moz-box-pack: SPACE-BETWEEN; -ms-flex-pack: SPACE-BETWEEN; justify-content: SPACE-BETWEEN }
d { -webkit-box-pack: Space-Around; -moz-box-pack: Space-Around; -ms-flex-pack: Space-Around; justify-content: Space-Around }
e { -webkit-box-align: FLEX-START; -moz-box-align: FLEX-START; -ms-flex-align: FLEX-START; align-items: FLEX-START }

Output after the fix (same as for the lowercase values)

a { -webkit-box-orient: horizontal; -webkit-box-direction: reverse; -moz-box-orient: horizontal; -moz-box-direction: reverse; -ms-flex-direction: ROW-REVERSE; flex-direction: ROW-REVERSE }
b { -webkit-box-flex: 0; -moz-box-flex: 0; -ms-flex: NONE; flex: NONE }
c { -webkit-box-pack: justify; -moz-box-pack: justify; -ms-flex-pack: justify; justify-content: SPACE-BETWEEN }
d { -ms-flex-pack: distribute; justify-content: Space-Around }
e { -webkit-box-align: start; -moz-box-align: start; -ms-flex-align: start; align-items: FLEX-START }

flex-flow: WRAP Row also gave box-orient: vertical, and flex-flow: WRAP added a box-orient/box-direction pair that the lowercase value does not get. align-self and align-content had the same lookup for -ms-flex-item-align/-ms-flex-line-pack.

The fix lowercases the value only for the checks and the oldValues lookups, so values that pass through keep the author's case (like #1582).

The new test fails before the fix. pnpm test passes (294 tests, 100% line coverage, lint and size checks).

This PR was prepared with AI assistance (Claude).

CSS keywords are ASCII case-insensitive, but the flexbox hacks looked up
their old-spec values case-sensitively. flex-direction: ROW-REVERSE gave
box-orient: vertical / box-direction: normal, flex: NONE gave
box-flex: NONE and justify-content: SPACE-BETWEEN was copied as-is into
box-pack and flex-pack. Lowercase the value before the checks and the
oldValues lookups in the flex-direction, flex-flow, flex,
justify-content and align-* hacks.
@ai
ai merged commit 3ef042b into postcss:main Dec 4, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants