@@ -14,29 +14,20 @@ function triggerFocusChange(element: HTMLElement, event: 'focus' | 'blur') {
14
14
element . addEventListener ( event , handler ) ;
15
15
element [ event ] ( ) ;
16
16
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.
20
17
if ( ! eventFired ) {
21
- simulateFocusSequence ( element , event ) ;
18
+ dispatchFakeEvent ( element , event ) ;
22
19
}
23
20
}
24
21
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
-
31
22
/**
32
23
* Patches an elements focus and blur methods to emit events consistently and predictably.
33
24
* This is necessary, because some browsers, like IE11, will call the focus handlers asynchronously,
34
25
* while others won't fire them at all if the browser window is not focused.
35
26
* @docs -private
36
27
*/
37
28
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' ) ;
40
31
}
41
32
42
33
/** @docs -private */
0 commit comments