Skip to content

Commit 1551d52

Browse files
authored
refactor(cdk/a11y): restrict setAttribute fanout capability (#26503)
By restricting the type of the parameter of `addAriaReferencedId`, make sure it only sets `aria-` attributes.
1 parent 50ec808 commit 1551d52

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cdk/a11y/aria-describer/aria-reference.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const ID_DELIMITER = ' ';
1313
* Adds the given ID to the specified ARIA attribute on an element.
1414
* Used for attributes such as aria-labelledby, aria-owns, etc.
1515
*/
16-
export function addAriaReferencedId(el: Element, attr: string, id: string) {
16+
export function addAriaReferencedId(el: Element, attr: `aria-${string}`, id: string) {
1717
const ids = getAriaReferenceIds(el, attr);
1818
if (ids.some(existingId => existingId.trim() == id.trim())) {
1919
return;
@@ -27,7 +27,7 @@ export function addAriaReferencedId(el: Element, attr: string, id: string) {
2727
* Removes the given ID from the specified ARIA attribute on an element.
2828
* Used for attributes such as aria-labelledby, aria-owns, etc.
2929
*/
30-
export function removeAriaReferencedId(el: Element, attr: string, id: string) {
30+
export function removeAriaReferencedId(el: Element, attr: `aria-${string}`, id: string) {
3131
const ids = getAriaReferenceIds(el, attr);
3232
const filteredIds = ids.filter(val => val != id.trim());
3333

0 commit comments

Comments
 (0)