Check for null selection

getRangeAt(0) will throw on null selection. Add guard in
ReactDOMSelection and DocumentSelection.