Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(ngChecked): ensure that ngChecked doesn't interfere with ngModel #10664

Closed

Conversation

LeonardoBraga
Copy link
Contributor

Fixes #10662

linkFn = function(scope, element, attr) {
// ensuring ngChecked doesn't interfere with ngModel when both are set on the same input
// - https://github.com/angular/angular.js/issues/10662
!attr.ngModel && defaultLinkFn(scope, element, attr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ngChecked only really breaks things if the ngModel attribute value is the same as the ngChecked attribute value

So more like attr.ngModel !== attr[normalized] && ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, for code style, please write it like this:

if (attr.ngModel !== attr[normalized) {
  defaultLinkFn(scope, element, attr);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caitp Done. Please let me know if something else requires adjustment.

linkFn = function(scope, element, attr) {
// ensuring ngChecked doesn't interfere with ngModel when both are set on the same input
// - https://github.com/angular/angular.js/issues/10662
if (attr.ngModel !== attr[normalized) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo ^^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kinda feel like special casing different attributes in here is kind of gross, too --- but we can worry about that later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-$ - sorry, it's fixed now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kinda feel like special casing different attributes in here is kind of gross, too --- but we can worry about that later

Sure. Just ping if you want me to consider that in another PR.

@caitp
Copy link
Contributor

caitp commented Jan 7, 2015

lgtm

@caitp
Copy link
Contributor

caitp commented Jan 7, 2015

@Narretz am I missing anything? could you give this a second look before merging thanks

}

var normalized = directiveNormalize('ng-' + attrName),
linkFn = defaultLinkFn;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explicitly declare the linkFn variable? I think we prefer this now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So linkFn would have it's own var? I'm asking because it differs with other places I saw in the code. Just let me know if that's indeed the case and I'll change it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I mean. It's a minor thing - but recent code changes favour this version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with @Narretz, we prefer to give each variable it's own var, it's a bit easier than dealing with a huge comma-separated list (see compile.js for examples :x) =)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a problem! :-) Thanks for the instructions and I'll be updating the PR soon.

@Narretz
Copy link
Contributor

Narretz commented Jan 7, 2015

Apart from these small nitpicks, this looks good to me. I also didn't know we had this directive ...

@caitp
Copy link
Contributor

caitp commented Jan 7, 2015

lgtm, will merge when green

@LeonardoBraga
Copy link
Contributor Author

@caitp Travis seems flaky again. Should I close + reopen to force a re-test?

@caitp
Copy link
Contributor

caitp commented Jan 8, 2015

no need, restarted manually

@LeonardoBraga
Copy link
Contributor Author

Could you please restart again? :-/

@caitp
Copy link
Contributor

caitp commented Jan 8, 2015

it's just browserstack having issues, it's not failing in a consistent way, so I think it's fine. chock it up to flakes

@caitp
Copy link
Contributor

caitp commented Jan 8, 2015

@petebacondarwin I think this is a good candidate for cherry-picking into 1.3, but can you make the call on that?

@caitp caitp closed this in e079111 Jan 8, 2015
@LeonardoBraga LeonardoBraga deleted the fix-ng-checked-10662 branch January 8, 2015 02:33
@lgalfaso lgalfaso mentioned this pull request Mar 11, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug in checkbox
4 participants