in src/component/selection/setDraftEditorSelection.js [329:361]
function addPointToSelection(
selection: SelectionObject,
node: Node,
offset: number,
selectionState: SelectionState,
): void {
const range = getCorrectDocumentFromNode(node).createRange();
// logging to catch bug that is being reported in t16250795
if (offset > getNodeLength(node)) {
// in this case we know that the call to 'range.setStart' is about to throw
DraftJsDebugLogging.logSelectionStateFailure({
anonymizedDom: getAnonymizedEditorDOM(node),
extraParams: JSON.stringify({offset}),
selectionState: JSON.stringify(selectionState.toJS()),
});
DraftEffects.handleExtensionCausedError();
}
range.setStart(node, offset);
// IE sometimes throws Unspecified Error when trying to addRange
if (isIE) {
try {
selection.addRange(range);
} catch (e) {
if (__DEV__) {
/* eslint-disable-next-line no-console */
console.warn('Call to selection.addRange() threw exception: ', e);
}
}
} else {
selection.addRange(range);
}
}