Created attachment 371479 [details] Html to reproduce the issue Steps to reproduce the problem: 1. Create and open html file with following content, or use attached one: `<div class="editor" contenteditable="true"><div>foo</div></div>` 2. Focus editable div. 3. Select all, you can either use keystroke, contextmenu or call `document.execCommand( 'selectall' )`. 4. Inspect selection ranges in console: `document.getSelection().getRangeAt( 0 )` What is the expected behavior? According to https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand > selectAll > Selects all of the content of the editable region. Range start/end container is div#editable startOffset = 0; endOffset = 1; `<div class="editor" contenteditable="true">[<div>foo</div>]</div>` What went wrong? Range start/end container is text node inside nested div startOffset = 0 endOffset = 1 `<div class="editor" contenteditable="true"><div>{foo}</div></div>` This is troublesome for users of rich text editors, as copied data doesn't match to all content of an editable. Edge and Firefox works as expected. Same issue in Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=931285
<rdar://problem/51486602>
*** Bug 34377 has been marked as a duplicate of this bug. ***
This stems from the fact WebKit always canonicalizes the selection end points before doing any editing operations. The bug 15256 is also caused by this behavior.