@@ -536,7 +536,7 @@ function MdDialogDirective($$rAF, $mdTheming, $mdDialog) {
536
536
* `three` into the controller, with the value 3. If `bindToController` is true, they will be
537
537
* copied to the controller instead.
538
538
* - `bindToController` - `bool`: bind the locals to the controller, instead of passing them in.
539
- * - `resolve` - `{function=}`: Similar to locals, except it takes as values functions that return promises, and the
539
+ * - `resolve` - `{function=}`: Similar to locals, except it takes as values functions that return promises, and the
540
540
* dialog will not open until all of the promises resolve.
541
541
* - `controllerAs` - `{string=}`: An alias to assign the controller to on the scope.
542
542
* - `parent` - `{element=}`: The element to append the dialog to. Defaults to appending
@@ -1145,35 +1145,46 @@ function MdDialogProvider($$interimElementProvider) {
1145
1145
// get raw DOM node
1146
1146
walkDOM ( element [ 0 ] ) ;
1147
1147
1148
- options . unlockScreenReader = function ( ) {
1148
+ options . unlockScreenReader = function ( ) {
1149
1149
isHidden = false ;
1150
1150
walkDOM ( element [ 0 ] ) ;
1151
1151
1152
1152
options . unlockScreenReader = null ;
1153
1153
} ;
1154
1154
1155
1155
/**
1156
- * Walk DOM to apply or remove aria-hidden on sibling nodes
1157
- * and parent sibling nodes
1158
- *
1156
+ * Get all of an element's parent elements up the DOM tree
1157
+ * @return {Array } The parent elements
1159
1158
*/
1160
- function walkDOM ( element ) {
1159
+ function getParents ( element ) {
1160
+ var parents = [ ] ;
1161
1161
while ( element . parentNode ) {
1162
1162
if ( element === document . body ) {
1163
- return ;
1163
+ return parents ;
1164
1164
}
1165
1165
var children = element . parentNode . children ;
1166
1166
for ( var i = 0 ; i < children . length ; i ++ ) {
1167
1167
// skip over child if it is an ascendant of the dialog
1168
- // or a script or style tag
1168
+ // a script or style tag, or a live region.
1169
1169
if ( element !== children [ i ] &&
1170
- ! isNodeOneOf ( children [ i ] , [ 'SCRIPT' , 'STYLE' ] ) &&
1171
- ! children [ i ] . hasAttribute ( 'aria-live' ) ) {
1172
- children [ i ] . setAttribute ( 'aria-hidden' , isHidden ) ;
1170
+ ! isNodeOneOf ( children [ i ] , [ 'SCRIPT' , 'STYLE' ] ) &&
1171
+ ! children [ i ] . hasAttribute ( 'aria-live' ) ) {
1172
+ parents . push ( children [ i ] ) ;
1173
1173
}
1174
1174
}
1175
+ element = element . parentNode ;
1176
+ }
1177
+ return parents ;
1178
+ }
1175
1179
1176
- walkDOM ( element = element . parentNode ) ;
1180
+ /**
1181
+ * Walk DOM to apply or remove aria-hidden on sibling nodes
1182
+ * and parent sibling nodes
1183
+ */
1184
+ function walkDOM ( element ) {
1185
+ var elements = getParents ( element ) ;
1186
+ for ( var i = 0 ; i < elements . length ; i ++ ) {
1187
+ elements [ i ] . setAttribute ( 'aria-hidden' , isHidden ) ;
1177
1188
}
1178
1189
}
1179
1190
}
0 commit comments