11/**
2- * @license AngularJS v1.4.4
2+ * @license AngularJS v1.4.7
33 * (c) 2010-2015 Google, Inc. http://angularjs.org
44 * License: MIT
55 */
5757var ngAriaModule = angular . module ( 'ngAria' , [ 'ng' ] ) .
5858 provider ( '$aria' , $AriaProvider ) ;
5959
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+ } ;
6070/**
6171 * @ngdoc provider
6272 * @name $ariaProvider
@@ -118,10 +128,10 @@ function $AriaProvider() {
118128 config = angular . extend ( config , newConfig ) ;
119129 } ;
120130
121- function watchExpr ( attrName , ariaAttr , negate ) {
131+ function watchExpr ( attrName , ariaAttr , nodeBlackList , negate ) {
122132 return function ( scope , elem , attr ) {
123133 var ariaCamelName = attr . $normalize ( ariaAttr ) ;
124- if ( config [ ariaCamelName ] && ! attr [ ariaCamelName ] ) {
134+ if ( config [ ariaCamelName ] && ! isNodeOneOf ( elem , nodeBlackList ) && ! attr [ ariaCamelName ] ) {
125135 scope . $watch ( attr [ attrName ] , function ( boolVal ) {
126136 // ensure boolean value
127137 boolVal = negate ? ! boolVal : ! ! boolVal ;
@@ -130,7 +140,6 @@ function $AriaProvider() {
130140 }
131141 } ;
132142 }
133-
134143 /**
135144 * @ngdoc service
136145 * @name $aria
@@ -189,10 +198,10 @@ function $AriaProvider() {
189198
190199
191200ngAriaModule . directive ( 'ngShow' , [ '$aria' , function ( $aria ) {
192- return $aria . $$watchExpr ( 'ngShow' , 'aria-hidden' , true ) ;
201+ return $aria . $$watchExpr ( 'ngShow' , 'aria-hidden' , [ ] , true ) ;
193202} ] )
194203. directive ( 'ngHide' , [ '$aria' , function ( $aria ) {
195- return $aria . $$watchExpr ( 'ngHide' , 'aria-hidden' , false ) ;
204+ return $aria . $$watchExpr ( 'ngHide' , 'aria-hidden' , [ ] , false ) ;
196205} ] )
197206. directive ( 'ngModel' , [ '$aria' , function ( $aria ) {
198207
@@ -266,6 +275,9 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
266275 scope . $watch ( ngAriaWatchModelValue , shape === 'radio' ?
267276 getRadioReaction ( ) : ngAriaCheckboxReaction ) ;
268277 }
278+ if ( needsTabIndex ) {
279+ elem . attr ( 'tabindex' , 0 ) ;
280+ }
269281 break ;
270282 case 'range' :
271283 if ( shouldAttachRole ( shape , elem ) ) {
@@ -294,6 +306,9 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
294306 } ) ;
295307 }
296308 }
309+ if ( needsTabIndex ) {
310+ elem . attr ( 'tabindex' , 0 ) ;
311+ }
297312 break ;
298313 case 'multiline' :
299314 if ( shouldAttachAttr ( 'aria-multiline' , 'ariaMultiline' , elem ) ) {
@@ -302,10 +317,6 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
302317 break ;
303318 }
304319
305- if ( needsTabIndex ) {
306- elem . attr ( 'tabindex' , 0 ) ;
307- }
308-
309320 if ( ngModel . $validators . required && shouldAttachAttr ( 'aria-required' , 'ariaRequired' , elem ) ) {
310321 scope . $watch ( function ngAriaRequiredWatch ( ) {
311322 return ngModel . $error . required ;
@@ -327,7 +338,7 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
327338 } ;
328339} ] )
329340. directive ( 'ngDisabled' , [ '$aria' , function ( $aria ) {
330- return $aria . $$watchExpr ( 'ngDisabled' , 'aria-disabled' ) ;
341+ return $aria . $$watchExpr ( 'ngDisabled' , 'aria-disabled' , [ ] ) ;
331342} ] )
332343. directive ( 'ngMessages' , function ( ) {
333344 return {
@@ -347,43 +358,36 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
347358 var fn = $parse ( attr . ngClick , /* interceptorFn */ null , /* expensiveChecks */ true ) ;
348359 return function ( scope , elem , attr ) {
349360
350- var nodeBlackList = [ 'BUTTON' , 'A' , 'INPUT' , 'TEXTAREA' ] ;
361+ if ( ! isNodeOneOf ( elem , nodeBlackList ) ) {
351362
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' ) ;
355365 }
356- }
357366
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+ }
367370
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+ }
374377
375- function callback ( ) {
376- fn ( scope , { $event : event } ) ;
377- }
378- } ) ;
378+ function callback ( ) {
379+ fn ( scope , { $event : event } ) ;
380+ }
381+ } ) ;
382+ }
379383 }
380384 } ;
381385 }
382386 } ;
383387} ] )
384388. directive ( 'ngDblclick' , [ '$aria' , function ( $aria ) {
385389 return function ( scope , elem , attr ) {
386- if ( $aria . config ( 'tabindex' ) && ! elem . attr ( 'tabindex' ) ) {
390+ if ( $aria . config ( 'tabindex' ) && ! elem . attr ( 'tabindex' ) && ! isNodeOneOf ( elem , nodeBlackList ) ) {
387391 elem . attr ( 'tabindex' , 0 ) ;
388392 }
389393 } ;
0 commit comments