This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(ngAria): add support for ngReadonly #14140
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,6 +396,66 @@ describe('$aria', function() { | |
}); | ||
}); | ||
|
||
describe('aria-readonly', function() { | ||
beforeEach(injectScopeAndCompiler); | ||
|
||
they('should not attach itself to native $prop controls', { | ||
input: '<input ng-readonly="val">', | ||
textarea: '<textarea ng-readonly="val"></textarea>', | ||
select: '<select ng-readonly="val"></select>', | ||
button: '<button ng-readonly="val"></button>' | ||
}, function(tmpl) { | ||
var element = $compile(tmpl)(scope); | ||
scope.$apply('val = true'); | ||
|
||
expect(element.attr('readonly')).toBeDefined(); | ||
expect(element.attr('aria-readonly')).toBeUndefined(); | ||
}); | ||
|
||
it('should attach itself to custom controls', function() { | ||
compileElement('<div ng-readonly="val"></div>'); | ||
expect(element.attr('aria-readonly')).toBe('false'); | ||
|
||
scope.$apply('val = true'); | ||
expect(element.attr('aria-readonly')).toBe('true'); | ||
|
||
}); | ||
|
||
it('should not attach itself if an aria-readonly attribute is already present', function() { | ||
compileElement('<div ng-readonly="val" aria-readonly="userSetValue"></div>'); | ||
|
||
expect(element.attr('aria-readonly')).toBe('userSetValue'); | ||
}); | ||
|
||
it('should always set aria-readonly to a boolean value', function() { | ||
compileElement('<div ng-readonly="val"></div>'); | ||
|
||
scope.$apply('val = "test angular"'); | ||
expect(element.attr('aria-readonly')).toBe('true'); | ||
|
||
scope.$apply('val = null'); | ||
expect(element.attr('aria-readonly')).toBe('false'); | ||
|
||
scope.$apply('val = {}'); | ||
expect(element.attr('aria-readonly')).toBe('true'); | ||
}); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also need some test for when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have added some tests when ariaReadonly is disabled |
||
|
||
describe('aria-readonly when disabled', function() { | ||
beforeEach(configAriaProvider({ | ||
ariaReadonly: false | ||
})); | ||
beforeEach(injectScopeAndCompiler); | ||
|
||
it('should not add the aria-readonly attribute', function() { | ||
compileElement("<input ng-model='val' readonly>"); | ||
expect(element.attr('aria-readonly')).toBeUndefined(); | ||
|
||
compileElement("<div ng-model='val' ng-readonly='true'></div>"); | ||
expect(element.attr('aria-readonly')).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe('aria-required', function() { | ||
beforeEach(injectScopeAndCompiler); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Redundant newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the Nitpick: Redundant newline.