Skip to content

Commit

Permalink
Prevent creation of invalid ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed May 11, 2021
1 parent 127779b commit b79d013
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/useEditable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ const makeRange = (
start: number,
end?: number
): Range => {
if (!end) end = start;
if (start <= 0) start = 0;
if (!end || end < 0) end = start;

const range = document.createRange();
const queue: Node[] = [element.firstChild!];
Expand Down

0 comments on commit b79d013

Please sign in to comment.