LibWeb: Return body from activeElement() when nothing is focused

This matches the behavior of other browsers.
This commit is contained in:
Tim Ledbetter
2026-01-19 06:13:24 +00:00
committed by Andreas Kling
parent 4a5350a2ee
commit 0035690977
Notes: github-actions[bot] 2026-02-06 11:26:03 +00:00
7 changed files with 73 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<body>
<script src="../include.js"></script>
<div id="content">Test content</div>
<script>
test(() => {
// When nothing is explicitly focused, activeElement should return the body element
println("document.activeElement === document.body: " + (document.activeElement === document.body));
println("document.activeElement is null: " + (document.activeElement === null));
println("document.activeElement tagName: " + (document.activeElement ? document.activeElement.tagName : "null"));
});
</script>
</body>