@@ -89,7 +89,9 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $mdAria, $interpolate,
8989 }
9090 labelEl . append ( '<span class="md-select-icon" aria-hidden="true"></span>' ) ;
9191 labelEl . addClass ( 'md-select-label' ) ;
92- labelEl . attr ( 'id' , 'select_label_' + $mdUtil . nextUid ( ) ) ;
92+ if ( ! labelEl [ 0 ] . hasAttribute ( 'id' ) ) {
93+ labelEl . attr ( 'id' , 'select_label_' + $mdUtil . nextUid ( ) ) ;
94+ }
9395
9496 // There's got to be an md-content inside. If there's not one, let's add it.
9597 if ( ! element . find ( 'md-content' ) . length ) {
@@ -233,22 +235,25 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $mdAria, $interpolate,
233235 element . off ( 'click' , openSelect ) ;
234236 element . off ( 'keydown' , handleKeypress ) ;
235237 } else {
236- element . attr ( { 'tabindex' : attr . tabindex , 'aria-disabled' :'false' } ) ;
238+ element . attr ( { 'tabindex' : attr . tabindex , 'aria-disabled' : 'false' } ) ;
237239 element . on ( 'click' , openSelect ) ;
238240 element . on ( 'keydown' , handleKeypress ) ;
239241 }
240242 } ) ;
241243 if ( ! attr . disabled && ! attr . ngDisabled ) {
242- element . attr ( { 'tabindex' : attr . tabindex , 'aria-disabled' :'false' } ) ;
244+ element . attr ( { 'tabindex' : attr . tabindex , 'aria-disabled' : 'false' } ) ;
243245 element . on ( 'click' , openSelect ) ;
244246 element . on ( 'keydown' , handleKeypress ) ;
245247 }
246248
247- element . attr ( {
248- 'role' : 'combobox' ,
249- 'id' : 'select_' + $mdUtil . nextUid ( ) ,
249+ var ariaAttrs = {
250+ role : 'combobox' ,
250251 'aria-expanded' : 'false'
251- } ) ;
252+ } ;
253+ if ( ! element [ 0 ] . hasAttribute ( 'id' ) ) {
254+ ariaAttrs . id = 'select_' + $mdUtil . nextUid ( ) ;
255+ }
256+ element . attr ( ariaAttrs ) ;
252257
253258 scope . $on ( '$destroy' , function ( ) {
254259 if ( isOpen ) {
@@ -617,11 +622,15 @@ function OptionDirective($mdInkRipple, $mdUtil) {
617622 } ) ;
618623
619624 function configureAria ( ) {
620- element . attr ( {
625+ var ariaAttrs = {
621626 'role' : 'option' ,
622- 'aria-selected' : 'false' ,
623- 'id' : 'select_option_' + $mdUtil . nextUid ( )
624- } ) ;
627+ 'aria-selected' : 'false'
628+ } ;
629+
630+ if ( ! element [ 0 ] . hasAttribute ( 'id' ) ) {
631+ ariaAttrs . id = 'select_option_' + $mdUtil . nextUid ( ) ;
632+ }
633+ element . attr ( ariaAttrs ) ;
625634 }
626635 }
627636
0 commit comments