Truly independent web browser
<!DOCTYPE html>
<script src="../../include.js"></script>
<script src="../../work-test.js"></script>
<style>
:checked ~ div > * { color: green }
</style>
<div id="host"></div>
<script>
test(() => {
const shadowRoot = document.getElementById("host").attachShadow({ mode: "open" });
shadowRoot.innerHTML = `<div><input type="checkbox"><label id="label"></label><button id="button"></button></div>`;
// A document rule never matches inside a shadow tree, so checking a box there restyles
// nothing through it.
const work = styleWork(() => shadowRoot.querySelector("input").checked = true);
println(`passes: ${work.passes().join(" | ") || "(no pass)"}`);
println(`changed: [${work.changed().map(shortStyleName).join(", ")}]`);
println(`restyled but unchanged: [${work.restyled().filter(element => !work.changed().includes(element)).map(shortStyleName).join(", ")}]`);
});
</script>