Skip to content

layout: fix a crash when a lone grid item spans the whole row axis with no explicit template - #266

Merged
tannevaled merged 1 commit into
mainfrom
fix-grid-row-span-full-crash
Oct 9, 2026
Merged

tannevaled merged 1 commit into
mainfrom
fix-grid-row-span-full-crash

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Summary

  • resolveAxisPlacement resolved grid-row:1 / -1 (Tailwind's row-span-full) with no grid-template-rows into a degenerate zero-track span: it clamped the resolved start line to non-negative but never re-checked that the span survived the clamp.
  • With this as a grid's only item, nRows stayed 0, leaving sizeRows/trackOffsets empty and panicking grid() on index out of range [0] with length 0 at rowY[it.r0].
  • Confirmed live on https://www.lego.com/, found by the 500-page bench corpus (round 166's own expansion) mid-run.
  • A grid item always occupies at least one track per axis (CSS Grid spec §8.3); the fix re-widens the span to 1 after the clamp instead of leaving it collapsed, matching the other resolveAxisPlacement cases, which already guarantee this unconditionally.

Test plan

  • go build ./...
  • go test ./... (all packages pass)
  • New test TestGridRowSpanFullWithNoExplicitRowsDoesNotCrash, stash-verified against the unfixed code (panics with the identical trace without the fix, passes with it)
  • Reproduced and confirmed fixed against the live lego.com page via cmd/render
  • layout package coverage unchanged at 100%

🤖 Generated with Claude Code

…th no explicit template

resolveAxisPlacement resolved "grid-row:1 / -1" (Tailwind's
row-span-full) with no grid-template-rows into a degenerate
zero-track span: it clamped the resolved start line to be
non-negative but never re-checked that the span survived the
clamp. With this as a grid's only item, nRows stayed 0, leaving
sizeRows/trackOffsets empty and panicking grid() on
"index out of range [0] with length 0" at rowY[it.r0].

Confirmed live on https://www.lego.com/, found by the 500-page
bench corpus. A grid item always occupies at least one track per
axis (CSS Grid spec 8.3); the fix re-widens the span to 1 after
the clamp instead of leaving it collapsed, matching the other
resolveAxisPlacement cases, which already guarantee this.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 4852862 into main Oct 9, 2026
7 checks passed
@tannevaled
tannevaled deleted the fix-grid-row-span-full-crash branch October 9, 2026 12:58
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.

1 participant