mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +02:00
Tests: Add getElementById mutation and shadow-root routing tests
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.
This commit is contained in:
committed by
Andreas Kling
parent
7cc973fa77
commit
a0768e9bac
Notes:
github-actions[bot]
2026-02-21 12:56:57 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/a0768e9bac6 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8055
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<div id="foo" data-name="first"></div>
|
||||
<div id="foo" data-name="second"></div>
|
||||
<script>
|
||||
test(() => {
|
||||
let [first, second] = document.querySelectorAll("[id='foo']");
|
||||
|
||||
println(`initial: ${document.getElementById("foo").dataset.name}`);
|
||||
|
||||
document.body.insertBefore(second, first);
|
||||
println(`after reorder: ${document.getElementById("foo").dataset.name}`);
|
||||
|
||||
first.id = "bar";
|
||||
println(`after first id change: ${document.getElementById("foo").dataset.name}`);
|
||||
|
||||
second.remove();
|
||||
println(`after removing second: ${document.getElementById("foo")}`);
|
||||
|
||||
first.id = "foo";
|
||||
println(`after restoring first: ${document.getElementById("foo") === first}`);
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user