Closed th0r closed 4 years ago
Closing as duplicate of https://github.com/angular/angular/issues/35383
@mhevery I would agree if input name was class
but it's className
and current behavior is very counterintuitive. I don't assign className
anywhere in the example.
Angular treats class
and className
as the same thing (because <div [class]="">
would make no sense as there is no class
property on <div>
(there is class
attribute, but []
is binding property).
Can you explain what kind of issues is this causing for you?
Discussed offline: we are going to talk more about this one internally
We don't use styles encapsulation, but use BEM instead. Because of this most of our components contain single root element with class="name-of-the-bem-block"
and sometimes we use className
input to set class to this root element that override some styles for this BEM block. And it was very strange to see that both host and root elements have received the same classes.
Of course we can rename all such inputs to something like cls
but it still doesn't eliminate the confusion aspect of this behavior.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
π bug report
Affected Package
Not sure
Is this a regression?
Yes, the previous version in which this bug was not present was: 8.2.14 ### Description For example we have this component: ```ts import { Component, Input } from '@angular/core'; @Component({ selector: 'app-test', template: 'className is "{{ className }}" but should be undefined' }) export class TestComponent { @Input() className: string; } ``` If we use it like this: ```htmlCouldn't reproduce it on Stackblitz (it uses JIT compiler instead of AoT?) so created a separate repo with a minimal reproduction: https://github.com/th0r/ng9-classname-bug
Steps:
npm ci && npm start
http://localhost:4200/
in the browserclassName is "foo" but should be undefined
π Your Environment
Angular Version:
Anything else relevant? Bug doesn't depend on the browser used.