@@ -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 )
@@ -417,7 +417,7 @@ describe('MdAutocomplete', () => {
417
417
. toBe ( false , `Expected control to stay pristine if value is set programmatically.` ) ;
418
418
} ) ;
419
419
420
- it ( 'should mark the autocomplete control as touched on blur ' , ( ) => {
420
+ it ( 'should mark the autocomplete control as touched on focusout ' , ( ) => {
421
421
fixture . componentInstance . trigger . openPanel ( ) ;
422
422
fixture . detectChanges ( ) ;
423
423
expect ( fixture . componentInstance . stateCtrl . touched )
@@ -427,7 +427,7 @@ describe('MdAutocomplete', () => {
427
427
fixture . detectChanges ( ) ;
428
428
429
429
expect ( fixture . componentInstance . stateCtrl . touched )
430
- . toBe ( true , `Expected control to become touched on blur .` ) ;
430
+ . toBe ( true , `Expected control to become touched on focusout .` ) ;
431
431
} ) ;
432
432
433
433
} ) ;
@@ -912,9 +912,15 @@ class AutocompleteWithoutForms {
912
912
* Dispatches an event from an element.
913
913
* @param eventName Name of the event
914
914
* @param element The element from which the event will be dispatched.
915
+ * @param extras Extra properties to be attached to the event object.
915
916
*/
916
- function dispatchEvent ( eventName : string , element : HTMLElement ) : void {
917
+ function dispatchEvent ( eventName : string , element : HTMLElement , extras ?: any ) : void {
917
918
let event = document . createEvent ( 'Event' ) ;
919
+
920
+ if ( extras ) {
921
+ Object . assign ( event , extras ) ;
922
+ }
923
+
918
924
event . initEvent ( eventName , true , true ) ;
919
925
element . dispatchEvent ( event ) ;
920
926
}
0 commit comments