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.coffee8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index 322188b3..e1f1f442 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -166,6 +166,14 @@ DomUtils =
node = node.parentNode
false
+ # True if element contains the active selection range.
+ isSelected: (element) ->
+ if element.isContentEditable
+ node = document.getSelection()?.anchorNode
+ node and @isDOMDescendant element, node
+ else
+ element.selectionStart? and element.selectionEnd? and element.selectionStart != element.selectionEnd
+
simulateSelect: (element) ->
element.focus()
# When focusing a textbox, put the selection caret at the end of the textbox's contents.