diff options
| author | Stephen Blott | 2016-03-29 15:51:24 +0100 |
|---|---|---|
| committer | Stephen Blott | 2016-03-29 15:51:28 +0100 |
| commit | 77a2c6b41959f978147bd953ac94f5484394b276 (patch) | |
| tree | cbfd57277e302bb651ffa1c49a157bfe1ff7bd36 /content_scripts/vimium_frontend.coffee | |
| parent | 7ecc65d8215203b89248d8f313783ce48e8ba1c4 (diff) | |
| download | vimium-77a2c6b41959f978147bd953ac94f5484394b276.tar.bz2 | |
Fix race condition in grab-back-focus.
See the newly-added comment.
Diffstat (limited to 'content_scripts/vimium_frontend.coffee')
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 93ab440a..b9249e73 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -49,14 +49,17 @@ class GrabBackFocus extends Mode mousedown: => @alwaysContinueBubbling => @exit() Settings.use "grabBackFocus", (grabBackFocus) => - if grabBackFocus - @push - _name: "grab-back-focus-focus" - focus: (event) => @grabBackFocus event.target - # An input may already be focused. If so, grab back the focus. - @grabBackFocus document.activeElement if document.activeElement - else - @exit() + # It is possible that this mode exits (e.g. due to a key event) before the settings are ready -- in + # which case we should not install this grab-back-focus watcher. + if @modeIsActive + if grabBackFocus + @push + _name: "grab-back-focus-focus" + focus: (event) => @grabBackFocus event.target + # An input may already be focused. If so, grab back the focus. + @grabBackFocus document.activeElement if document.activeElement + else + @exit() grabBackFocus: (element) -> return @continueBubbling unless DomUtils.isEditable element |
