license /** IDs are deliminated by an empty space, as per the spec. */ const ID_DELIMINATOR = ' ' ; /**
 * Adds the given ID to the specified ARIA attribute on an element.
 * Used for attributes such as aria-labelledby, aria-owns, etc.
 */ export function addAriaReferencedId ( el , attr , id ) { const ids = getAriaReferenceIds ( el , attr ) ; if ( ids . some ( existingId => existingId . trim ( ) == id . trim ( ) ) ) { return ; } ids . push ( id . trim ( ) ) ; el . setAttribute ( attr , ids . join ( ID_DELIMINATOR ) ) ; } /**
 * Removes the given ID from the specified ARIA attribute on an element.
 * Used for attributes such as aria-labelledby, aria-owns, etc.
 */ export function removeAriaReferencedId ( el , attr , id ) { const ids = getAriaReferenceIds ( el , attr ) ; const filteredIds = ids . filter ( val => val != id . trim ( ) ) ; el . setAttribute ( attr , filteredIds . join ( ID_DELIMINATOR ) ) ; } /**
 * Gets the list of IDs referenced by the given ARIA attribute on an element.
 * Used for attributes such as aria-labelledby, aria-owns, etc.
 */ export function getAriaReferenceIds ( el , attr ) { return ( el . getAttribute ( attr ) || '' ) . match ( /\S+/g ) || [ ] ; }