1
1
/**
2
- * @license AngularJS v1.4.4
2
+ * @license AngularJS v1.4.7
3
3
* (c) 2010-2015 Google, Inc. http://angularjs.org
4
4
* License: MIT
5
5
*/
57
57
var ngAriaModule = angular . module ( 'ngAria' , [ 'ng' ] ) .
58
58
provider ( '$aria' , $AriaProvider ) ;
59
59
60
+ /**
61
+ * Internal Utilities
62
+ */
63
+ var nodeBlackList = [ 'BUTTON' , 'A' , 'INPUT' , 'TEXTAREA' , 'SELECT' , 'DETAILS' , 'SUMMARY' ] ;
64
+
65
+ var isNodeOneOf = function ( elem , nodeTypeArray ) {
66
+ if ( nodeTypeArray . indexOf ( elem [ 0 ] . nodeName ) !== - 1 ) {
67
+ return true ;
68
+ }
69
+ } ;
60
70
/**
61
71
* @ngdoc provider
62
72
* @name $ariaProvider
@@ -118,10 +128,10 @@ function $AriaProvider() {
118
128
config = angular . extend ( config , newConfig ) ;
119
129
} ;
120
130
121
- function watchExpr ( attrName , ariaAttr , negate ) {
131
+ function watchExpr ( attrName , ariaAttr , nodeBlackList , negate ) {
122
132
return function ( scope , elem , attr ) {
123
133
var ariaCamelName = attr . $normalize ( ariaAttr ) ;
124
- if ( config [ ariaCamelName ] && ! attr [ ariaCamelName ] ) {
134
+ if ( config [ ariaCamelName ] && ! isNodeOneOf ( elem , nodeBlackList ) && ! attr [ ariaCamelName ] ) {
125
135
scope . $watch ( attr [ attrName ] , function ( boolVal ) {
126
136
// ensure boolean value
127
137
boolVal = negate ? ! boolVal : ! ! boolVal ;
@@ -130,7 +140,6 @@ function $AriaProvider() {
130
140
}
131
141
} ;
132
142
}
133
-
134
143
/**
135
144
* @ngdoc service
136
145
* @name $aria
@@ -189,10 +198,10 @@ function $AriaProvider() {
189
198
190
199
191
200
ngAriaModule . directive ( 'ngShow' , [ '$aria' , function ( $aria ) {
192
- return $aria . $$watchExpr ( 'ngShow' , 'aria-hidden' , true ) ;
201
+ return $aria . $$watchExpr ( 'ngShow' , 'aria-hidden' , [ ] , true ) ;
193
202
} ] )
194
203
. directive ( 'ngHide' , [ '$aria' , function ( $aria ) {
195
- return $aria . $$watchExpr ( 'ngHide' , 'aria-hidden' , false ) ;
204
+ return $aria . $$watchExpr ( 'ngHide' , 'aria-hidden' , [ ] , false ) ;
196
205
} ] )
197
206
. directive ( 'ngModel' , [ '$aria' , function ( $aria ) {
198
207
@@ -266,6 +275,9 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
266
275
scope . $watch ( ngAriaWatchModelValue , shape === 'radio' ?
267
276
getRadioReaction ( ) : ngAriaCheckboxReaction ) ;
268
277
}
278
+ if ( needsTabIndex ) {
279
+ elem . attr ( 'tabindex' , 0 ) ;
280
+ }
269
281
break ;
270
282
case 'range' :
271
283
if ( shouldAttachRole ( shape , elem ) ) {
@@ -294,6 +306,9 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
294
306
} ) ;
295
307
}
296
308
}
309
+ if ( needsTabIndex ) {
310
+ elem . attr ( 'tabindex' , 0 ) ;
311
+ }
297
312
break ;
298
313
case 'multiline' :
299
314
if ( shouldAttachAttr ( 'aria-multiline' , 'ariaMultiline' , elem ) ) {
@@ -302,10 +317,6 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
302
317
break ;
303
318
}
304
319
305
- if ( needsTabIndex ) {
306
- elem . attr ( 'tabindex' , 0 ) ;
307
- }
308
-
309
320
if ( ngModel . $validators . required && shouldAttachAttr ( 'aria-required' , 'ariaRequired' , elem ) ) {
310
321
scope . $watch ( function ngAriaRequiredWatch ( ) {
311
322
return ngModel . $error . required ;
@@ -327,7 +338,7 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
327
338
} ;
328
339
} ] )
329
340
. directive ( 'ngDisabled' , [ '$aria' , function ( $aria ) {
330
- return $aria . $$watchExpr ( 'ngDisabled' , 'aria-disabled' ) ;
341
+ return $aria . $$watchExpr ( 'ngDisabled' , 'aria-disabled' , [ ] ) ;
331
342
} ] )
332
343
. directive ( 'ngMessages' , function ( ) {
333
344
return {
@@ -347,43 +358,36 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
347
358
var fn = $parse ( attr . ngClick , /* interceptorFn */ null , /* expensiveChecks */ true ) ;
348
359
return function ( scope , elem , attr ) {
349
360
350
- var nodeBlackList = [ 'BUTTON' , 'A' , 'INPUT' , 'TEXTAREA' ] ;
361
+ if ( ! isNodeOneOf ( elem , nodeBlackList ) ) {
351
362
352
- function isNodeOneOf ( elem , nodeTypeArray ) {
353
- if ( nodeTypeArray . indexOf ( elem [ 0 ] . nodeName ) !== - 1 ) {
354
- return true ;
363
+ if ( $aria . config ( 'bindRoleForClick' ) && ! elem . attr ( 'role' ) ) {
364
+ elem . attr ( 'role' , 'button' ) ;
355
365
}
356
- }
357
366
358
- if ( $aria . config ( 'bindRoleForClick' )
359
- && ! elem . attr ( 'role' )
360
- && ! isNodeOneOf ( elem , nodeBlackList ) ) {
361
- elem . attr ( 'role' , 'button' ) ;
362
- }
363
-
364
- if ( $aria . config ( 'tabindex' ) && ! elem . attr ( 'tabindex' ) ) {
365
- elem . attr ( 'tabindex' , 0 ) ;
366
- }
367
+ if ( $aria . config ( 'tabindex' ) && ! elem . attr ( 'tabindex' ) ) {
368
+ elem . attr ( 'tabindex' , 0 ) ;
369
+ }
367
370
368
- if ( $aria . config ( 'bindKeypress' ) && ! attr . ngKeypress && ! isNodeOneOf ( elem , nodeBlackList ) ) {
369
- elem . on ( 'keypress' , function ( event ) {
370
- var keyCode = event . which || event . keyCode ;
371
- if ( keyCode === 32 || keyCode === 13 ) {
372
- scope . $apply ( callback ) ;
373
- }
371
+ if ( $aria . config ( 'bindKeypress' ) && ! attr . ngKeypress ) {
372
+ elem . on ( 'keypress' , function ( event ) {
373
+ var keyCode = event . which || event . keyCode ;
374
+ if ( keyCode === 32 || keyCode === 13 ) {
375
+ scope . $apply ( callback ) ;
376
+ }
374
377
375
- function callback ( ) {
376
- fn ( scope , { $event : event } ) ;
377
- }
378
- } ) ;
378
+ function callback ( ) {
379
+ fn ( scope , { $event : event } ) ;
380
+ }
381
+ } ) ;
382
+ }
379
383
}
380
384
} ;
381
385
}
382
386
} ;
383
387
} ] )
384
388
. directive ( 'ngDblclick' , [ '$aria' , function ( $aria ) {
385
389
return function ( scope , elem , attr ) {
386
- if ( $aria . config ( 'tabindex' ) && ! elem . attr ( 'tabindex' ) ) {
390
+ if ( $aria . config ( 'tabindex' ) && ! elem . attr ( 'tabindex' ) && ! isNodeOneOf ( elem , nodeBlackList ) ) {
387
391
elem . attr ( 'tabindex' , 0 ) ;
388
392
}
389
393
} ;
0 commit comments