Truly independent web browser
<!doctype html>
<script src="../include.js"></script>
<div id="host1"><span slot="s1">a</span></div>
<div id="host2"><span>b</span></div>
<script>
asyncTest(async done => {
const check = n =>
println(`check ${n}: ${internals.compareLayoutTreeWithFullRebuild().matches ? "PASS" : "FAIL"}`);
const attach = (host, html) => {
const root = host.attachShadow({ mode: "open" });
root.innerHTML = html;
const slot = root.querySelector("slot");
slot.addEventListener("slotchange", () => println(`slotchange on ${slot.id}`));
return root;
};
const root1 = attach(host1, '<div><slot id="slot1" name="s1"></slot></div>');
const root2 = attach(host2, '<div><slot id="slot2"></slot></div>');
const slots = [root1, root2].map(root => root.querySelector("slot"));
document.body.offsetHeight;
check(0);
root1.innerHTML = '<div><slot name="s2"><span>fallback</span></slot></div> ';
document.body.offsetHeight;
check(1);
root2.firstChild.remove();
document.body.offsetHeight;
check(2);
await timeout(0);
for (const slot of slots) println(`${slot.id} assignedNodes: ${slot.assignedNodes().length}`);
done();
});
</script>