util.dom: clearSelection; TextSelection.getState: fix to work correctly with empty selection