An aria-label attribute set in PHP is removed in JS when an element is infused. For example, with the following button created in PHP:
$button = new \OOUI\ButtonWidget( [ 'label' => 'X', 'id' => 'test-button', 'infusable' => true, ] ); $button->setAttributes( [ 'aria-label' => 'Close', ] );
And infused like this in JS:
console.log( $( '#test-button' ).attr( 'aria-label' ) ); // Correctly outputs 'Close'. var button = OO.ui.infuse( '#test-button' ); console.log( button.$element.attr( 'aria-label' ) ); // Incorrectly outputs 'undefined'.