2 addEventListener("load", () => {
3 const editingHost
= document
.querySelector("div[contenteditable]");
4 // For emulating the traditional behavior, collapse Selection to end of the
5 // text node in the <div contenteditable> which is the last child of the
7 getSelection().collapse(editingHost
.lastChild
, editingHost
.lastChild
.length
);
8 editingHost
.addEventListener("DOMNodeRemoved", () => {
9 getSelection().collapse(null);
11 document
.execCommand("delete");
14 <div contenteditable
>x
</link></body>