Skip to content

Commit 2ada60d

Browse files
committed
added rangeCount check. see facebookarchive#1571
1 parent 1ab3dca commit 2ada60d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/component/selection/setDraftEditorSelection.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,11 @@ function addFocusToSelection(
304304
// Additionally, clone the selection range. IE11 throws an
305305
// InvalidStateError when attempting to access selection properties
306306
// after the range is detached.
307-
var range = selection.getRangeAt(0);
308-
range.setEnd(node, offset);
309-
selection.addRange(range.cloneRange());
307+
if (selection.rangeCount > 0) {
308+
var range = selection.getRangeAt(0);
309+
range.setEnd(node, offset);
310+
selection.addRange(range.cloneRange());
311+
}
310312
}
311313
}
312314

0 commit comments

Comments
 (0)