Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-gaps/grid/grid-gap-decorations-repaint-on-item-position-change.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<title>CSS Gap Decorations: repaint when grid item position changes</title>
<link rel="help" href="https://drafts.csswg.org/css-gaps-1/">
<link rel="match" href="grid-gap-decorations-repaint-on-item-position-change-ref.html">
<link rel="author" title="Kevin Babbitt" href="mailto:kbabbitt@microsoft.com">
<meta name="assert" content="Gap decorations repaint correctly when a grid item's position changes with rule-visibility-items: around">
<style>
.grid-container {
display: grid;
grid-template: repeat(2, 50px) / repeat(2, 50px);
gap: 20px;
column-rule: 20px solid green;
row-rule: 20px solid green;
rule-break: intersection;
rule-interior-inset: -20px;
rule-visibility-items: around;
}
.grid-item {
background: green;
}
#walking-item {
/* Start at row 1, col 1; will move to row 2, col 2 */
grid-row: 1;
grid-column: 1;
}
</style>
</head>
<body>
<p>Test passes if there is a filled green square.</p>
<div class="grid-container">
<div id="walking-item" class="grid-item"></div>
</div>
<script>
// Use double requestAnimationFrame to ensure style is computed and painted.
requestAnimationFrame(() => {
requestAnimationFrame(() => {
// Move walking-item from (1,1) to (2,2).
// With rule-visibility-items: around, this changes which gap segments
// are visible. The gap decorations should repaint to reflect this.
const item = document.getElementById('walking-item');
item.style.gridRow = '2';
item.style.gridColumn = '2';
document.documentElement.classList.remove("reftest-wait");
});
});
</script>
</body>
</html>