Generate a FocusEvent (not Event) for focus-related events - #272
Conversation
ContextThe reason that this initially came to my attention (and my motivation for this change) is that a JavaScript library that I use ( Because currently on This change makes it so that those warnings are no longer printed when I use the Capybara |
|
Looking at the Ruby 3.3 test run, there are five failing specs (link). I believe that none of those failures are related to my change, and that those failures are already present on Edit: I submitted a separate PR to fix these spec failures. |
| }) | ||
| .focus(function(event) { | ||
| $("#changes_on_focus").text("Focus") | ||
| $("#changes_on_focus").text(`Focus (${event.originalEvent.constructor.name})`) |
There was a problem hiding this comment.
I would like tests to cover the change in this PR, so I added the event constructor name in parentheses here. On main, this text would be Focus (Event). On this branch, it's Focus (FocusEvent).
I have submitted a separate PR to fix these spec failures that currently exist on the |
ad4a53d to
3047b60
Compare
|
Thanks for this — confirmed the underlying issue is real and still present on main (focus/blur events dispatch as plain Event instead of FocusEvent, which trips up libraries doing I rebased this onto current main and also swapped the deprecated document.createEvent/initEvent pair for the modern |
|
@route Thank you so much for taking a look, improving this branch, and merging! This has been continuing to be a small annoyance for me, so I'm grateful that it has been resolved on |

Currently on
main, focus-related events (blur, focus, focusin, and focusout) create a JavaScriptEventobject.However, as can be seen by clicking into and out of the input in this JSFiddle (tested in Firefox 130 and Chrome 128), those events should actually be JavaScript
FocusEventobjects (notEventobjects).This change makes it so that Cuprite will generate
FocusEventobjects (notEventobjects) for focus-related events.