Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-anchor-position/anchor-scroll-update-008.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html class="reftest-wait">
<title>Anchored element should update when anchor's div under `contain: layout size` becomes a non scroll container.</title>
<link rel="author" href="mailto:dshin@mozilla.com">
<link rel="match" href="reference/anchor-scroll-update-008-ref.html">
<style>
.abspos-cb {
position: relative;
width: 200px;
height: 200px;
border: 1px solid;
}
.positioned {
width: 15px;
height: 15px;
background: purple;
position: absolute;
position-anchor: --a;
left: anchor(right);
top: anchor(top);
}
.scroller {
overflow-y: scroll;
height: 100%;
}
.filler {
width: 1px;
height: 500px;
}
.anchor {
width: 15px;
height: 15px;
background: magenta;
anchor-name: --a;
}
.contain {
contain: layout size;
width: 200px;
height: 200px;
}
</style>
<div class=abspos-cb>
<div class=positioned></div>
<div class=contain><div id=dut class=scroller>
<div class=anchor></div>
<div class=filler></div>
</div></div>
</div>
<script>
dut.scrollTop = 300;
dut.classList.toggle('scroller');
function raf() {
return new Promise(resolve => requestAnimationFrame(resolve));
}
async function runTest() {
await raf();
await raf();
document.documentElement.classList.remove('reftest-wait');
}
runTest();
</script>