File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import {MdDatepickerIntl} from './datepicker-intl';
99  template : '' , 
1010  styleUrls : [ 'datepicker-toggle.css' ] , 
1111  host : { 
12+     '[attr.type]' : 'type' , 
1213    '[class.mat-datepicker-toggle]' : 'true' , 
1314    '[attr.aria-label]' : '_intl.openCalendarLabel' , 
1415    '(click)' : '_open($event)' , 
@@ -17,8 +18,12 @@ import {MdDatepickerIntl} from './datepicker-intl';
1718  changeDetection : ChangeDetectionStrategy . OnPush , 
1819} ) 
1920export  class  MdDatepickerToggle < D >  { 
21+   /** Datepicker instance that the button will toggle. */ 
2022  @Input ( 'mdDatepickerToggle' )  datepicker : MdDatepicker < D > ; 
2123
24+   /** Type of the button. */ 
25+   @Input ( )  type : string  =  'button' ; 
26+ 
2227  @Input ( 'matDatepickerToggle' ) 
2328  get  _datepicker ( )  {  return  this . datepicker ;  } 
2429  set  _datepicker ( v : MdDatepicker < D > )  {  this . datepicker  =  v ;  } 
Original file line number Diff line number Diff line change @@ -374,15 +374,20 @@ describe('MdDatepicker', () => {
374374        fixture . detectChanges ( ) ; 
375375      } ) ) ; 
376376
377-       it ( 'should open calendar when toggle clicked' ,  async ( ( )  =>  { 
377+       it ( 'should open calendar when toggle clicked' ,  ( )  =>  { 
378378        expect ( document . querySelector ( 'md-dialog-container' ) ) . toBeNull ( ) ; 
379379
380380        let  toggle  =  fixture . debugElement . query ( By . css ( 'button' ) ) ; 
381381        dispatchMouseEvent ( toggle . nativeElement ,  'click' ) ; 
382382        fixture . detectChanges ( ) ; 
383383
384384        expect ( document . querySelector ( 'md-dialog-container' ) ) . not . toBeNull ( ) ; 
385-       } ) ) ; 
385+       } ) ; 
386+ 
387+       it ( 'should set the `button` type on the trigger to prevent form submissions' ,  ( )  =>  { 
388+         let  toggle  =  fixture . debugElement . query ( By . css ( 'button' ) ) . nativeElement ; 
389+         expect ( toggle . getAttribute ( 'type' ) ) . toBe ( 'button' ) ; 
390+       } ) ; 
386391    } ) ; 
387392
388393    describe ( 'datepicker inside input-container' ,  ( )  =>  { 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments