|
341 | 341 |
|
342 | 342 | var ngAttributeAliasDirectives = {};
|
343 | 343 |
|
344 |
| - |
345 | 344 | // boolean attrs are evaluated
|
346 | 345 | forEach(BOOLEAN_ATTR, function(propName, attrName) {
|
347 | 346 | // binding to multiple is not supported
|
348 | 347 | if (propName == "multiple") return;
|
349 | 348 |
|
350 |
| - var normalized = directiveNormalize('ng-' + attrName); |
| 349 | + function defaultLinkFn(scope, element, attr) { |
| 350 | + scope.$watch(attr[normalized], function ngBooleanAttrWatchAction(value) { |
| 351 | + attr.$set(attrName, !!value); |
| 352 | + }); |
| 353 | + } |
| 354 | + |
| 355 | + var normalized = directiveNormalize('ng-' + attrName), |
| 356 | + linkFn = defaultLinkFn; |
| 357 | + |
| 358 | + if (propName === 'checked') { |
| 359 | + linkFn = function(scope, element, attr) { |
| 360 | + // ensuring ngChecked doesn't interfere with ngModel when both are set on the same input |
| 361 | + // - https://github.com/angular/angular.js/issues/10662 |
| 362 | + !attr.ngModel && defaultLinkFn(scope, element, attr); |
| 363 | + }; |
| 364 | + } |
| 365 | + |
351 | 366 | ngAttributeAliasDirectives[normalized] = function() {
|
352 | 367 | return {
|
353 | 368 | restrict: 'A',
|
354 | 369 | priority: 100,
|
355 |
| - link: function(scope, element, attr) { |
356 |
| - scope.$watch(attr[normalized], function ngBooleanAttrWatchAction(value) { |
357 |
| - attr.$set(attrName, !!value); |
358 |
| - }); |
359 |
| - } |
| 370 | + link: linkFn |
360 | 371 | };
|
361 | 372 | };
|
362 | 373 | });
|
|
0 commit comments