From 90f906b626d370a82f5143f84bf1384060386e46 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Tue, 17 Feb 2015 23:24:06 +0000 Subject: Remove redundant check, make isSelected's behaviour match its contract --- lib/dom_utils.coffee | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 83fb045c..fae29e49 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -171,13 +171,11 @@ DomUtils = # being accessed. isSelected: (element) -> if element.isContentEditable - node = document.getSelection()?.anchorNode + node = document.getSelection().anchorNode node and @isDOMDescendant element, node else - # Note. This makes the wrong decision if the user has placed the caret at the start of element. We - # cannot distinguish that case from the user having made no selection. try - element.selectionEnd != 0 + element.selectionStart != element.selectionEnd catch # This input element doesn't support selectionStart/selectionEnd. # NOTE(mrmr1993): We choose true here because it does the right thing everywhere in the code. I am -- cgit v1.2.3