From 636eaffd418a7a5346135eab34b88cdd4b0b4162 Mon Sep 17 00:00:00 2001 From: Antoine Gomez Date: Wed, 27 Jan 2016 18:49:45 +0100 Subject: [PATCH] Add support of iframe for keyboard event Really simple piece of code to add support of iframe in keyboard event activeElement test. --- src/js/plugin/handler/keyboard.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/js/plugin/handler/keyboard.js b/src/js/plugin/handler/keyboard.js index e2bcea5..1234172 100644 --- a/src/js/plugin/handler/keyboard.js +++ b/src/js/plugin/handler/keyboard.js @@ -53,9 +53,13 @@ function bindKeyboardHandler(element, i) { var activeElement = document.activeElement ? document.activeElement : i.ownerDocument.activeElement; if (activeElement) { - // go deeper if element is a webcomponent - while (activeElement.shadowRoot) { - activeElement = activeElement.shadowRoot.activeElement; + if (activeElement.tagName === 'IFRAME') { + activeElement = activeElement.contentDocument.activeElement; + } else { + // go deeper if element is a webcomponent + while (activeElement.shadowRoot) { + activeElement = activeElement.shadowRoot.activeElement; + } } if (h.isEditable(activeElement)) { return;