mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-17 07:50:04 +00:00
LibWeb: Align editing whitespace canonicalization with other browsers
The spec calls for a couple of very specific whitespace padding techniques whenever we canonicalize whitespace during the execution of editing commands, but it seems that other browsers have a simpler strategy - let's adopt theirs!
This commit is contained in:
parent
36bb2824a6
commit
6176b05ca5
Notes:
github-actions[bot]
2025-04-29 13:33:03 +00:00
Author: https://github.com/gmta
Commit: 6176b05ca5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4520
3 changed files with 81 additions and 48 deletions
|
@ -1,19 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<div contenteditable="true">foobar</div>
|
||||
<div id="a" contenteditable="true">foobar</div>
|
||||
<div id="b" contenteditable="true">a </div>
|
||||
<div id="c" contenteditable="true">a b</div>
|
||||
<div id="d" contenteditable="true">a b</div>
|
||||
<div id="e" contenteditable="true">a b</div>
|
||||
<div id="f" contenteditable="true">a b</div>
|
||||
<div id="g" contenteditable="true"> b</div>
|
||||
<script>
|
||||
test(() => {
|
||||
var divElm = document.querySelector('div');
|
||||
println(`Before: ${divElm.textContent}`);
|
||||
const testForwardDelete = function(divId, position) {
|
||||
println(`--- ${divId} ---`);
|
||||
const divElm = document.querySelector(`div#${divId}`);
|
||||
println(`Before: ${divElm.innerHTML}`);
|
||||
|
||||
// Put cursor after 'foo'
|
||||
var range = document.createRange();
|
||||
range.setStart(divElm.childNodes[0], 3);
|
||||
getSelection().addRange(range);
|
||||
// Place cursor
|
||||
const node = divElm.childNodes[0];
|
||||
getSelection().setBaseAndExtent(node, position, node, position);
|
||||
|
||||
// Press delete
|
||||
document.execCommand('forwardDelete');
|
||||
// Press delete
|
||||
document.execCommand('forwardDelete');
|
||||
|
||||
println(`After: ${divElm.textContent}`);
|
||||
println(`After: ${divElm.innerHTML}`);
|
||||
};
|
||||
|
||||
testForwardDelete('a', 3);
|
||||
testForwardDelete('b', 1);
|
||||
testForwardDelete('c', 1);
|
||||
testForwardDelete('d', 1);
|
||||
testForwardDelete('e', 1);
|
||||
testForwardDelete('f', 1);
|
||||
testForwardDelete('g', 0);
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue