aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dom_utils.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-01-18 11:35:30 +0000
committerStephen Blott2015-01-18 11:35:30 +0000
commite700982a20737bdc1cf0c4babaa2c199a53a1300 (patch)
tree86c1990124f6414b1525ac3e578be80164dc5021 /lib/dom_utils.coffee
parent9c572b3863018c4cc8ed11a1e43aa7b7e76cc281 (diff)
downloadvimium-e700982a20737bdc1cf0c4babaa2c199a53a1300.tar.bz2
Move isSelected test to before possible blur/click.
Diffstat (limited to 'lib/dom_utils.coffee')
-rw-r--r--lib/dom_utils.coffee3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index af563fd1..21a00ae4 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -176,13 +176,14 @@ DomUtils =
element.selectionStart? and element.selectionEnd? and element.selectionStart != element.selectionEnd
simulateSelect: (element) ->
+ isSelected = @isSelected element
# If element == document.activeElement, then we won't get a new focus event. So, we pretend (to any
# active modes which care, e.g. PostFindMode) that element has been clicked.
if element == document.activeElement and DomUtils.isEditable document.activeElement
handlerStack.bubbleEvent "click", target: element
element.focus()
- unless @isSelected element
+ unless isSelected
# When focusing a textbox, put the selection caret at the end of the textbox's contents.
# For some HTML5 input types (eg. date) we can't position the caret, so we wrap this with a try.
try element.setSelectionRange(element.value.length, element.value.length)