The check above is (!selection.anchorNode && !selection.focusNode). Could it happen that only selection.focusNode is not set? In that case the above branch would not be passed, but this branch will. Cannot oversee right now if that is good or bad.