Skip to content

Commit 225e80d

Browse files
committed
wip
1 parent 961e9ee commit 225e80d

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

src/ng/directive/input.js

+3
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,7 @@ function radioInputType(scope, element, attr, ctrl) {
13101310
ctrl.$render = function() {
13111311
var value = attr.value;
13121312
element[0].checked = (value == ctrl.$viewValue);
1313+
dump('after render');
13131314
};
13141315

13151316
attr.$observe('value', ctrl.$render);
@@ -1339,6 +1340,7 @@ function checkboxInputType(scope, element, attr, ctrl, $sniffer, $browser, $filt
13391340
element.on('click', listener);
13401341

13411342
ctrl.$render = function() {
1343+
dump('render', typeof ctrl.$viewValue);
13421344
element[0].checked = ctrl.$viewValue;
13431345
};
13441346

@@ -1350,6 +1352,7 @@ function checkboxInputType(scope, element, attr, ctrl, $sniffer, $browser, $filt
13501352
};
13511353

13521354
ctrl.$formatters.push(function(value) {
1355+
dump('formatter', value, trueValue, equals(value, trueValue));
13531356
return equals(value, trueValue);
13541357
});
13551358

src/ngAria/aria.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,27 @@ ngAriaModule.directive('ngShow', ['$aria', function($aria) {
228228
if (needsTabIndex) {
229229
needsTabIndex = false;
230230
return function ngAriaRadioReaction(newVal) {
231-
var boolVal = (angular.isUndefined(newVal) ? newVal : newVal.toString()) === attr.value;
231+
// var boolVal = (angular.isUndefined(newVal) ? newVal : newVal.toString()) === attr.value;
232+
// var boolVal = !ngModel.$isEmpty(ngModel.$viewValue);
233+
var boolVal = (attr.value == ngModel.$viewValue);
234+
dump(ngModel.$viewValue, ngModel.$isEmpty(ngModel.$viewValue));
232235
elem.attr('aria-checked', boolVal);
233236
elem.attr('tabindex', 0 - !boolVal);
234237
};
235238
} else {
236239
return function ngAriaRadioReaction(newVal) {
237-
elem.attr('aria-checked', (angular.isUndefined(newVal) ? newVal : newVal.toString()) === attr.value);
240+
// elem.attr('aria-checked', (!ngModel.$isEmpty(ngModel.$viewValue)));
241+
dump('no needs tabindex', ngModel.$viewValue, ngModel.$isEmpty(ngModel.$viewValue));
242+
// elem.attr('aria-checked', (angular.isUndefined(newVal) ? newVal : newVal.toString()) === attr.value);
243+
elem.attr('aria-checked', (attr.value == ngModel.$viewValue));
238244
};
239245
}
240246
}
241247

242248
function ngAriaCheckboxReaction(newVal) {
243-
elem.attr('aria-checked', !!newVal);
249+
// elem.attr('aria-checked', !!newVal);
250+
dump('checkbox', newVal, ngModel.$viewValue, ngModel.$isEmpty(ngModel.$viewValue));
251+
elem.attr('aria-checked', !ngModel.$isEmpty(ngModel.$viewValue));
244252
}
245253

246254
switch (shape) {

test/ngAria/ariaSpec.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
describe('$aria', function() {
3+
ddescribe('$aria', function() {
44
var scope, $compile, element;
55

66
beforeEach(module('ngAria'));
@@ -98,6 +98,18 @@ describe('$aria', function() {
9898
expect(element.eq(1).attr('aria-checked')).toBe('true');
9999
});
100100

101+
it('should handle non-string model values for checkbox', function() {
102+
var element = $compile('<input type="checkbox" ng-model="val" ng-true-value="0">')(scope);
103+
104+
scope.$apply("val=0");
105+
expect(element.eq(0).attr('aria-checked')).toBe('true');
106+
107+
// scope.$apply("val=1");
108+
// // dump('bla', element.controller('ngModel').$viewValue);
109+
// expect(element.eq(0).attr('aria-checked')).toBe('false');
110+
// expect(element.eq(1).attr('aria-checked')).toBe('true');
111+
});
112+
101113
it('should handle non-string model values', function() {
102114
var element = $compile('<input type="radio" ng-model="val" value="0">' +
103115
'<input type="radio" ng-model="val" value="1">')(scope);
@@ -107,6 +119,7 @@ describe('$aria', function() {
107119
expect(element.eq(1).attr('aria-checked')).toBe('false');
108120

109121
scope.$apply("val=1");
122+
dump('bla', element.controller('ngModel').$viewValue);
110123
expect(element.eq(0).attr('aria-checked')).toBe('false');
111124
expect(element.eq(1).attr('aria-checked')).toBe('true');
112125
});

0 commit comments

Comments
 (0)