From 681c61d37f0b937939e739d888e93c65add51463 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 22 Apr 2017 07:37:57 +0100 Subject: Firefox: Polyfill for selection.type for visual mode. @mrmr1993... This puts the logic of how we choose the selection type in one place; so, if you have a better idea of how to determine the selection type, then we just change it here. Once. --- lib/dom_utils.coffee | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 8fdc319e..c21d5a29 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -326,9 +326,15 @@ DomUtils = @suppressEvent event handlerStack.suppressEvent - + # Polyfill for selection.type (which is not available in Firefox). getSelectionType: (selection) -> - selection.type + selection.type or do -> + if selection.rangeCount == 0 + "None" + else if selection.isCollapsed + "Caret" + else + "Range" # Adapted from: http://roysharon.com/blog/37. # This finds the element containing the selection focus. -- cgit v1.2.3