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

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

Open
@jbedard

Description

@jbedard

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions