LibWeb: Invalidate pseudo-elements on hover even when not yet created

The hover invalidation code only tried matching ::before/::after
selectors when has_pseudo_element() returned true, which requires an
existing layout node. A pseudo-element that doesn't exist yet (because
its content is only set by a hover rule) has no layout node, so the
match was skipped and hovering never triggered a style recompute.
Always try ::before/::after selectors during hover invalidation.
This commit is contained in:
Jelle Raaijmakers
2026-03-24 13:35:58 +01:00
committed by Tim Flynn
parent 77b9fcf7f9
commit 16dffe39a0
Notes: github-actions[bot] 2026-03-24 14:28:09 +00:00
5 changed files with 43 additions and 44 deletions

View File

@@ -0,0 +1,36 @@
<!DOCTYPE html>
<style>
.outer {
height: 100px;
}
.update {
display: inline-block;
}
.update::before {
content: "Hi";
}
.outer:hover .update::before {
content: "Long text";
}
.create {
display: inline-block;
}
.outer:hover .create::before {
content: "Flag";
}
</style>
<script src="../include.js"></script>
<div class="outer"><div class="update"></div><div class="create"></div></div>
<script>
test(() => {
const update = document.querySelector('.update');
const create = document.querySelector('.create');
println(`update: ${update.clientWidth} create: ${create.clientWidth}`);
internals.mouseMove(50, 50);
println(`update: ${update.clientWidth} create: ${create.clientWidth}`);
internals.mouseMove(200, 200);
println(`update: ${update.clientWidth} create: ${create.clientWidth}`);
});
</script>