From d4ad99aec8ed1689dac1b197a7b4df63c959fcfb Mon Sep 17 00:00:00 2001 From: Anton Khodakivskiy Date: Mon, 3 Mar 2014 10:34:23 -0800 Subject: [PATCH] Bug fixes --- extension/packages/mode-hints/mode-hints.coffee | 6 +++--- extension/packages/utils.coffee | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/extension/packages/mode-hints/mode-hints.coffee b/extension/packages/mode-hints/mode-hints.coffee index afd5c46b..94b41c6e 100644 --- a/extension/packages/mode-hints/mode-hints.coffee +++ b/extension/packages/mode-hints/mode-hints.coffee @@ -6,11 +6,11 @@ hints = require 'mode-hints/hints' exports.mode_hints = onEnter: (vim, storage, callback) -> markers = hints.injectHints(vim.window.document) - if markers.length == 0 - vim.enterMode('normal') - else + if markers?.length > 0 storage.markers = markers storage.callback = callback + else + vim.enterMode('normal') onLeave: (vim, storage) -> hints.removeHints(vim.window.document) diff --git a/extension/packages/utils.coffee b/extension/packages/utils.coffee index 4b8e78ee..1f74a079 100644 --- a/extension/packages/utils.coffee +++ b/extension/packages/utils.coffee @@ -68,7 +68,7 @@ blurActiveElement = (window) -> # really needed? What if a website has made more elements focusable -- shouldn't those also be # blurred? { activeElement } = window.document - if isElementEditable(activeElement) + if activeElement and isElementEditable(activeElement) activeElement.blur() isTextInputElement = (element) -> @@ -89,10 +89,10 @@ isElementEditable = (element) -> isElementVisible = (element) -> document = element.ownerDocument window = document.defaultView - computedStyle = window.getComputedStyle(element, null) - return computedStyle.getPropertyValue('visibility') == 'visible' and \ - computedStyle.getPropertyValue('display') != 'none' and \ - computedStyle.getPropertyValue('opacity') != '0' + if computedStyle = window.getComputedStyle(element, null) + return computedStyle.getPropertyValue('visibility') == 'visible' and \ + computedStyle.getPropertyValue('display') != 'none' and \ + computedStyle.getPropertyValue('opacity') != '0' getWindowId = (window) -> return window