Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ivy] 'ngClass' + 'dynamic [class] = undefined | null' completely clears out 'static class binding' #35335

Closed
Gretam11 opened this issue Feb 11, 2020 · 2 comments
Assignees
Labels
area: core Issues related to the framework runtime state: has PR type: bug/fix
Milestone

Comments

@Gretam11
Copy link

🐞 bug report

Affected Package

The issue is caused by package @angular/core or @angular/common 9.0.0

Is this a regression?

It works fine when Ivy is opted-out.

Description

I'm not sure whether this is a real bug, but it's indeed behavior which some libraries depend on. If the static class binding is specified with NgClass directive and with dynamic class binding equals null or undefined, all values from static class binding are being cleared out.
In case if any string (even empty) is specified in dynamic binding, it just merges all classes as expected.

🔬 Minimal Reproduction

I couldn't turn on ivy on stack-blitz, so here is the link on ng-run of minimal reproduction:
https://ng-run.com/edit/LKHMmMPIRiZmgFFqMt15
It's handy to turn on/off Ivy there.

🌍 Your Environment

Angular Version:

Angular CLI: 9.0.1
Node: 12.13.0
OS: win32 x64

Angular: 9.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.1
@angular-devkit/build-angular     0.900.1
@angular-devkit/build-optimizer   0.900.1
@angular-devkit/build-webpack     0.900.1
@angular-devkit/core              9.0.1
@angular-devkit/schematics        9.0.1
@angular/cli                      9.0.1
@ngtools/webpack                  9.0.1
@schematics/angular               9.0.1
@schematics/update                0.900.1
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2
@Gretam11 Gretam11 changed the title [ivy] 'ngClass' + 'dynamic [class]' completely clears out 'static class binding' [ivy] 'ngClass' + 'dynamic [class] = undefined | null' completely clears out 'static class binding' Feb 11, 2020
@kara kara added area: core Issues related to the framework runtime comp: ivy labels Feb 11, 2020
@ngbot ngbot bot modified the milestone: needsTriage Feb 11, 2020
mhevery added a commit to mhevery/angular that referenced this issue Feb 12, 2020
@cagataycivici
Copy link

Thank you, it was a showstopper for us to release PrimeNG 9.0.0

tundisto pushed a commit to TimUnderhay/xsoar-incident-creator that referenced this issue Feb 13, 2020
PrimenNG messages display is broken due to ivy bug angular/angular#35335.
mhevery added a commit to mhevery/angular that referenced this issue Feb 14, 2020
…` when shadowed

Given:
```
<div class="s1" [class]="null" [ngClass]="exp">
```
Notice that `[class]` binding is not a `string`. As a result the existing logic would not concatenate `[class]` with `class="s1"`. The resulting falsy value would than be sent to `ngClass` which would promptly clear all styles on the `<div>`

The new logic correctly handles falsy values for `[class]` bindings.

Fix angular#35335
mhevery added a commit to mhevery/angular that referenced this issue Feb 14, 2020
…` when shadowed

Given:
```
<div class="s1" [class]="null" [ngClass]="exp">
```
Notice that `[class]` binding is not a `string`. As a result the existing logic would not concatenate `[class]` with `class="s1"`. The resulting falsy value would than be sent to `ngClass` which would promptly clear all styles on the `<div>`

The new logic correctly handles falsy values for `[class]` bindings.

Fix angular#35335
@alxhub alxhub closed this as completed in 8c75f21 Feb 14, 2020
alxhub pushed a commit that referenced this issue Feb 14, 2020
…` when shadowed (#35350)

Given:
```
<div class="s1" [class]="null" [ngClass]="exp">
```
Notice that `[class]` binding is not a `string`. As a result the existing logic would not concatenate `[class]` with `class="s1"`. The resulting falsy value would than be sent to `ngClass` which would promptly clear all styles on the `<div>`

The new logic correctly handles falsy values for `[class]` bindings.

Fix #35335

PR Close #35350
sonukapoor pushed a commit to sonukapoor/angular that referenced this issue Feb 17, 2020
…` when shadowed (angular#35350)

Given:
```
<div class="s1" [class]="null" [ngClass]="exp">
```
Notice that `[class]` binding is not a `string`. As a result the existing logic would not concatenate `[class]` with `class="s1"`. The resulting falsy value would than be sent to `ngClass` which would promptly clear all styles on the `<div>`

The new logic correctly handles falsy values for `[class]` bindings.

Fix angular#35335

PR Close angular#35350
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Mar 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime state: has PR type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants