Skip to content

Commit 855d82f

Browse files
committed
refactor(cdk-experimental/table-scroll-container): use ID generator
Switches to using the ID generator service to create unique IDs.
1 parent 044e3fc commit 855d82f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/cdk-experimental/table-scroll-container/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ng_module(
1414
exclude = ["**/*.spec.ts"],
1515
),
1616
deps = [
17+
"//src/cdk/a11y",
1718
"//src/cdk/bidi",
1819
"//src/cdk/platform",
1920
"//src/cdk/table",

src/cdk-experimental/table-scroll-container/table-scroll-container.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
import {CSP_NONCE, Directive, ElementRef, OnDestroy, OnInit, inject} from '@angular/core';
10+
import {_IdGenerator} from '@angular/cdk/a11y';
1011
import {DOCUMENT} from '@angular/common';
1112
import {Directionality} from '@angular/cdk/bidi';
1213
import {_getShadowRoot} from '@angular/cdk/platform';
@@ -17,8 +18,6 @@ import {
1718
StickyUpdate,
1819
} from '@angular/cdk/table';
1920

20-
let nextId = 0;
21-
2221
/**
2322
* Applies styles to the host element that make its scrollbars match up with
2423
* the non-sticky scrollable portions of the CdkTable contained within.
@@ -43,7 +42,7 @@ export class CdkTableScrollContainer implements StickyPositioningListener, OnDes
4342
private readonly _directionality = inject(Directionality, {optional: true});
4443
private readonly _nonce = inject(CSP_NONCE, {optional: true});
4544

46-
private readonly _uniqueClassName = `cdk-table-scroll-container-${++nextId}`;
45+
private readonly _uniqueClassName = inject(_IdGenerator).getId('cdk-table-scroll-container-');
4746
private _styleRoot!: Node;
4847
private _styleElement?: HTMLStyleElement;
4948

0 commit comments

Comments
 (0)