Angular parser strips single quotes from ngClass
See original GitHub issuePrettier 1.15.3 Playground link
--parser angular
Input:
<div [ngClass]="{ 'x': y }"></div>
Output:
<div [ngClass]="{ x: y }"></div>
Expected behavior:
The single quotations around the x
should not be stripped out.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:13 (7 by maintainers)
Top Results From Across the Web
VS Code Prettier extension replaces single quotation marks to ...
angular - VS Code Prettier extension replaces single quotation marks to double and removes backslash marks - Stack Overflow. Stack Overflow for ...
Read more >ngClass - Unsaved project - Plunker
var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope, $timeout) { $scope.like = true; $scope.button = true; $scope.cool ...
Read more >Template Syntax - ts - GUIDE - Angular
A template statement responds to an event raised by a binding target such as an element, component, or directive. You'll see template statements...
Read more >Angular with haml: Dynamic html classes - makandra dev
jQuery's removeClass removes the given class string from an element collection. If you want to remove multiple/unknown classes matching a given pattern, you...
Read more >Template Syntax - dart - GUIDE - Angular
A template reference variable is one such alternative context object. ... The template statement parser is different than the template expression parser and ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@duailibe No, I am not worried that it will break the app - I am worried that it will lead to what some (including myself) would consider inconsistent styling, where someone who isn’t familiar with the otherwise somewhat obscure rules regarding multiple, dash separated word variable names in JS would be confused at why some ngClass examples get stripped of quotes, and others don’t. This is further amplified by the fact that while the parser strips quotes when they aren’t needed, it doesn’t add them where they are needed, creating further confusion for someone who might modify a single word class into a multi word one, and suddenly run into a compilation error.
At the end of the day, I’m just worried that newbies are going to get confused, but its possible that I’m worrying too much, so it would help if any other Angular devs could give their thoughts.
Whitespace around will not lead to the removal of the quotes.
[ngClass]="{ 'active': isActive }">
here the quotes will be removed[ngClass]="{ ' active ': isActive }">
here not