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', () => {
298
298
fixture . changeDetectorRef . markForCheck ( ) ;
299
299
fixture . detectChanges ( ) ;
300
300
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+ / ) ;
302
302
expect ( inputElement . id ) . toBe ( checkboxInstance . inputId ) ;
303
303
} ) ) ;
304
304
@@ -965,8 +965,8 @@ describe('MatCheckbox', () => {
965
965
. queryAll ( By . directive ( MatCheckbox ) )
966
966
. map ( debugElement => debugElement . nativeElement . querySelector ( 'input' ) . id ) ;
967
967
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 / ) ;
970
970
expect ( firstId ) . not . toEqual ( secondId ) ;
971
971
} ) ) ;
972
972
} ) ;
Original file line number Diff line number Diff line change 6
6
* found in the LICENSE file at https://angular.dev/license
7
7
*/
8
8
9
- import { FocusableOption } from '@angular/cdk/a11y' ;
9
+ import { _IdGenerator , FocusableOption } from '@angular/cdk/a11y' ;
10
10
import {
11
11
ANIMATION_MODULE_TYPE ,
12
12
AfterViewInit ,
@@ -77,9 +77,6 @@ export class MatCheckboxChange {
77
77
checked : boolean ;
78
78
}
79
79
80
- // Increasing integer for generating unique ids for checkbox components.
81
- let nextUniqueId = 0 ;
82
-
83
80
// Default checkbox configuration.
84
81
const defaults = MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY ( ) ;
85
82
@@ -255,7 +252,7 @@ export class MatCheckbox
255
252
this . _options = this . _options || defaults ;
256
253
this . color = this . _options . color || defaults . color ;
257
254
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-' ) ;
259
256
this . disabledInteractive = this . _options ?. disabledInteractive ?? false ;
260
257
}
261
258
You can’t perform that action at this time.
0 commit comments