Repository navigation
layout: fix a crash when a lone grid item spans the whole row axis with no explicit template - #266
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resolveAxisPlacementresolvedgrid-row:1 / -1(Tailwind'srow-span-full) with nogrid-template-rowsinto a degenerate zero-track span: it clamped the resolved start line to non-negative but never re-checked that the span survived the clamp.nRowsstayed 0, leavingsizeRows/trackOffsetsempty and panickinggrid()onindex out of range [0] with length 0atrowY[it.r0].resolveAxisPlacementcases, which already guarantee this unconditionally.Test plan
go build ./...go test ./...(all packages pass)TestGridRowSpanFullWithNoExplicitRowsDoesNotCrash, stash-verified against the unfixed code (panics with the identical trace without the fix, passes with it)cmd/renderlayoutpackage coverage unchanged at 100%🤖 Generated with Claude Code