mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Check for null selection
getRangeAt(0) will throw on null selection. Add guard in ReactDOMSelection and DocumentSelection.
This commit is contained in:
committed by
Paul O’Shannessy
parent
4549fd7510
commit
58c392ae3b
@@ -56,10 +56,15 @@ function getIEOffsets(node) {
|
||||
|
||||
/**
|
||||
* @param {DOMElement} node
|
||||
* @return {object}
|
||||
* @return {?object}
|
||||
*/
|
||||
function getModernOffsets(node) {
|
||||
var selection = window.getSelection();
|
||||
|
||||
if (selection.rangeCount === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var anchorNode = selection.anchorNode;
|
||||
var anchorOffset = selection.anchorOffset;
|
||||
var focusNode = selection.focusNode;
|
||||
|
||||
Reference in New Issue
Block a user