File tree Expand file tree Collapse file tree 2 files changed +5
-8
lines changed
Expand file tree Collapse file tree 2 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -298,7 +298,7 @@ describe('MatCheckbox', () => {
298298 fixture . changeDetectorRef . markForCheck ( ) ;
299299 fixture . detectChanges ( ) ;
300300
301- expect ( checkboxInstance . inputId ) . toMatch ( / m a t - m d c - c h e c k b o x - \d + / ) ;
301+ expect ( checkboxInstance . inputId ) . toMatch ( / m a t - m d c - c h e c k b o x - \w + \ d+ / ) ;
302302 expect ( inputElement . id ) . toBe ( checkboxInstance . inputId ) ;
303303 } ) ) ;
304304
@@ -965,8 +965,8 @@ describe('MatCheckbox', () => {
965965 . queryAll ( By . directive ( MatCheckbox ) )
966966 . map ( debugElement => debugElement . nativeElement . querySelector ( 'input' ) . id ) ;
967967
968- expect ( firstId ) . toMatch ( / m a t - m d c - c h e c k b o x - \d + - i n p u t / ) ;
969- expect ( secondId ) . toMatch ( / m a t - m d c - c h e c k b o x - \d + - i n p u t / ) ;
968+ expect ( firstId ) . toMatch ( / m a t - m d c - c h e c k b o x - \w + \ d+ - i n p u t / ) ;
969+ expect ( secondId ) . toMatch ( / m a t - m d c - c h e c k b o x - \w + \ d+ - i n p u t / ) ;
970970 expect ( firstId ) . not . toEqual ( secondId ) ;
971971 } ) ) ;
972972 } ) ;
Original file line number Diff line number Diff line change 66 * found in the LICENSE file at https://angular.dev/license
77 */
88
9- import { FocusableOption } from '@angular/cdk/a11y' ;
9+ import { _IdGenerator , FocusableOption } from '@angular/cdk/a11y' ;
1010import {
1111 ANIMATION_MODULE_TYPE ,
1212 AfterViewInit ,
@@ -77,9 +77,6 @@ export class MatCheckboxChange {
7777 checked : boolean ;
7878}
7979
80- // Increasing integer for generating unique ids for checkbox components.
81- let nextUniqueId = 0 ;
82-
8380// Default checkbox configuration.
8481const defaults = MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY ( ) ;
8582
@@ -255,7 +252,7 @@ export class MatCheckbox
255252 this . _options = this . _options || defaults ;
256253 this . color = this . _options . color || defaults . color ;
257254 this . tabIndex = tabIndex == null ? 0 : parseInt ( tabIndex ) || 0 ;
258- this . id = this . _uniqueId = ` mat-mdc-checkbox-${ ++ nextUniqueId } ` ;
255+ this . id = this . _uniqueId = inject ( _IdGenerator ) . getId ( ' mat-mdc-checkbox-' ) ;
259256 this . disabledInteractive = this . _options ?. disabledInteractive ?? false ;
260257 }
261258
You can’t perform that action at this time.
0 commit comments