diff options
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 6 | ||||
| -rw-r--r-- | lib/dom_utils.coffee | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index eacf2eb1..9c86e808 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -660,7 +660,8 @@ selectFoundInputElement = -> # instead. however, since the last focused element might not be the one currently pointed to by find (e.g. # the current one might be disabled and therefore unable to receive focus), we use the approximate # heuristic of checking that the last anchor node is an ancestor of our element. - if (findModeQueryHasResults && DomUtils.isSelectable(document.activeElement) && + if (findModeQueryHasResults && document.activeElement && + DomUtils.isSelectable(document.activeElement) && isDOMDescendant(findModeAnchorNode, document.activeElement)) DomUtils.simulateSelect(document.activeElement) # the element has already received focus via find(), so invoke insert mode manually @@ -698,7 +699,8 @@ findAndFocus = (backwards) -> # if we have found an input element via 'n', pressing <esc> immediately afterwards sends us into insert # mode - elementCanTakeInput = DomUtils.isSelectable(document.activeElement) && + elementCanTakeInput = document.activeElement && + DomUtils.isSelectable(document.activeElement) && isDOMDescendant(findModeAnchorNode, document.activeElement) if (elementCanTakeInput) handlerStack.push({ diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 57930f80..d4a4d379 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -128,8 +128,8 @@ DomUtils = flashEl.style.top = rect.top + window.scrollY + "px" flashEl.style.width = rect.width + "px" flashEl.style.height = rect.height + "px" - document.body.appendChild(flashEl) - setTimeout((-> flashEl.parentNode.removeChild(flashEl)), 400) + document.documentElement.appendChild(flashEl) + setTimeout((-> DomUtils.removeElement flashEl), 400) root = exports ? window root.DomUtils = DomUtils |
