Files
ladybird/Tests/LibWeb/Text/input/css/shadow-root-host-keyframes-invalidation.html
Andreas Kling 928a5247ff LibWeb: Narrow stylesheet add/remove invalidation
Avoid broad document invalidation when adding or removing ordinary
document-owned or shadow-owned stylesheets. Reuse the targeted
StyleSheetInvalidation path for style rules, including shadow-host
escapes, pseudo-element-only selectors, and trailing-universal cases.

Keep the broad path for sheet contents whose effects are not captured
by selector invalidation alone, including @property, @font-face,
@font-feature-values, @keyframes, imported sheets, and top-level @layer
blocks. Broad-path shadow-root sheets still reach host-side consumers
through their active-scope effects.
2026-04-23 16:45:22 +02:00

36 lines
1.1 KiB
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<div id="host"></div>
<script>
asyncTest(async done => {
const host = document.getElementById("host");
const shadowRoot = host.attachShadow({ mode: "open" });
const sheet = new CSSStyleSheet();
sheet.replaceSync(`
:host {
animation-name: fade;
animation-duration: 1s;
animation-fill-mode: both;
}
`);
shadowRoot.adoptedStyleSheets = [sheet];
println(`opacity before keyframes: ${getComputedStyle(host).opacity}`);
sheet.insertRule(`
@keyframes fade {
from { opacity: 0.25; }
to { opacity: 0.25; }
}
`, sheet.cssRules.length);
await animationFrame();
println(`opacity after keyframes insert: ${getComputedStyle(host).opacity}`);
sheet.deleteRule(sheet.cssRules.length - 1);
await animationFrame();
println(`opacity after keyframes delete: ${getComputedStyle(host).opacity}`);
done();
});
</script>