diff options
| author | Stephen Blott | 2017-04-22 07:37:57 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2017-04-22 07:38:22 +0100 | 
| commit | 681c61d37f0b937939e739d888e93c65add51463 (patch) | |
| tree | 20ede9a3b528b694ee3e545bcb4233b2c51d37b2 | |
| parent | 0975076abe3529e19dcd23655697791c39c3ff78 (diff) | |
| download | vimium-681c61d37f0b937939e739d888e93c65add51463.tar.bz2 | |
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.
| -rw-r--r-- | lib/dom_utils.coffee | 10 | 
1 files changed, 8 insertions, 2 deletions
| 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. | 
