Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng-attr-* entry in `$attrs` has incorrect casing #16624

Open
jbedard opened this issue Jul 6, 2018 · 0 comments
Open

ng-attr-* entry in `$attrs` has incorrect casing #16624

jbedard opened this issue Jul 6, 2018 · 0 comments

Comments

@jbedard
Copy link
Contributor

@jbedard jbedard commented Jul 6, 2018

I'm submitting a ...

  • bug report

Current behavior:
The entries in $attrs created by ng-attr-* have the incorrect camel casing when the attribute has mixed case.

Details
Normally the keys in $attrs get normalized by directiveNormalize(name.toLowerCase()): https://github.com/angular/angular.js/blob/v1.7.2/src/ng/compile.js#L2274

But for ng-attr-* the name gets partially normalized by the ng-attr-* logic before being normalized again in the standard way. I think this has existed since mixed case attributes were supported.

This causes things like ng-attr-my-camel_prop="..." to be $attrs.myCamelprop instead of $attrs.myCamelProp. Where my-camel_prop="..." would be $attrs.myCamelProp.

Note that the actual attribute put onto the element is correct, it's only the entry in $attrs and $attrs.$attr that have the incorrect casing. For example ng-attr-my-camel_case correctly maps to the my-camelCase attribute, its just the key in $attrs.myCamelcase and $attrs.$attr.myCamelcase that are wrong.

Expected / new behavior:
Consistent attribute name normalizing between ng-attr-* and normal attributes.

Anything else:
I wonder if $attrs.$set has any issues? https://github.com/angular/angular.js/blob/v1.7.2/src/ng/compile.js#L1762-L1765

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants