LibWeb: Selecting an editing host should focus it

Unspecced but common behavior in the major browsers: if the selection
moves to an editing host, the editing host itself should become focused.
This commit is contained in:
Jelle Raaijmakers
2025-07-31 14:25:03 +02:00
committed by Jelle Raaijmakers
parent c9d4913bb4
commit 0ce1571e71
Notes: github-actions[bot] 2025-08-01 08:10:36 +00:00
3 changed files with 35 additions and 7 deletions

View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<div contenteditable>foo</div>
<script src="include.js"></script>
<script>
test(() => {
const divElm = document.querySelector('div[contenteditable]');
const range = document.createRange();
range.setStart(divElm.childNodes[0], 1);
range.setEnd(divElm.childNodes[0], 2);
window.getSelection().addRange(range);
println(`Range: ${range.startContainer} ${range.startOffset} ${range.endContainer} ${range.endOffset}`);
println(`document.activeElement: ${document.activeElement}`);
});
</script>