Files
ladybird/Tests/LibWeb/Text/input/css/part-does-not-match-selection.html
Jelle Raaijmakers e1ba577ab7 LibWeb: Don't match ::part() selectors against unrelated pseudo-elements
The selector matching code bypassed the pseudo-element type check for
`::part()` selectors to support compound selectors like
`::part(foo)::before`. This caused bare ::part() declarations to leak
into unrelated pseudo-elements like ::selection.

Fix this by finding any additional pseudo-element beyond ::part() in the
selector and verifying it matches the target.
2026-03-03 10:03:03 +01:00

17 lines
550 B
HTML

<!DOCTYPE html>
<style>
#host::part(p) { background-color: red; }
</style>
<div id="host"></div>
<script src="../include.js"></script>
<script>
test(() => {
const host = document.getElementById("host");
const shadow = host.attachShadow({ mode: "open" });
shadow.innerHTML = `<span id="inner" part="p">text</span>`;
const inner = shadow.getElementById("inner");
println(getComputedStyle(inner).backgroundColor);
println(getComputedStyle(inner, "::selection").backgroundColor);
});
</script>