var anchorNode, sibling;
var selection = window.getSelection();
+ if (!selection.rangeCount) {
+ // Skip invocations that do not have an active range. This happens if the
+ // user loads a page but has not yet interacted with the page. Such a
+ // selection is the result of a synthetic event without any prior user
+ // interaction.
+ return;
+ }
+
if (!selection.isCollapsed) {
if (_isSafari && _iOS && _touchstartTarget === event.target && this.utils.isBlockTag(_touchstartTarget.nodeName)) {
// Treat this as a collapsed selection instead, because the iOS Safari