Skip to content

Commit

Permalink
off by one error
Browse files Browse the repository at this point in the history
incorrectly indexes into container -> block -> text
  • Loading branch information
jhchen committed Mar 19, 2018
1 parent c393b62 commit e595afe
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,15 @@ class Selection {
offset = 0;
} else if (node.childNodes.length === offset) {
node = node.lastChild;
offset =
node instanceof Text
? node.data.length
: node.childNodes.length + 1;
if (node instanceof Text) {
offset = node.data.length;
} else if (node.childNodes.length > 0) {
// Container case
offset = node.childNodes.length;
} else {
// Embed case
offset = node.childNodes.length + 1;
}
} else {
break;
}
Expand Down

0 comments on commit e595afe

Please sign in to comment.