Skip to content
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

Event: Use only one focusin/out handler per matching window & document #4656

Merged
merged 1 commit into from
Apr 6, 2020

Conversation

mgol
Copy link
Member

@mgol mgol commented Apr 6, 2020

Summary

The doc variable in:
https://github.com/jquery/jquery/blob/3.4.1/src/event/focusin.js#L30
matched document for document & window for window, creating two separate
wrapper event handlers & calling handlers twice if at least one focusout or
focusin handler was attached on both window & document, or on window
& another regular node.

Also, fix the "focusin from an iframe" test to actually verify the behavior
from commit 1cecf64 - the commit that
introduced the regression - to make sure we don't regress on either front.

+5 bytes.

Test updates should be cherry-picked to master without any source changes.

Checklist

@mgol mgol added Bug Event Needs review Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. labels Apr 6, 2020
@mgol mgol added this to the 3.5.0 milestone Apr 6, 2020
@mgol mgol self-assigned this Apr 6, 2020
@mgol mgol force-pushed the 3.x-focusin-window-document branch 2 times, most recently from 0a19d1a to 2e48489 Compare April 6, 2020 16:26

// DOM focus is unreliable in TestSwarm
if ( QUnit.isSwarm && !focus ) {
assert.ok( true, "GAP: Could not observe focus change" );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gibson042 BTW, I copied this from other similar assertions but... what is GAP?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My attempt to make clear that this is not a true passing assertion, but rather a failure to verify the desired assertion at all... a gap between intent and capability.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Since it’s all uppercase, I thought it’s an acronym. 😅

@mgol mgol force-pushed the 3.x-focusin-window-document branch from 2e48489 to 6f78bba Compare April 6, 2020 16:46
@timmywil timmywil removed the Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. label Apr 6, 2020
@mgol mgol removed the Needs review label Apr 6, 2020
… document

The `doc` variable in:
https://github.com/jquery/jquery/blob/3.4.1/src/event/focusin.js#L30
matched `document` for `document` & `window` for `window`, creating two separate
wrapper event handlers & calling handlers twice if at least one `focusout` or
`focusin` handler was attached on *both* `window` & `document`, or on `window`
& another regular node.

Also, fix the "focusin from an iframe" test to actually verify the behavior
from commit 1cecf64 - the commit that
introduced the regression - to make sure we don't regress on either front.
@mgol mgol force-pushed the 3.x-focusin-window-document branch from 6f78bba to a236eca Compare April 6, 2020 17:57
@mgol mgol changed the title Event: attach only one focusin/focusout handler per matching window & document Event: Use only one focusin/out handler per matching window & document Apr 6, 2020
@mgol mgol merged commit 9e15d6b into jquery:3.x-stable Apr 6, 2020
@mgol mgol deleted the 3.x-focusin-window-document branch April 6, 2020 18:34
mgol added a commit to mgol/jquery that referenced this pull request Apr 6, 2020
Backport tests from a jQuery 3.x fix that's not needed on `master`.

Also, fix the "focusin from an iframe" test to actually verify the behavior
from commit 1cecf64 - the commit that
introduced the regression - to make sure we don't regress on either front.

The main part of the modified test was checking that focusin handling in an
iframe works and that's still checked. The test was also checking that it
doesn't propagate to the parent document, though, and, apparently, in IE it
does. This one test is now blacklisted in IE.

(cherry picked from 9e15d6b)
(cherry picked from 1a4f10d)

Ref jquerygh-4652
Ref jquerygh-4656
@mgol
Copy link
Member Author

mgol commented Apr 6, 2020

Tests backported to master in #4657.

mgol added a commit that referenced this pull request Apr 27, 2020
Backport tests from a jQuery 3.x fix that's not needed on `master`.

Also, fix the "focusin from an iframe" test to actually verify the behavior
from commit 1cecf64 - the commit that
introduced the regression - to make sure we don't regress on either front.

The main part of the modified test was checking that focusin handling in an
iframe works and that's still checked. The test was also checking that it
doesn't propagate to the parent document, though, and, apparently, in IE it
does. This one test is now blacklisted in IE.

(cherry picked from 9e15d6b)
(cherry picked from 1a4f10d)

Ref gh-4652
Ref gh-4656
Closes gh-4657
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants