LibWeb/HTML: Properly get the attr-associated element

This replaces ad-hoc implementations of the get the attr-associated
element steps with a call to the proper implementation. This fixes
issue #8585.
This commit is contained in:
Glenn Skrzypczak
2026-03-24 10:47:25 +01:00
committed by Jelle Raaijmakers
parent 4110a05684
commit 88167149f6
Notes: github-actions[bot] 2026-03-25 22:15:22 +00:00
5 changed files with 36 additions and 31 deletions

View File

@@ -0,0 +1,28 @@
<!doctype html>
<script src="../include.js"></script>
<button id="button"></button>
<div id="target"></div>
<script>
test(() => {
const logEvent = e => println(`${e.command}: ${e.source.id} -> ${e.target.id}`);
target.addEventListener("command", logEvent);
const detachedTarget = document.createElement("div");
detachedTarget.id = "detachedTarget";
detachedTarget.addEventListener("command", logEvent);
const detachedButton = document.createElement("button");
detachedTarget.id = "detachedButton";
function testEvent(button, target) {
button.command = "--test";
button.commandForElement = target;
button.click();
}
testEvent(button, target);
testEvent(button, detachedTarget);
testEvent(detachedButton, target);
testEvent(detachedButton, detachedTarget);
});
</script>