Skip to content

Fix grid autoplacement for repeat() with multiple tracks - #1571

Open
wozhenbang2004 wants to merge 1 commit into
postcss:mainfrom
wozhenbang2004:fix-grid-repeat-multiple-tracks-1369
Open

wozhenbang2004 wants to merge 1 commit into
postcss:mainfrom
wozhenbang2004:fix-grid-repeat-multiple-tracks-1369

Conversation

@wozhenbang2004

Copy link
Copy Markdown
Contributor

Fixes #1369.

Reproduced with Autoprefixer 10.7.0 and PostCSS 8.5.33.

With grid: 'autoplace' and overrideBrowserslist: ['IE 10']:

.example2 {
  display: grid;
  grid-template-rows: 50px 100px;
  grid-template-columns: repeat(2, 50px 100px);
}

The generated placement rules currently cover only two columns:

.example2 > *:nth-child(1) { -ms-grid-row: 1; -ms-grid-column: 1; }
.example2 > *:nth-child(2) { -ms-grid-row: 1; -ms-grid-column: 2; }
.example2 > *:nth-child(3) { -ms-grid-row: 2; -ms-grid-column: 1; }
.example2 > *:nth-child(4) { -ms-grid-row: 2; -ms-grid-column: 2; }

With this change, they cover all four columns in both rows:

.example2 > *:nth-child(1) { -ms-grid-row: 1; -ms-grid-column: 1; }
.example2 > *:nth-child(2) { -ms-grid-row: 1; -ms-grid-column: 2; }
.example2 > *:nth-child(3) { -ms-grid-row: 1; -ms-grid-column: 3; }
.example2 > *:nth-child(4) { -ms-grid-row: 1; -ms-grid-column: 4; }
.example2 > *:nth-child(5) { -ms-grid-row: 2; -ms-grid-column: 1; }
.example2 > *:nth-child(6) { -ms-grid-row: 2; -ms-grid-column: 2; }
.example2 > *:nth-child(7) { -ms-grid-row: 2; -ms-grid-column: 3; }
.example2 > *:nth-child(8) { -ms-grid-row: 2; -ms-grid-column: 4; }

Split each repeated group into tracks before counting them, using the existing list.space() helper to keep functions such as minmax() intact. The existing two-row, eight-column fixture also expected only eight placements; it now expects sixteen. Added cases for the input above and repeated rows with gaps and column flow.

Verified the failure and fix through PostCSS. All test:* scripts passed sequentially on Node.js 24.22.3: 288 tests, 100% line coverage, lint with one thread, and 63.91 kB against the 70 kB size limit.

Count each track in a fixed repeat group when generating IE grid placements.
Preserve nested functions and cover repeated rows and columns in the existing fixtures.
@ai

ai commented Nov 22, 2026

Copy link
Copy Markdown
Member

Did you check it in real IE that it works?

@wozhenbang2004

Copy link
Copy Markdown
Contributor Author

No, I haven’t tested this in real IE. I verified the generated -ms-grid placement rules through PostCSS with IE 10 targeted and added automated regression fixtures; the test, coverage, lint, and size checks pass. Actual rendering in IE remains unverified.

@ai

ai commented Nov 23, 2026

Copy link
Copy Markdown
Member

We need IE test for that PR if you really need this feature and it is not a LLM's PR spam

@wozhenbang2004

Copy link
Copy Markdown
Contributor Author

Understood. The patch was prepared with AI assistance. I don't have real IE rendering results to provide, so the required IE validation remains outstanding.

@ai

ai commented Nov 23, 2026

Copy link
Copy Markdown
Member

The problem is not AI assistance (I use AI every day).

Very likely that the problem is why do you send this PR. Do you really need this feature or want to help my project explicitly, or it is mass-sending PR just to get big merge count?

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.

autoplace for IE 10/11 not work as expected when use css repeat(2, 50px 100px);

2 participants