LibWeb: Nested editing host focus should propagate to farthest ancestor

Nested editing hosts should act as a single big editing host, as long as
there are no uneditable elements in between.
This commit is contained in:
Jelle Raaijmakers
2025-08-21 15:24:55 +02:00
committed by Jelle Raaijmakers
parent 6c0a0b86ba
commit 90f1c8724b
Notes: github-actions[bot] 2025-08-26 08:27:24 +00:00
3 changed files with 20 additions and 0 deletions

View File

@@ -2,6 +2,8 @@
<div id="a" contenteditable>foo</div>
<div id="b" contenteditable>foo<span>bar</span></div>
<button id="c">press me</button>
<div id="d" contenteditable>foo <span contenteditable>bar</span></div>
<div id="e" contenteditable>foo <span contenteditable="false">bar <span contenteditable>baz</span></span></div>
<script src="include.js"></script>
<script>
test(() => {
@@ -27,5 +29,15 @@ test(() => {
const buttonRect = buttonElm.getBoundingClientRect();
internals.click(buttonRect.left + 5, buttonRect.top + 5);
reportSelectionAndFocus();
println('-- Nested editing host --');
const spanC = document.querySelector('div#d span');
getSelection().setBaseAndExtent(spanC.childNodes[0], 0, spanC.childNodes[0], 3);
reportSelectionAndFocus();
println('-- Nested editing host with uneditable element as parent --');
const spanD = document.querySelector('div#e span span');
getSelection().setBaseAndExtent(spanD.childNodes[0], 0, spanD.childNodes[0], 3);
reportSelectionAndFocus();
});
</script>