selection: don’t assume focus creates a selection

Under rare circumstances (e.g. typing something, focusing the console,
then clicking on the page but outside the editor), the focus and blur
events were both fired in the same tick, and a selection was never
actually created. In that case, there was no selection during the next
tick for the focus handler to normalize, and an error was thrown; some
simple defensive programming solves this issue.