mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-24 17:09:43 +00:00
We currently delete a single code unit. If the user presses backspace on a multi code point emoji, they are going to expect the entire emoji to be removed. This now matches the behavior of Chrome and Firefox.
25 lines
792 B
HTML
25 lines
792 B
HTML
<!DOCTYPE html>
|
||
<script src="../include.js"></script>
|
||
<div id="a" contenteditable="true">foobar</div>
|
||
<div id="b" contenteditable="true">foo👩🏼❤️👨🏻bar</div>
|
||
<script>
|
||
test(() => {
|
||
const testDelete = function (divId, position) {
|
||
println(`--- ${divId} ---`);
|
||
const divElm = document.querySelector(`div#${divId}`);
|
||
println(`Before: ${divElm.textContent}`);
|
||
|
||
// Place cursor
|
||
const node = divElm.childNodes[0];
|
||
getSelection().setBaseAndExtent(node, position, node, position);
|
||
|
||
// Press backspace
|
||
document.execCommand("delete");
|
||
|
||
println(`After: ${divElm.textContent}`);
|
||
};
|
||
|
||
testDelete("a", 3);
|
||
testDelete("b", 15);
|
||
});
|
||
</script>
|