-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(multiple): include APP_ID in element IDs #29263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a common helper for this so in the future we only have one place we'd need to change?
Yeah, I could see having something like let nextId = 0;
@Injectable()
class IdGenerator {
appId = inject(APP_ID);
generateId(prefix: string) {
return `${prefix}${this.appId}${nextId++}`;
}
} I guess in |
Yeah I think |
Updated the PR to include an |
2327d53
to
2bbe914
Compare
Adds a tiny utility class for generating unique element IDs.
Many components generate element IDs, which are used primarily for accessible labeling. The IDs all use an incrementing number concatenated with some stirng specific to that component. This change add Angular's `APP_ID` into these IDs in order to avoid ID collisions in cases where there are multiple instances of Angular running on the same page.
Closing in favor of #29948. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Many components generate element IDs, which are used primarily for accessible labeling. The IDs all use an incrementing number concatenated with some stirng specific to that component. This change add Angular's
APP_ID
into these IDs in order to avoid ID collisions in cases where there are multiple instances of Angular running on the same page.