mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Add focused coverage for the ElementByIdMap that is easy to regress while optimizing lookup paths. The dynamic mutations test verifies duplicate id tree order semantics remain correct after reordering, id changes, removals, and reintroduction. The shadow root routing test verifies lookups stay routed to the correct scope when an element with an id is removed and moved across shadow roots and into the document.
33 lines
1.1 KiB
HTML
33 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
test(() => {
|
|
let host1 = document.createElement("div");
|
|
let host2 = document.createElement("div");
|
|
document.body.append(host1, host2);
|
|
|
|
let shadow1 = host1.attachShadow({ mode: "open" });
|
|
let shadow2 = host2.attachShadow({ mode: "open" });
|
|
|
|
let node = document.createElement("span");
|
|
node.id = "foo";
|
|
shadow1.append(node);
|
|
|
|
shadow1.getElementById("foo");
|
|
|
|
println(`shadow1 has foo initially: ${shadow1.getElementById("foo") === node}`);
|
|
|
|
node.remove();
|
|
println(`shadow1 has foo after remove: ${shadow1.getElementById("foo") === null}`);
|
|
|
|
shadow2.append(node);
|
|
println(`shadow1 has foo after move: ${shadow1.getElementById("foo") === null}`);
|
|
println(`shadow2 has foo after move: ${shadow2.getElementById("foo") === node}`);
|
|
println(`document has foo while in shadow: ${document.getElementById("foo") === null}`);
|
|
|
|
document.body.append(node);
|
|
println(`shadow2 has foo after moving to document: ${shadow2.getElementById("foo") === null}`);
|
|
println(`document has foo after move: ${document.getElementById("foo") === node}`);
|
|
});
|
|
</script>
|