@@ -87,12 +87,12 @@ describe('MdAutocomplete', () => {
87
87
. toContain ( 'California' , `Expected panel to display when opened programmatically.` ) ;
88
88
} ) ;
89
89
90
- it ( 'should close the panel when blurred ' , async ( ( ) => {
90
+ it ( 'should close the panel when input loses focus ' , async ( ( ) => {
91
91
dispatchEvent ( 'focus' , input ) ;
92
92
fixture . detectChanges ( ) ;
93
93
94
94
fixture . whenStable ( ) . then ( ( ) => {
95
- dispatchEvent ( 'focusout' , input ) ;
95
+ dispatchEvent ( 'focusout' , input , { relatedTarget : document . body } ) ;
96
96
fixture . detectChanges ( ) ;
97
97
98
98
expect ( fixture . componentInstance . trigger . panelOpen )
@@ -413,7 +413,7 @@ describe('MdAutocomplete', () => {
413
413
. toBe ( false , `Expected control to stay pristine if value is set programmatically.` ) ;
414
414
} ) ;
415
415
416
- it ( 'should mark the autocomplete control as touched on blur ' , ( ) => {
416
+ it ( 'should mark the autocomplete control as touched on focusout ' , ( ) => {
417
417
fixture . componentInstance . trigger . openPanel ( ) ;
418
418
fixture . detectChanges ( ) ;
419
419
expect ( fixture . componentInstance . stateCtrl . touched )
@@ -423,7 +423,7 @@ describe('MdAutocomplete', () => {
423
423
fixture . detectChanges ( ) ;
424
424
425
425
expect ( fixture . componentInstance . stateCtrl . touched )
426
- . toBe ( true , `Expected control to become touched on blur .` ) ;
426
+ . toBe ( true , `Expected control to become touched on focusout .` ) ;
427
427
} ) ;
428
428
429
429
} ) ;
@@ -913,9 +913,15 @@ class AutocompleteWithoutForms {
913
913
* Dispatches an event from an element.
914
914
* @param eventName Name of the event
915
915
* @param element The element from which the event will be dispatched.
916
+ * @param extras Extra properties to be attached to the event object.
916
917
*/
917
- function dispatchEvent ( eventName : string , element : HTMLElement ) : void {
918
+ function dispatchEvent ( eventName : string , element : HTMLElement , extras ?: any ) : void {
918
919
let event = document . createEvent ( 'Event' ) ;
920
+
921
+ if ( extras ) {
922
+ Object . assign ( event , extras ) ;
923
+ }
924
+
919
925
event . initEvent ( eventName , true , true ) ;
920
926
element . dispatchEvent ( event ) ;
921
927
}
0 commit comments