You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unexpected behaviour for falsy values when using arrays in class binding #48473
My expectation is basically that falsy values in an array will not be printed and will not affect other class declarations.
Basically I always expect to get .as-array .as-array2 .specific.
I cannot find logic in how it current works. There are 4 different behaviours based on what falsy value is used.
This can lead to unexpected behaviour and hard to diagnose errors.
Please provide a link to a minimal reproduction of the bug
This is a confirmed bug. What is going on here is that the styling algorithm doesn't seem to account for non-string and empty string values. Those unchecked values are propagated to the other parts of the framework and throw exceptions in other parts (DOM etc.).
While this might look like a corner cases, I can understand how people might want to use ternary expressions to have conditional classes (and evaluate to an empty string / null / undefined if a given class should not be applied).
We should fix it, although I'm not sure what is the best approach here: throw for "invalid" values or just ignore them.
@undsoft I think that any null or falsy value shouldn't affect the other class declaration. We can still show warning like "class declaration shouldn't contain any null or falsy values".. After showing this warning we should ignore falsy values and continue to apply other class declaration
Activity
pkozlowski-opensource commentedon Dec 14, 2022
Fixed stackblitz: https://stackblitz.com/edit/angular-ivy-g2fcyh?file=src%2Fapp%2Fapp.module.ts,src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.component.ts
This is a confirmed bug. What is going on here is that the styling algorithm doesn't seem to account for non-string and empty string values. Those unchecked values are propagated to the other parts of the framework and throw exceptions in other parts (DOM etc.).
While this might look like a corner cases, I can understand how people might want to use ternary expressions to have conditional classes (and evaluate to an empty string / null / undefined if a given class should not be applied).
We should fix it, although I'm not sure what is the best approach here: throw for "invalid" values or just ignore them.
pritam-chowdhury commentedon Dec 27, 2022
@undsoft I think that any null or falsy value shouldn't affect the other class declaration. We can still show warning like "class declaration shouldn't contain any null or falsy values".. After showing this warning we should ignore falsy values and continue to apply other class declaration
fix(core): handle invalid classes in class array bindings
fix(core): handle invalid classes in class array bindings (#49924)
fix(core): handle invalid classes in class array bindings (#49924)
angular-automatic-lock-bot commentedon May 20, 2023
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.