diff --git a/src/ngAria/aria.js b/src/ngAria/aria.js
index 8c136676d4ad..770500e11d9a 100644
--- a/src/ngAria/aria.js
+++ b/src/ngAria/aria.js
@@ -265,13 +265,23 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
elem.attr('role', 'slider');
}
if ($aria.config('ariaValue')) {
- if (attr.min && !elem.attr('aria-valuemin')) {
- elem.attr('aria-valuemin', attr.min);
+ var needsAriaValuemin = !elem.attr('aria-valuemin') &&
+ (attr.hasOwnProperty('min') || attr.hasOwnProperty('ngMin'));
+ var needsAriaValuemax = !elem.attr('aria-valuemax') &&
+ (attr.hasOwnProperty('max') || attr.hasOwnProperty('ngMax'));
+ var needsAriaValuenow = !elem.attr('aria-valuenow');
+
+ if (needsAriaValuemin) {
+ attr.$observe('min', function ngAriaValueMinReaction(newVal) {
+ elem.attr('aria-valuemin', newVal);
+ });
}
- if (attr.max && !elem.attr('aria-valuemax')) {
- elem.attr('aria-valuemax', attr.max);
+ if (needsAriaValuemax) {
+ attr.$observe('max', function ngAriaValueMinReaction(newVal) {
+ elem.attr('aria-valuemax', newVal);
+ });
}
- if (!elem.attr('aria-valuenow')) {
+ if (needsAriaValuenow) {
scope.$watch(ngAriaWatchModelValue, function ngAriaValueNowReaction(newVal) {
elem.attr('aria-valuenow', newVal);
});
diff --git a/test/ngAria/ariaSpec.js b/test/ngAria/ariaSpec.js
index 8bfe301123e6..a36faa6443dc 100644
--- a/test/ngAria/ariaSpec.js
+++ b/test/ngAria/ariaSpec.js
@@ -510,6 +510,34 @@ describe('$aria', function() {
expectAriaAttrOnEachElement(element, 'aria-valuemin', 'userSetValue2');
expectAriaAttrOnEachElement(element, 'aria-valuemax', 'userSetValue3');
});
+
+ it('should update `aria-valuemin/max` when `min/max` changes dynamically', function() {
+ scope.$apply('min = 25; max = 75');
+ compileElement('');
+
+ expect(element.attr('aria-valuemin')).toBe('25');
+ expect(element.attr('aria-valuemax')).toBe('75');
+
+ scope.$apply('min = 0');
+ expect(element.attr('aria-valuemin')).toBe('0');
+
+ scope.$apply('max = 100');
+ expect(element.attr('aria-valuemax')).toBe('100');
+ });
+
+ it('should update `aria-valuemin/max` when `ng-min/ng-max` changes dynamically', function() {
+ scope.$apply('min = 25; max = 75');
+ compileElement('');
+
+ expect(element.attr('aria-valuemin')).toBe('25');
+ expect(element.attr('aria-valuemax')).toBe('75');
+
+ scope.$apply('min = 0');
+ expect(element.attr('aria-valuemin')).toBe('0');
+
+ scope.$apply('max = 100');
+ expect(element.attr('aria-valuemax')).toBe('100');
+ });
});
describe('announcing ngMessages', function() {