@@ -496,6 +496,16 @@ describe('$aria', function() {
496
496
expect ( clickFn ) . toHaveBeenCalled ( ) ;
497
497
} ) ;
498
498
499
+ it ( 'should a trigger click from the keyboard' , function ( ) {
500
+ scope . someAction = function ( ) { } ;
501
+ compileInput ( '<li ng-click="someAction()" tabindex="0"></li>' ) ;
502
+ clickFn = spyOn ( scope , 'someAction' ) ;
503
+
504
+ element . triggerHandler ( { type : 'keypress' , keyCode : 32 } ) ;
505
+
506
+ expect ( clickFn ) . toHaveBeenCalled ( ) ;
507
+ } ) ;
508
+
499
509
it ( 'should not override existing ng-keypress' , function ( ) {
500
510
scope . someOtherAction = function ( ) { } ;
501
511
var keypressFn = spyOn ( scope , 'someOtherAction' ) ;
@@ -526,6 +536,31 @@ describe('$aria', function() {
526
536
element . triggerHandler ( { type : 'keypress' , keyCode : 13 } ) ;
527
537
expect ( element . text ( ) ) . toBe ( 'keypress13' ) ;
528
538
} ) ;
539
+
540
+ it ( 'should not bind keypress to non-div elements' , function ( ) {
541
+ compileInput ( '<button ng-click="event = $event">{{event.type}}{{event.keyCode}}</button>' ) ;
542
+ expect ( element . text ( ) ) . toBe ( '' ) ;
543
+ element . triggerHandler ( { type : 'keypress' , keyCode : 13 } ) ;
544
+ expect ( element . text ( ) ) . toBe ( '' ) ;
545
+ } ) ;
546
+ } ) ;
547
+
548
+ describe ( 'actions for different configured elements' , function ( ) {
549
+ beforeEach ( configAriaProvider ( {
550
+ keypressEls : [ 'DIV' ]
551
+ } ) ) ;
552
+ beforeEach ( injectScopeAndCompiler ) ;
553
+
554
+ it ( 'should not a trigger click from the keyboard' , function ( ) {
555
+ scope . someAction = function ( ) { } ;
556
+ var clickFn = spyOn ( scope , 'someAction' ) ;
557
+
558
+ element = $compile ( '<li ng-click="someAction()" tabindex="0"></li>' ) ( scope ) ;
559
+
560
+ element . triggerHandler ( { type : 'keypress' , keyCode : 32 } ) ;
561
+
562
+ expect ( clickFn ) . not . toHaveBeenCalled ( ) ;
563
+ } ) ;
529
564
} ) ;
530
565
531
566
describe ( 'actions when bindKeypress set to false' , function ( ) {
@@ -538,7 +573,7 @@ describe('$aria', function() {
538
573
scope . someAction = function ( ) { } ;
539
574
var clickFn = spyOn ( scope , 'someAction' ) ;
540
575
541
- element = $compile ( '<div ng-click="someAction()" tabindex="0">> </div>' ) ( scope ) ;
576
+ element = $compile ( '<div ng-click="someAction()" tabindex="0"></div>' ) ( scope ) ;
542
577
543
578
element . triggerHandler ( { type : 'keypress' , keyCode : 32 } ) ;
544
579
0 commit comments