Tests: Account for extra focus/blur listeners in jQuery >=3.4#1930
Conversation
jQuery >=3.4.0 uses a special focus/blur handler pair needed to fix various issues with checkboxes/radio buttons as well as being able to pass data in focus triggers. However, this leaves dummy focus & blur events if any of these events were ever listened to at a particular element. There's not a lot UI can do to fix this so we now just skip these handlers for data comparisons in tests. Ref jquery/jquery#4496
timmywil
left a comment
There was a problem hiding this comment.
LGTM. A little hacky, but should be future safe.
gibson042
left a comment
There was a problem hiding this comment.
This fix fails to filter out the dummy handlers added when .trigger precedes .on, but that would only be a problem if such cases exist in the test suite. Apparently they don't, so this works! 👍
| // a lot UI can do to fix this so just skip these handlers for | ||
| // data comparisons in tests. | ||
| // See https://github.com/jquery/jquery/issues/4496 | ||
| if ( result.events && jQueryVersionSince( "3.4.0" ) ) { |
There was a problem hiding this comment.
Do we actually need to restrict this code to jQuery >= 3.4.0? What would happen without the check?
There was a problem hiding this comment.
I thought since this excludes some things from the compared objects, in older jQueries where there are no additional listeners we could perform a full check. There's always a risk that the workaround will not account for some real differences and by restricting it to jQuery >=3.4.0 we'd see a test error in older jQuery versions in such a case.
UI is currently tested with Core >=1.8.
Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
jQuery >=3.4.0 uses a special focus/blur handler pair needed to fix various issues with checkboxes/radio buttons as well as being able to pass data in focus triggers. This leaves extra focus & blur events if any of these events were ever listened to at a particular element. We've started skipping these handlers in the `domEqual` assertion in jquerygh-1930 but we missed a case where an event is triggered before any handler is attached - jQuery >=3.4.0 attaches then an extra noop listener just to force the code path to go through the setup code before the trigger happens. We now skip this extra handler as well. This fixes a test failure in "dialog: methods" destroy tests. Ref jquery/jquery#4496 Ref jquerygh-1930
jQuery >=3.4.0 uses a special focus/blur handler pair needed to fix various issues with checkboxes/radio buttons as well as being able to pass data in focus triggers. This leaves extra focus & blur events if any of these events were ever listened to at a particular element. We've started skipping these handlers in the `domEqual` assertion in jquerygh-1930 but we missed a case where an event is triggered before any handler is attached - jQuery >=3.4.0 attaches then an extra noop listener just to force the code path to go through the setup code before the trigger happens. We now skip this extra handler as well. This fixes a test failure in "dialog: methods" destroy tests. Ref jquery/jquery#4496 Ref jquerygh-1930
jQuery >=3.4.0 uses a special focus/blur handler pair needed to fix various issues with checkboxes/radio buttons as well as being able to pass data in focus triggers. This leaves extra focus & blur events if any of these events were ever listened to at a particular element. We've started skipping these handlers in the `domEqual` assertion in jquerygh-1930 but we missed a case where an event is triggered before any handler is attached - jQuery >=3.4.0 attaches then an extra noop listener just to force the code path to go through the setup code before the trigger happens. We now skip this extra handler as well. This fixes a test failure in "dialog: methods" destroy tests. Ref jquery/jquery#4496 Ref jquerygh-1930
jQuery >=3.4.0 uses a special focus/blur handler pair needed to fix various issues with checkboxes/radio buttons as well as being able to pass data in focus triggers. This leaves extra focus & blur events if any of these events were ever listened to at a particular element. We've started skipping these handlers in the `domEqual` assertion in gh-1930 but we missed a case where an event is triggered before any handler is attached - jQuery >=3.4.0 attaches then an extra noop listener just to force the code path to go through the setup code before the trigger happens. We now skip this extra handler as well. This fixes a test failure in "dialog: methods" destroy tests. Closes gh-1945 Ref jquery/jquery#4496 Ref gh-1930
jQuery >=3.4.0 uses a special focus/blur handler pair
needed to fix various issues with checkboxes/radio buttons
as well as being able to pass data in focus triggers.
However, this leaves dummy focus & blur events if any of these
events were ever listened to at a particular element. There's not
a lot UI can do to fix this so we now just skip these handlers for
data comparisons in tests.
Ref jquery/jquery#4496