From 604ae4c33a8236c582ebe7ecd09c09f64d6a0a3b Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Thu, 2 Nov 2017 13:52:03 +0000 Subject: FF: Don't use Selection.getRangeAt(0) when there are no ranges This fixes #2757. --- content_scripts/mode_find.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index 0fc147a3..950b08e9 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -82,6 +82,7 @@ class FindMode extends Mode FindMode.handleEscape() if event restoreSelection: -> + return unless @initialRange range = @initialRange selection = getSelection() selection.removeAllRanges() @@ -241,7 +242,10 @@ getCurrentRange = -> range else selection.collapseToStart() if selection.type == "Range" - selection.getRangeAt 0 + if selection.rangeCount > 0 + selection.getRangeAt 0 + else # Firefox returns a selection with no ranges and null anchor/focusNode in some situations. + null getLinkFromSelection = -> node = window.getSelection().anchorNode -- cgit v1.2.3