]> git.gir.st - VimFx.git/commit
Fix focusType after searching issues on github
authorSimon Lydell <simon.lydell@gmail.com>
Sat, 5 Mar 2016 12:29:52 +0000 (13:29 +0100)
committerSimon Lydell <simon.lydell@gmail.com>
Sat, 5 Mar 2016 13:03:41 +0000 (14:03 +0100)
commitcd7119937b9337ce3af1e44394bc66ebcade3d94
treeec658608fda9f311739c604bcb9b0ad5a83c78f2
parent11d3db5b90d39a04ac79647581454eb6f10c9599
Fix focusType after searching issues on github

When searching for issues on github, the results are fetched with AJAX and then
inserted into the page. More accurately, the fetched content _replaces_ already
existing content on the page, including the search input. It turns out that
neither 'focus' nor 'blur' events are fired when a focused text input is removed
from the DOM (even though that actually blurs it and focuses `<body>`). This
caused VimFx to believe that the text input was still focused, which meant that
you had to press `<escape>` before you could use any VimFx commands. Using a
`MutationObserver`, this commit temporarily observes the currently focused
element (unless `focusType == 'none'`, because that's unnecessary and might
degrade performance). If the element gets removed, the current `focusType` is
updated, fixing the problem.

To check if an element gets removed from the DOM requires observing the _entire_
document tree, recursively. The `utils.onRemoved` function did (wrongly) not do
that, so it had to be updated.

Because of the update to `utils.onRemoved`, this commit also removes the
`MutationObserver`s for scrollable elements. The reason they were added in the
first place was to try to reduce memory consumption by pruning the list of
scrollable elements from elements removed from the DOM. However, the observers
were buggy: They were only triggered if _only_ the scrollable element was
removed, not if one of its parents were removed. Since this "buggy" behavior has
been used for quite some time now and it hasn't caused any memory problems, one
can draw the conclusion that the observers are not needed. That's good, because
it means that there's no need to add observers for the entire document on
basically _every_ page.
extension/lib/events-frame.coffee
extension/lib/scrollable-elements.coffee
extension/lib/utils.coffee
Imprint / Impressum