Files
sousa-gecko/testing/web-platform/tests/css/css-content/element-replacement-dynamic-002.html
T
Oriol BrufauandMartin Robinson 1a28be1b9d Bug 2052963 [wpt PR 61099] - layout: Clear laid out fragments of descendants when content is replaced, a=testonly
Automatic update from web-platform-tests
layout: Clear laid out fragments of descendants when `content` is replaced

A dynamic change of the `content` property can turn a non-replaced
element into replaced. In that case, it's possible that the contents
were laid out previously, and now they will be skipped.

The problem was that we were still caching the results from the previous
layout in some cases. Thus, script queries like `getComputedStyle` could
return the wrong value, or Servo could crash.

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>

--

wpt-commits: aa133226f042b41a269689ff9072ec91098916cd
wpt-pr: 61099
2026-07-12 11:55:17 +00:00

32 lines
1.1 KiB
HTML

<!DOCTYPE html>
<html class="reftest-wait">
<meta charset="utf-8">
<title>The content CSS attribute can replace an element's contents dynamically</title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-content-3/#content-property">
<meta name="assert" content="
Descendants of an element that is replaced because of the content property
shouldn't be laid out. Therefore, the resolved height in getComputedStyle
should be the computed value (`auto`), not the used amount of pixels from
the previous layout.
">
<div id="wrapper">
<div style="display: flow-root">
<div id="target">Text</div>
</div>
</div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/interpolation-testcommon.js"></script>
<script>
test(function() {
// Force layout
document.body.offsetWidth;
wrapper.style.content = "linear-gradient(blue)";
assert_equals(getComputedStyle(target).height, "auto");
}, "getComputedStyle().height after ancestor becomes replaced");
</script>