|
6 | 6 | * found in the LICENSE file at https://angular.dev/license
|
7 | 7 | */
|
8 | 8 |
|
9 |
| -import {ActiveDescendantKeyManager, Highlightable, ListKeyManagerOption} from '@angular/cdk/a11y'; |
| 9 | +import { |
| 10 | + _IdGenerator, |
| 11 | + ActiveDescendantKeyManager, |
| 12 | + Highlightable, |
| 13 | + ListKeyManagerOption, |
| 14 | +} from '@angular/cdk/a11y'; |
10 | 15 | import {Directionality} from '@angular/cdk/bidi';
|
11 | 16 | import {coerceArray} from '@angular/cdk/coercion';
|
12 | 17 | import {SelectionModel} from '@angular/cdk/collections';
|
@@ -42,9 +47,6 @@ import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
|
42 | 47 | import {defer, fromEvent, merge, Observable, Subject} from 'rxjs';
|
43 | 48 | import {filter, map, startWith, switchMap, takeUntil} from 'rxjs/operators';
|
44 | 49 |
|
45 |
| -/** The next id to use for creating unique DOM IDs. */ |
46 |
| -let nextId = 0; |
47 |
| - |
48 | 50 | /**
|
49 | 51 | * An implementation of SelectionModel that internally always represents the selection as a
|
50 | 52 | * multi-selection. This is necessary so that we can recover the full selection if the user
|
@@ -104,7 +106,7 @@ export class CdkOption<T = unknown> implements ListKeyManagerOption, Highlightab
|
104 | 106 | this._id = value;
|
105 | 107 | }
|
106 | 108 | private _id: string;
|
107 |
| - private _generatedId = `cdk-option-${nextId++}`; |
| 109 | + private _generatedId = inject(_IdGenerator).getId('cdk-option-'); |
108 | 110 |
|
109 | 111 | /** The value of this option. */
|
110 | 112 | @Input('cdkOption') value: T;
|
@@ -262,7 +264,7 @@ export class CdkListbox<T = unknown> implements AfterContentInit, OnDestroy, Con
|
262 | 264 | this._id = value;
|
263 | 265 | }
|
264 | 266 | private _id: string;
|
265 |
| - private _generatedId = `cdk-listbox-${nextId++}`; |
| 267 | + private _generatedId = inject(_IdGenerator).getId('cdk-listbox-'); |
266 | 268 |
|
267 | 269 | /** The tabindex to use when the listbox is enabled. */
|
268 | 270 | @Input('tabindex')
|
|
0 commit comments