Skip to content

Commit 0062278

Browse files
typeofwebnetman92
authored andcommitted
test(ngAria): test that aria-hidden/disabled are always "true" or "false"
Previously, when using ngAria with the ng-hide directive, and the value passed to ng-hide was not boolean, the aria-hidden attribute was set to this non-boolean value. Closes angular#11865 Closes angular#11998
1 parent dce4460 commit 0062278

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/ngAria/ariaSpec.js

+39
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,31 @@ describe('$aria', function() {
5757
scope.$apply('val = true');
5858
expect(element.attr('aria-hidden')).toBe('userSetValue');
5959
});
60+
61+
it('should always set aria-hidden to a boolean value', function() {
62+
compileElement('<div ng-hide="val"></div>');
63+
64+
scope.$apply('val = "test angular"');
65+
expect(element.attr('aria-hidden')).toBe('true');
66+
67+
scope.$apply('val = null');
68+
expect(element.attr('aria-hidden')).toBe('false');
69+
70+
scope.$apply('val = {}');
71+
expect(element.attr('aria-hidden')).toBe('true');
72+
73+
74+
compileElement('<div ng-show="val"></div>');
75+
76+
scope.$apply('val = "test angular"');
77+
expect(element.attr('aria-hidden')).toBe('false');
78+
79+
scope.$apply('val = null');
80+
expect(element.attr('aria-hidden')).toBe('true');
81+
82+
scope.$apply('val = {}');
83+
expect(element.attr('aria-hidden')).toBe('false');
84+
});
6085
});
6186

6287

@@ -319,6 +344,20 @@ describe('$aria', function() {
319344
scope.$apply('val = true');
320345
expectAriaAttrOnEachElement(element, 'aria-disabled', 'userSetValue');
321346
});
347+
348+
349+
it('should always set aria-disabled to a boolean value', function() {
350+
compileElement('<div ng-disabled="val"></div>');
351+
352+
scope.$apply('val = "test angular"');
353+
expect(element.attr('aria-disabled')).toBe('true');
354+
355+
scope.$apply('val = null');
356+
expect(element.attr('aria-disabled')).toBe('false');
357+
358+
scope.$apply('val = {}');
359+
expect(element.attr('aria-disabled')).toBe('true');
360+
});
322361
});
323362

324363
describe('aria-disabled when disabled', function() {

0 commit comments

Comments
 (0)