From 4d7c53b3ebc4f7889cb6282e802ca198906e6ced Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sun, 15 Nov 2015 18:55:26 +0100 Subject: [PATCH] Make `gi` find text inputs in all frames --- extension/lib/commands-frame.coffee | 2 +- extension/lib/utils.coffee | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/extension/lib/commands-frame.coffee b/extension/lib/commands-frame.coffee index e0b3d96..5ad4ede 100644 --- a/extension/lib/commands-frame.coffee +++ b/extension/lib/commands-frame.coffee @@ -274,7 +274,7 @@ commands.follow_pattern = ({ vim, type, options }) -> commands.focus_text_input = ({ vim, storage, count = null }) -> { lastFocusedTextInput } = vim.state inputs = Array.filter( - vim.content.document.querySelectorAll('input, textarea'), (element) -> + utils.querySelectorAllDeep(vim.content, 'input, textarea'), (element) -> return isTextInputElement(element) and utils.area(element) > 0 ) if lastFocusedTextInput and lastFocusedTextInput not in inputs diff --git a/extension/lib/utils.coffee b/extension/lib/utils.coffee index 999d805..bc09675 100644 --- a/extension/lib/utils.coffee +++ b/extension/lib/utils.coffee @@ -222,6 +222,12 @@ insertText = (input, value) -> input.value[0...selectionStart] + value + input.value[selectionEnd..] input.selectionStart = input.selectionEnd = selectionStart + value.length +querySelectorAllDeep = (window, selector) -> + elements = Array.from(window.document.querySelectorAll(selector)) + for frame in window.frames + elements.push(querySelectorAllDeep(frame, selector)...) + return elements + setAttributes = (element, attributes) -> for attribute, value of attributes element.setAttribute(attribute, value) @@ -345,6 +351,7 @@ module.exports = { area createBox insertText + querySelectorAllDeep setAttributes windowContainsDeep -- 2.39.3