-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of shadowRoot in page makes each focus event register another focus handler, potentially building up to massive slowdowns #2504
Comments
Fixes philc#2504. For some reason, the test removed here never fires. However, it appears that *any* `blur` event has to result in an input within the shadow DOM (which previously had the focus) losing the focus. Therefore, we don't need this test. Aside: - This code is firing *twice*. So, we add two handlers and remove two handlers each time. This seems to be harmless. I think what's happening is that we first see the event when it's bubbling down, so our newly-added handler on the shadow-DOM element fires again as the event continues bubbling down.
The shadow DOM spec has changed now... 😡
There's possibly also mileage in something like (to get the active element): active = document.activeElement
shadow = active.shadowRoot
while shadow?
break unless shadow.activeElement?
active = shadow.activeElement
shadow = active.shadow But doing this doesn't alert us to transitions to/from a focused element's insert mode. I'll see if I can throw something together. (@smblott-github do we need to support the fix for old versions too? I can't remember how |
Great, thanks for working on this @mrmr1993 and @smblott-github ! |
@mrmr1993. What about this... Leaving the event listener in place when the focus is lost is not, in itself, a problem. So we don't actually have to remove the event listeners. The problem is just that we must not install lots of listeners. So why not just make it a singleton? When adding a new listener, remove the previous listener (if any). That's considerably simpler. This is a bit of a corner case, to which we shouldn't really be devoting large amounts of (hard-to-maintain) logic. |
I despair. Try the example with such an implementation (edit: example implementation).
If we want to play nicely with polymer elements (and other users of shadow DOMs), we should do this properly. |
This does not work correctly. Do not use this. See [1] for a description of the actual behaviour. To test brokenness: * visit http://openfin.github.io/fin-hypergrid-polymer-demo/components/fin-hypergrid/demo.html * double-click a cell to open it as editable * type in it using Vimium-bound keys * "Everything the Circus thinks is gold is shit..." [1] philc#2504 (comment)
@mrmr1993 Chrome shows real target in Vimium has dropped the support for So there would be a trade-off if using |
I think that this has been resolved in recent versions of vimium. Not 100% sure since I don't recall exactly how the flamegraph looked. Based on @smblott-github 's comment on #2399 (comment) , the related code has changed a lot, so not surprising this has been fixed as a consquence. |
I believe this line is the culprit: https://github.com/philc/vimium/blob/master/content_scripts/mode_insert.coffee#L69
Repro:
else if (event.target.shadowRoot) {
block of mode_insert.jsVimium 1.59
The text was updated successfully, but these errors were encountered: