Skip to content

Commit 6996851

Browse files
committed
refactor(material/snack-bar): use ID generator
Switches to using the ID generator service to create unique IDs.
1 parent 621ec01 commit 6996851

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/material/snack-bar/snack-bar-container.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ import {
2929
TemplatePortal,
3030
} from '@angular/cdk/portal';
3131
import {Observable, Subject} from 'rxjs';
32-
import {AriaLivePoliteness} from '@angular/cdk/a11y';
32+
import {_IdGenerator, AriaLivePoliteness} from '@angular/cdk/a11y';
3333
import {Platform} from '@angular/cdk/platform';
3434
import {AnimationEvent} from '@angular/animations';
3535
import {MatSnackBarConfig} from './snack-bar-config';
3636

37-
let uniqueId = 0;
38-
3937
/**
4038
* Internal component that wraps user-provided snack bar content.
4139
* @docs-private
@@ -109,7 +107,7 @@ export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy
109107
_role?: 'status' | 'alert';
110108

111109
/** Unique ID of the aria-live element. */
112-
readonly _liveElementId = `mat-snack-bar-container-live-${uniqueId++}`;
110+
readonly _liveElementId = inject(_IdGenerator).getId('mat-snack-bar-container-live-');
113111

114112
constructor(...args: unknown[]);
115113

0 commit comments

Comments
 (0)