Skip to content

Commit 3805519

Browse files
committed
Revert "fix(cdk/testing): simulate focusin/focusout events" (#23794)
This reverts commit ef7d9e0. (cherry picked from commit 5f72dbc)
1 parent edad40f commit 3805519

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/cdk/testing/testbed/fake-events/element-focus.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,20 @@ function triggerFocusChange(element: HTMLElement, event: 'focus' | 'blur') {
1414
element.addEventListener(event, handler);
1515
element[event]();
1616
element.removeEventListener(event, handler);
17-
18-
// Some browsers won't move focus if the browser window is blurred while other will move it
19-
// asynchronously. If that is the case, we fake the event sequence as a fallback.
2017
if (!eventFired) {
21-
simulateFocusSequence(element, event);
18+
dispatchFakeEvent(element, event);
2219
}
2320
}
2421

25-
/** Simulates the full event sequence for a focus event. */
26-
function simulateFocusSequence(element: HTMLElement, event: 'focus' | 'blur') {
27-
dispatchFakeEvent(element, event);
28-
dispatchFakeEvent(element, event === 'focus' ? 'focusin' : 'focusout');
29-
}
30-
3122
/**
3223
* Patches an elements focus and blur methods to emit events consistently and predictably.
3324
* This is necessary, because some browsers, like IE11, will call the focus handlers asynchronously,
3425
* while others won't fire them at all if the browser window is not focused.
3526
* @docs-private
3627
*/
3728
export function patchElementFocus(element: HTMLElement) {
38-
element.focus = () => simulateFocusSequence(element, 'focus');
39-
element.blur = () => simulateFocusSequence(element, 'blur');
29+
element.focus = () => dispatchFakeEvent(element, 'focus');
30+
element.blur = () => dispatchFakeEvent(element, 'blur');
4031
}
4132

4233
/** @docs-private */

0 commit comments

Comments
 (0)