Skip to content

Commit 02ab458

Browse files
typeofwebNarretz
authored andcommitted
test(ngAria): test that aria-hidden is 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
1 parent 6e1ed03 commit 02ab458

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/ngAria/ariaSpec.js

+25
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

0 commit comments

Comments
 (0)