Files
sousa-gecko/testing/web-platform/tests/css/css-grid/subgrid/grid-template-computed-invalid-subgrid.html
T
Alison Maher 0d678c8806 Bug 2040791 [wpt PR 59981] - [Masonry] Compute subgrid to none when subgridding is invalid, a=testonly
Automatic update from web-platform-tests
[Masonry] Compute subgrid to none when subgridding is invalid

When 'grid-template-rows/grid-template-columns: subgrid' is specified on
a grid container that cannot validly subgrid in that direction — either
because the parent is not a grid, or because the parent is a grid-lanes
container and this is the standalone axis — the computed value was
serializing to an empty string instead of resolving to the initial value
'none'.

Per CSS Grid 2 §7.2.5 (subgrid value definition): "If there is no parent
grid, [...] the used value is the initial value, 'none', and the grid
container is not a subgrid." See
https://www.w3.org/TR/css-grid-2/#subgrid-listing.

This was also resolved to 'none' if subgridding to the stacking axis of
a grid lanes container in
https://github.com/w3c/csswg-drafts/issues/13529#issuecomment-4172117246.

And per the grid spec, the resolved value for
'grid-template-rows/grid-template-columns' is the same as the used
value.

Adds WPT tests covering both the regular-grid case (grid container with
non-grid parent) and the grid-lanes standalone-axis case.

Bug: 343257585
Change-Id: I83dc5c6dce4ba04df2eba8fbec8d4ff88c32feb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7856652
Reviewed-by: Kurt Catti-Schmidt <kschmi@microsoft.com>
Commit-Queue: Alison Maher <almaher@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1632960}

--

wpt-commits: 4b9d9bd6acde4a938a8113bb249069438b068b44
wpt-pr: 59981
2026-05-22 14:16:10 +00:00

40 lines
2.1 KiB
HTML

<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Grid Layout Test: getComputedStyle().gridTemplateColumns/Rows when subgrid is specified on a grid container without a grid parent</title>
<link rel="author" title="Alison Maher" href="mailto:almaher@microsoft.com">
<link rel="help" href="https://drafts.csswg.org/css-grid-2/#subgrid-listing">
<meta name="assert" content="When `subgrid` is specified in grid-template-columns or grid-template-rows on a grid container whose parent is not a grid, the element is not a valid subgrid and the computed value resolves to the initial value `none`.">
<style>
#parent {
display: block;
}
#target {
display: grid;
}
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<div id="parent">
<div id="target"></div>
</div>
<script>
// `subgrid` on a grid container with no grid parent is not a valid subgrid;
// per the spec it should compute to the initial value `none`.
test_computed_value("grid-template-columns", "subgrid", "none");
test_computed_value("grid-template-columns", "subgrid [a]", "none");
test_computed_value("grid-template-columns", "subgrid [a] [b]", "none");
test_computed_value("grid-template-columns", "subgrid [a] [] [b]", "none");
test_computed_value("grid-template-columns", "subgrid repeat(auto-fill, [a])", "none");
test_computed_value("grid-template-columns", "subgrid repeat(2, [a] [b])", "none");
test_computed_value("grid-template-columns", "subgrid [a] repeat(auto-fill, [b]) [c]", "none");
test_computed_value("grid-template-rows", "subgrid", "none");
test_computed_value("grid-template-rows", "subgrid [a]", "none");
test_computed_value("grid-template-rows", "subgrid [a] [b]", "none");
test_computed_value("grid-template-rows", "subgrid [a] [] [b]", "none");
test_computed_value("grid-template-rows", "subgrid repeat(auto-fill, [a])", "none");
test_computed_value("grid-template-rows", "subgrid repeat(2, [a] [b])", "none");
test_computed_value("grid-template-rows", "subgrid [a] repeat(auto-fill, [b]) [c]", "none");
</script>