blob: c1bb7219a5f68e05ee053ee76e2fbffeb1b2369c (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
<div contenteditable> a</div>
<script>
// For emulating the traditional behavior, collapse Selection to end of the
// text node in this <script>.
const script = document.querySelector("script");
getSelection().collapse(script.lastChild, script.lastChild.length);
const editingHost = document.querySelector("div[contenteditable]");
editingHost.insertBefore(document.createTextNode(""), editingHost.firstChild);
getSelection().collapse(editingHost.firstChild.nextSibling, 2);
document.execCommand("delete");
</script></body>
|