aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dom_utils.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dom_utils.coffee')
-rw-r--r--lib/dom_utils.coffee7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index 62e655e7..7735f62b 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -94,14 +94,15 @@ DomUtils =
# Selectable means the element has a text caret; this is not the same as "focusable".
#
isSelectable: (element) ->
- selectableTypes = ["search", "text", "password"]
- (element.nodeName.toLowerCase() == "input" && selectableTypes.indexOf(element.type) >= 0) ||
+ unselectableTypes = ["button", "checkbox", "color", "file", "hidden", "image", "radio", "reset"]
+ (element.nodeName.toLowerCase() == "input" && unselectableTypes.indexOf(element.type) == -1) ||
element.nodeName.toLowerCase() == "textarea"
simulateSelect: (element) ->
element.focus()
# When focusing a textbox, put the selection caret at the end of the textbox's contents.
- element.setSelectionRange(element.value.length, element.value.length)
+ # 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)
simulateClick: (element, modifiers) ->
modifiers ||= {}