-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[Angular] Do not force lowercase for any attribute #5547
Copy link
Copy link
Closed
Labels
lang:angularIssues affecting Angular template (not general JS/TS issues used for Angular)Issues affecting Angular template (not general JS/TS issues used for Angular)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.priority:highCode is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!Issues with an accompanying pull request. These issues will probably be fixed soon!
Milestone
Metadata
Metadata
Assignees
Labels
lang:angularIssues affecting Angular template (not general JS/TS issues used for Angular)Issues affecting Angular template (not general JS/TS issues used for Angular)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.priority:highCode is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!Code is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!status:has prIssues with an accompanying pull request. These issues will probably be fixed soon!Issues with an accompanying pull request. These issues will probably be fixed soon!
I ran into this in an existing Angular project where I have an
InputnameditemTypein an Angular directive. Prettier transforms myitemTypeattribute intoitemtypesince I'm applying it to adivelement anditemtypeis a known global attribute. However, this breaks the binding with the AngularInputin the directive.This type of transformation is likely always unsafe in the Angular world, even if there is no noticeable directive being applied to the element, since I can have a directive with a generic selector such as
divand customInputs on it.For now I'm using Angular's square bracket notation:
[itemType]="'x'". This might even be the best option (since it avoids conflicts with the nativeitemtypeattribute). However, Prettier should probably not break user-code, so I'd qualify this as a bug.Prettier 1.15.2
Playground link
Input:
Output:
Expected behavior (unchanged):