Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9133e14

Browse files
author
Marcy Sutton
committedFeb 7, 2015
feat(ngAria): Adds button role to ng-click
Closes #9254
1 parent 93253df commit 9133e14

File tree

3 files changed

+98
-75
lines changed

3 files changed

+98
-75
lines changed
 

‎docs/content/guide/accessibility.ngdoc

+8-5
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,14 @@ The default CSS for `ngHide`, the inverse method to `ngShow`, makes ngAria redun
213213
If `ng-click` or `ng-dblclick` is encountered, ngAria will add `tabindex="0"` if it isn't there
214214
already.
215215

216-
For `ng-click`, keypress will also be bound to `div` and `li` elements. You can turn this
217-
functionality on or off with the `bindKeypress` configuration option.
218-
219-
For `ng-dblclick`, you must manually add `ng-keypress` to non-interactive elements such as `div`
220-
or `taco-button` to enable keyboard access.
216+
To fix widespread accessibility problems with `ng-click` on div elements, ngAria will dynamically
217+
bind keypress by default as long as the element isn't an anchor, button, input or textarea.
218+
You can turn this functionality on or off with the `bindKeypress` configuration option. ngAria
219+
will also add the `button` role to those elements to communicate better to users of
220+
assistive technologies.
221+
222+
For `ng-dblclick`, you must still manually add `ng-keypress` and role to non-interactive elements such
223+
as `div` or `taco-button` to enable keyboard access.
221224

222225
<h3>Example</h3>
223226
```html

‎src/ngAria/aria.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
*
2323
* | Directive | Supported Attributes |
2424
* |---------------------------------------------|----------------------------------------------------------------------------------------|
25-
* | {@link ng.directive:ngModel ngModel} | aria-checked, aria-valuemin, aria-valuemax, aria-valuenow, aria-invalid, aria-required |
2625
* | {@link ng.directive:ngDisabled ngDisabled} | aria-disabled |
2726
* | {@link ng.directive:ngShow ngShow} | aria-hidden |
2827
* | {@link ng.directive:ngHide ngHide} | aria-hidden |
29-
* | {@link ng.directive:ngClick ngClick} | tabindex, keypress event |
3028
* | {@link ng.directive:ngDblclick ngDblclick} | tabindex |
3129
* | {@link module:ngMessages ngMessages} | aria-live |
30+
* | {@link ng.directive:ngModel ngModel} | aria-checked, aria-valuemin, aria-valuemax, aria-valuenow, aria-invalid, aria-required, input roles |
31+
* | {@link ng.directive:ngClick ngClick} | tabindex, keypress event, button role |
3232
*
3333
* Find out more information about each directive by reading the
3434
* {@link guide/accessibility ngAria Developer Guide}.
@@ -315,17 +315,22 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
315315
var fn = $parse(attr.ngClick, /* interceptorFn */ null, /* expensiveChecks */ true);
316316
return function(scope, elem, attr) {
317317

318+
var nodeBlackList = ['BUTTON', 'A', 'INPUT', 'TEXTAREA'];
319+
318320
function isNodeOneOf(elem, nodeTypeArray) {
319321
if (nodeTypeArray.indexOf(elem[0].nodeName) !== -1) {
320322
return true;
321323
}
322324
}
325+
if (!elem.attr('role') && !isNodeOneOf(elem, nodeBlackList)) {
326+
elem.attr('role', 'button');
327+
}
323328

324329
if ($aria.config('tabindex') && !elem.attr('tabindex')) {
325330
elem.attr('tabindex', 0);
326331
}
327332

328-
if ($aria.config('bindKeypress') && !attr.ngKeypress && isNodeOneOf(elem, ['DIV', 'LI'])) {
333+
if ($aria.config('bindKeypress') && !attr.ngKeypress && !isNodeOneOf(elem, nodeBlackList)) {
329334
elem.on('keypress', function(event) {
330335
if (event.keyCode === 32 || event.keyCode === 13) {
331336
scope.$apply(callback);

‎test/ngAria/ariaSpec.js

+82-67
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('$aria', function() {
55

66
beforeEach(module('ngAria'));
77

8-
afterEach(function(){
8+
afterEach(function() {
99
dealoc(element);
1010
});
1111

@@ -16,7 +16,7 @@ describe('$aria', function() {
1616
});
1717
}
1818

19-
function compileInput(inputHtml) {
19+
function compileElement(inputHtml) {
2020
element = $compile(inputHtml)(scope);
2121
scope.$digest();
2222
}
@@ -25,7 +25,7 @@ describe('$aria', function() {
2525
beforeEach(injectScopeAndCompiler);
2626

2727
it('should attach aria-hidden to ng-show', function() {
28-
compileInput('<div ng-show="val"></div>');
28+
compileElement('<div ng-show="val"></div>');
2929
scope.$apply('val = false');
3030
expect(element.attr('aria-hidden')).toBe('true');
3131

@@ -34,7 +34,7 @@ describe('$aria', function() {
3434
});
3535

3636
it('should attach aria-hidden to ng-hide', function() {
37-
compileInput('<div ng-hide="val"></div>');
37+
compileElement('<div ng-hide="val"></div>');
3838
scope.$apply('val = false');
3939
expect(element.attr('aria-hidden')).toBe('false');
4040

@@ -43,15 +43,15 @@ describe('$aria', function() {
4343
});
4444

4545
it('should not change aria-hidden if it is already present on ng-show', function() {
46-
compileInput('<div ng-show="val" aria-hidden="userSetValue"></div>');
46+
compileElement('<div ng-show="val" aria-hidden="userSetValue"></div>');
4747
expect(element.attr('aria-hidden')).toBe('userSetValue');
4848

4949
scope.$apply('val = true');
5050
expect(element.attr('aria-hidden')).toBe('userSetValue');
5151
});
5252

5353
it('should not change aria-hidden if it is already present on ng-hide', function() {
54-
compileInput('<div ng-hide="val" aria-hidden="userSetValue"></div>');
54+
compileElement('<div ng-hide="val" aria-hidden="userSetValue"></div>');
5555
expect(element.attr('aria-hidden')).toBe('userSetValue');
5656

5757
scope.$apply('val = true');
@@ -68,10 +68,10 @@ describe('$aria', function() {
6868

6969
it('should not attach aria-hidden', function() {
7070
scope.$apply('val = false');
71-
compileInput('<div ng-show="val"></div>');
71+
compileElement('<div ng-show="val"></div>');
7272
expect(element.attr('aria-hidden')).toBeUndefined();
7373

74-
compileInput('<div ng-hide="val"></div>');
74+
compileElement('<div ng-hide="val"></div>');
7575
expect(element.attr('aria-hidden')).toBeUndefined();
7676
});
7777
});
@@ -80,7 +80,7 @@ describe('$aria', function() {
8080
beforeEach(injectScopeAndCompiler);
8181

8282
it('should attach itself to input type="checkbox"', function() {
83-
compileInput('<input type="checkbox" ng-model="val">');
83+
compileElement('<input type="checkbox" ng-model="val">');
8484

8585
scope.$apply('val = true');
8686
expect(element.attr('aria-checked')).toBe('true');
@@ -104,25 +104,25 @@ describe('$aria', function() {
104104

105105
it('should attach itself to role="radio"', function() {
106106
scope.$apply("val = 'one'");
107-
compileInput('<div role="radio" ng-model="val" value="{{val}}"></div>');
107+
compileElement('<div role="radio" ng-model="val" value="{{val}}"></div>');
108108
expect(element.attr('aria-checked')).toBe('true');
109109
});
110110

111111
it('should attach itself to role="checkbox"', function() {
112112
scope.val = true;
113-
compileInput('<div role="checkbox" ng-model="val"></div>');
113+
compileElement('<div role="checkbox" ng-model="val"></div>');
114114
expect(element.attr('aria-checked')).toBe('true');
115115
});
116116

117117
it('should attach itself to role="menuitemradio"', function() {
118118
scope.val = 'one';
119-
compileInput('<div role="menuitemradio" ng-model="val" value="{{val}}"></div>');
119+
compileElement('<div role="menuitemradio" ng-model="val" value="{{val}}"></div>');
120120
expect(element.attr('aria-checked')).toBe('true');
121121
});
122122

123123
it('should attach itself to role="menuitemcheckbox"', function() {
124124
scope.val = true;
125-
compileInput('<div role="menuitemcheckbox" ng-model="val"></div>');
125+
compileElement('<div role="menuitemcheckbox" ng-model="val"></div>');
126126
expect(element.attr('aria-checked')).toBe('true');
127127
});
128128

@@ -143,34 +143,49 @@ describe('$aria', function() {
143143
describe('roles for custom inputs', function() {
144144
beforeEach(injectScopeAndCompiler);
145145

146+
it('should add missing role="button" to custom input', function() {
147+
compileElement('<div ng-click="someFunction()"></div>');
148+
expect(element.attr('role')).toBe('button');
149+
});
150+
151+
it('should not add role="button" to anchor', function() {
152+
compileElement('<a ng-click="someFunction()"></a>');
153+
expect(element.attr('role')).not.toBe('button');
154+
});
155+
146156
it('should add missing role="checkbox" to custom input', function() {
147157
scope.$apply('val = true');
148-
compileInput('<div type="checkbox" ng-model="val"></div>');
158+
compileElement('<div type="checkbox" ng-model="val"></div>');
149159
expect(element.attr('role')).toBe('checkbox');
150160
});
161+
151162
it('should not add a role to a native checkbox', function() {
152163
scope.$apply('val = true');
153-
compileInput('<input type="checkbox" ng-model="val"></div>');
164+
compileElement('<input type="checkbox" ng-model="val"></div>');
154165
expect(element.attr('role')).toBe(undefined);
155166
});
167+
156168
it('should add missing role="radio" to custom input', function() {
157169
scope.$apply('val = true');
158-
compileInput('<div type="radio" ng-model="val"></div>');
170+
compileElement('<div type="radio" ng-model="val"></div>');
159171
expect(element.attr('role')).toBe('radio');
160172
});
173+
161174
it('should not add a role to a native radio button', function() {
162175
scope.$apply('val = true');
163-
compileInput('<input type="radio" ng-model="val"></div>');
176+
compileElement('<input type="radio" ng-model="val"></div>');
164177
expect(element.attr('role')).toBe(undefined);
165178
});
179+
166180
it('should add missing role="slider" to custom input', function() {
167181
scope.$apply('val = true');
168-
compileInput('<div type="range" ng-model="val"></div>');
182+
compileElement('<div type="range" ng-model="val"></div>');
169183
expect(element.attr('role')).toBe('slider');
170184
});
185+
171186
it('should not add a role to a native range input', function() {
172187
scope.$apply('val = true');
173-
compileInput('<input type="range" ng-model="val"></div>');
188+
compileElement('<input type="range" ng-model="val"></div>');
174189
expect(element.attr('role')).toBe(undefined);
175190
});
176191
});
@@ -182,16 +197,16 @@ describe('$aria', function() {
182197
beforeEach(injectScopeAndCompiler);
183198

184199
it('should not attach aria-checked', function() {
185-
compileInput("<div role='radio' ng-model='val' value='{{val}}'></div>");
200+
compileElement("<div role='radio' ng-model='val' value='{{val}}'></div>");
186201
expect(element.attr('aria-checked')).toBeUndefined();
187202

188-
compileInput("<div role='menuitemradio' ng-model='val' value='{{val}}'></div>");
203+
compileElement("<div role='menuitemradio' ng-model='val' value='{{val}}'></div>");
189204
expect(element.attr('aria-checked')).toBeUndefined();
190205

191-
compileInput("<div role='checkbox' checked='checked'></div>");
206+
compileElement("<div role='checkbox' checked='checked'></div>");
192207
expect(element.attr('aria-checked')).toBeUndefined();
193208

194-
compileInput("<div role='menuitemcheckbox' checked='checked'></div>");
209+
compileElement("<div role='menuitemcheckbox' checked='checked'></div>");
195210
expect(element.attr('aria-checked')).toBeUndefined();
196211
});
197212
});
@@ -201,7 +216,7 @@ describe('$aria', function() {
201216

202217
it('should attach itself to input elements', function() {
203218
scope.$apply('val = false');
204-
compileInput("<input ng-disabled='val'>");
219+
compileElement("<input ng-disabled='val'>");
205220
expect(element.attr('aria-disabled')).toBe('false');
206221

207222
scope.$apply('val = true');
@@ -210,7 +225,7 @@ describe('$aria', function() {
210225

211226
it('should attach itself to textarea elements', function() {
212227
scope.$apply('val = false');
213-
compileInput('<textarea ng-disabled="val"></textarea>');
228+
compileElement('<textarea ng-disabled="val"></textarea>');
214229
expect(element.attr('aria-disabled')).toBe('false');
215230

216231
scope.$apply('val = true');
@@ -219,7 +234,7 @@ describe('$aria', function() {
219234

220235
it('should attach itself to button elements', function() {
221236
scope.$apply('val = false');
222-
compileInput('<button ng-disabled="val"></button>');
237+
compileElement('<button ng-disabled="val"></button>');
223238
expect(element.attr('aria-disabled')).toBe('false');
224239

225240
scope.$apply('val = true');
@@ -228,7 +243,7 @@ describe('$aria', function() {
228243

229244
it('should attach itself to select elements', function() {
230245
scope.$apply('val = false');
231-
compileInput('<select ng-disabled="val"></select>');
246+
compileElement('<select ng-disabled="val"></select>');
232247
expect(element.attr('aria-disabled')).toBe('false');
233248

234249
scope.$apply('val = true');
@@ -271,7 +286,7 @@ describe('$aria', function() {
271286
beforeEach(injectScopeAndCompiler);
272287

273288
it('should attach aria-invalid to input', function() {
274-
compileInput('<input ng-model="txtInput" ng-minlength="10">');
289+
compileElement('<input ng-model="txtInput" ng-minlength="10">');
275290
scope.$apply("txtInput='LTten'");
276291
expect(element.attr('aria-invalid')).toBe('true');
277292

@@ -280,7 +295,7 @@ describe('$aria', function() {
280295
});
281296

282297
it('should not attach itself if aria-invalid is already present', function() {
283-
compileInput('<input ng-model="txtInput" ng-minlength="10" aria-invalid="userSetValue">');
298+
compileElement('<input ng-model="txtInput" ng-minlength="10" aria-invalid="userSetValue">');
284299
scope.$apply("txtInput='LTten'");
285300
expect(element.attr('aria-invalid')).toBe('userSetValue');
286301
});
@@ -294,7 +309,7 @@ describe('$aria', function() {
294309

295310
it('should not attach aria-invalid if the option is disabled', function() {
296311
scope.$apply("txtInput='LTten'");
297-
compileInput('<input ng-model="txtInput" ng-minlength="10">');
312+
compileElement('<input ng-model="txtInput" ng-minlength="10">');
298313
expect(element.attr('aria-invalid')).toBeUndefined();
299314
});
300315
});
@@ -303,48 +318,48 @@ describe('$aria', function() {
303318
beforeEach(injectScopeAndCompiler);
304319

305320
it('should attach aria-required to input', function() {
306-
compileInput('<input ng-model="val" required>');
321+
compileElement('<input ng-model="val" required>');
307322
expect(element.attr('aria-required')).toBe('true');
308323

309324
scope.$apply("val='input is valid now'");
310325
expect(element.attr('aria-required')).toBe('false');
311326
});
312327

313328
it('should attach aria-required to textarea', function() {
314-
compileInput('<textarea ng-model="val" required></textarea>');
329+
compileElement('<textarea ng-model="val" required></textarea>');
315330
expect(element.attr('aria-required')).toBe('true');
316331

317332
scope.$apply("val='input is valid now'");
318333
expect(element.attr('aria-required')).toBe('false');
319334
});
320335

321336
it('should attach aria-required to select', function() {
322-
compileInput('<select ng-model="val" required></select>');
337+
compileElement('<select ng-model="val" required></select>');
323338
expect(element.attr('aria-required')).toBe('true');
324339

325340
scope.$apply("val='input is valid now'");
326341
expect(element.attr('aria-required')).toBe('false');
327342
});
328343

329344
it('should attach aria-required to ngRequired', function() {
330-
compileInput('<input ng-model="val" ng-required="true">');
345+
compileElement('<input ng-model="val" ng-required="true">');
331346
expect(element.attr('aria-required')).toBe('true');
332347

333348
scope.$apply("val='input is valid now'");
334349
expect(element.attr('aria-required')).toBe('false');
335350
});
336351

337352
it('should not attach itself if aria-required is already present', function() {
338-
compileInput("<input ng-model='val' required aria-required='userSetValue'>");
353+
compileElement("<input ng-model='val' required aria-required='userSetValue'>");
339354
expect(element.attr('aria-required')).toBe('userSetValue');
340355

341-
compileInput("<textarea ng-model='val' required aria-required='userSetValue'></textarea>");
356+
compileElement("<textarea ng-model='val' required aria-required='userSetValue'></textarea>");
342357
expect(element.attr('aria-required')).toBe('userSetValue');
343358

344-
compileInput("<select ng-model='val' required aria-required='userSetValue'></select>");
359+
compileElement("<select ng-model='val' required aria-required='userSetValue'></select>");
345360
expect(element.attr('aria-required')).toBe('userSetValue');
346361

347-
compileInput("<input ng-model='val' ng-required='true' aria-required='userSetValue'>");
362+
compileElement("<input ng-model='val' ng-required='true' aria-required='userSetValue'>");
348363
expect(element.attr('aria-required')).toBe('userSetValue');
349364
});
350365
});
@@ -356,13 +371,13 @@ describe('$aria', function() {
356371
beforeEach(injectScopeAndCompiler);
357372

358373
it('should not add the aria-required attribute', function() {
359-
compileInput("<input ng-model='val' required>");
374+
compileElement("<input ng-model='val' required>");
360375
expect(element.attr('aria-required')).toBeUndefined();
361376

362-
compileInput("<textarea ng-model='val' required></textarea>");
377+
compileElement("<textarea ng-model='val' required></textarea>");
363378
expect(element.attr('aria-required')).toBeUndefined();
364379

365-
compileInput("<select ng-model='val' required></select>");
380+
compileElement("<select ng-model='val' required></select>");
366381
expect(element.attr('aria-required')).toBeUndefined();
367382
});
368383
});
@@ -371,20 +386,20 @@ describe('$aria', function() {
371386
beforeEach(injectScopeAndCompiler);
372387

373388
it('should attach itself to textarea', function() {
374-
compileInput('<textarea ng-model="val"></textarea>');
389+
compileElement('<textarea ng-model="val"></textarea>');
375390
expect(element.attr('aria-multiline')).toBe('true');
376391
});
377392

378393
it('should attach itself role="textbox"', function() {
379-
compileInput('<div role="textbox" ng-model="val"></div>');
394+
compileElement('<div role="textbox" ng-model="val"></div>');
380395
expect(element.attr('aria-multiline')).toBe('true');
381396
});
382397

383398
it('should not attach itself if aria-multiline is already present', function() {
384-
compileInput('<textarea aria-multiline="userSetValue"></textarea>');
399+
compileElement('<textarea aria-multiline="userSetValue"></textarea>');
385400
expect(element.attr('aria-multiline')).toBe('userSetValue');
386401

387-
compileInput('<div role="textbox" aria-multiline="userSetValue"></div>');
402+
compileElement('<div role="textbox" aria-multiline="userSetValue"></div>');
388403
expect(element.attr('aria-multiline')).toBe('userSetValue');
389404
});
390405
});
@@ -396,12 +411,12 @@ describe('$aria', function() {
396411
beforeEach(injectScopeAndCompiler);
397412

398413
it('should not attach itself to textarea', function() {
399-
compileInput('<textarea></textarea>');
414+
compileElement('<textarea></textarea>');
400415
expect(element.attr('aria-multiline')).toBeUndefined();
401416
});
402417

403418
it('should not attach itself role="textbox"', function() {
404-
compileInput('<div role="textbox"></div>');
419+
compileElement('<div role="textbox"></div>');
405420
expect(element.attr('aria-multiline')).toBeUndefined();
406421
});
407422
});
@@ -459,12 +474,12 @@ describe('$aria', function() {
459474
it('should not attach itself', function() {
460475
scope.$apply('val = 50');
461476

462-
compileInput('<input type="range" ng-model="val" min="0" max="100">');
477+
compileElement('<input type="range" ng-model="val" min="0" max="100">');
463478
expect(element.attr('aria-valuenow')).toBeUndefined();
464479
expect(element.attr('aria-valuemin')).toBeUndefined();
465480
expect(element.attr('aria-valuemax')).toBeUndefined();
466481

467-
compileInput('<div role="progressbar" min="0" max="100" ng-model="val">');
482+
compileElement('<div role="progressbar" min="0" max="100" ng-model="val">');
468483
expect(element.attr('aria-valuenow')).toBeUndefined();
469484
expect(element.attr('aria-valuemin')).toBeUndefined();
470485
expect(element.attr('aria-valuemax')).toBeUndefined();
@@ -475,32 +490,32 @@ describe('$aria', function() {
475490
beforeEach(injectScopeAndCompiler);
476491

477492
it('should attach tabindex to role="checkbox", ng-click, and ng-dblclick', function() {
478-
compileInput('<div role="checkbox" ng-model="val"></div>');
493+
compileElement('<div role="checkbox" ng-model="val"></div>');
479494
expect(element.attr('tabindex')).toBe('0');
480495

481-
compileInput('<div ng-click="someAction()"></div>');
496+
compileElement('<div ng-click="someAction()"></div>');
482497
expect(element.attr('tabindex')).toBe('0');
483498

484-
compileInput('<div ng-dblclick="someAction()"></div>');
499+
compileElement('<div ng-dblclick="someAction()"></div>');
485500
expect(element.attr('tabindex')).toBe('0');
486501
});
487502

488503
it('should not attach tabindex if it is already on an element', function() {
489-
compileInput('<div role="button" tabindex="userSetValue"></div>');
504+
compileElement('<div role="button" tabindex="userSetValue"></div>');
490505
expect(element.attr('tabindex')).toBe('userSetValue');
491506

492-
compileInput('<div role="checkbox" tabindex="userSetValue"></div>');
507+
compileElement('<div role="checkbox" tabindex="userSetValue"></div>');
493508
expect(element.attr('tabindex')).toBe('userSetValue');
494509

495-
compileInput('<div ng-click="someAction()" tabindex="userSetValue"></div>');
510+
compileElement('<div ng-click="someAction()" tabindex="userSetValue"></div>');
496511
expect(element.attr('tabindex')).toBe('userSetValue');
497512

498-
compileInput('<div ng-dblclick="someAction()" tabindex="userSetValue"></div>');
513+
compileElement('<div ng-dblclick="someAction()" tabindex="userSetValue"></div>');
499514
expect(element.attr('tabindex')).toBe('userSetValue');
500515
});
501516

502517
it('should set proper tabindex values for radiogroup', function() {
503-
compileInput('<div role="radiogroup">' +
518+
compileElement('<div role="radiogroup">' +
504519
'<div role="radio" ng-model="val" value="one">1</div>' +
505520
'<div role="radio" ng-model="val" value="two">2</div>' +
506521
'</div>');
@@ -553,7 +568,7 @@ describe('$aria', function() {
553568

554569
scope.someAction = function() {};
555570
clickFn = spyOn(scope, 'someAction');
556-
compileInput('<div ng-click="someAction()" ng-keypress="someOtherAction()" tabindex="0"></div>');
571+
compileElement('<div ng-click="someAction()" ng-keypress="someOtherAction()" tabindex="0"></div>');
557572

558573
element.triggerHandler({type: 'keypress', keyCode: 32});
559574

@@ -562,7 +577,7 @@ describe('$aria', function() {
562577
});
563578

564579
it('should update bindings when keypress handled', function() {
565-
compileInput('<div ng-click="text = \'clicked!\'">{{text}}</div>');
580+
compileElement('<div ng-click="text = \'clicked!\'">{{text}}</div>');
566581
expect(element.text()).toBe('');
567582
spyOn(scope.$root, '$digest').andCallThrough();
568583
element.triggerHandler({ type: 'keypress', keyCode: 13 });
@@ -571,22 +586,22 @@ describe('$aria', function() {
571586
});
572587

573588
it('should pass $event to ng-click handler as local', function() {
574-
compileInput('<div ng-click="event = $event">{{event.type}}' +
575-
'{{event.keyCode}}</div>');
589+
compileElement('<div ng-click="event = $event">{{event.type}}' +
590+
'{{event.keyCode}}</div>');
576591
expect(element.text()).toBe('');
577592
element.triggerHandler({ type: 'keypress', keyCode: 13 });
578593
expect(element.text()).toBe('keypress13');
579594
});
580595

581596
it('should not bind keypress to elements not in the default config', function() {
582-
compileInput('<button ng-click="event = $event">{{event.type}}{{event.keyCode}}</button>');
597+
compileElement('<button ng-click="event = $event">{{event.type}}{{event.keyCode}}</button>');
583598
expect(element.text()).toBe('');
584599
element.triggerHandler({ type: 'keypress', keyCode: 13 });
585600
expect(element.text()).toBe('');
586601
});
587602
});
588603

589-
describe('actions when bindKeypress set to false', function() {
604+
describe('actions when bindKeypress is set to false', function() {
590605
beforeEach(configAriaProvider({
591606
bindKeypress: false
592607
}));
@@ -611,16 +626,16 @@ describe('$aria', function() {
611626
beforeEach(injectScopeAndCompiler);
612627

613628
it('should not add a tabindex attribute', function() {
614-
compileInput('<div role="button"></div>');
629+
compileElement('<div role="button"></div>');
615630
expect(element.attr('tabindex')).toBeUndefined();
616631

617-
compileInput('<div role="checkbox"></div>');
632+
compileElement('<div role="checkbox"></div>');
618633
expect(element.attr('tabindex')).toBeUndefined();
619634

620-
compileInput('<div ng-click="someAction()"></div>');
635+
compileElement('<div ng-click="someAction()"></div>');
621636
expect(element.attr('tabindex')).toBeUndefined();
622637

623-
compileInput('<div ng-dblclick="someAction()"></div>');
638+
compileElement('<div ng-dblclick="someAction()"></div>');
624639
expect(element.attr('tabindex')).toBeUndefined();
625640
});
626641
});

0 commit comments

Comments
 (0)
This repository has been archived.