From 8cf8f2a520b2ecc1816737dc65492e52e491c61b Mon Sep 17 00:00:00 2001 From: Adam Pritchard Date: Wed, 3 Oct 2012 22:29:13 -0400 Subject: [PATCH] Fix for bug #31: Sometimes Mozilla gives a bad focused element, resulting in a lost email. --- src/common/markdown-here.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/common/markdown-here.js b/src/common/markdown-here.js index 822a0f8c..606b5983 100644 --- a/src/common/markdown-here.js +++ b/src/common/markdown-here.js @@ -28,6 +28,13 @@ function findFocusedElem(document) { focusedElem = focusedElem.contentDocument.activeElement; } + // There's a bug in Firefox/Thunderbird that we need to work around. For + // details see https://github.com/adam-p/markdown-here/issues/31 + // The short version: Sometimes we'll get the element instead of . + if (focusedElem instanceof document.defaultView.HTMLHtmlElement) { + focusedElem = focusedElem.ownerDocument.body; + } + return focusedElem; }