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

fix(core): correctly concatinate static and dynamic binding to `class… #35350

Closed
wants to merge 1 commit into from

Conversation

mhevery
Copy link
Contributor

@mhevery mhevery commented Feb 12, 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 #35335

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@pullapprove pullapprove bot requested a review from alxhub February 12, 2020 00:31
@mhevery mhevery added area: core Issues related to the framework runtime action: merge The PR is ready for merge by the caretaker action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Feb 12, 2020
@ngbot ngbot bot modified the milestone: needsTriage Feb 12, 2020
@mhevery
Copy link
Contributor Author

mhevery commented Feb 12, 2020

presubmit

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up! Some minor changes requested below.

  • Can we also add some context to the commit message itself on what was broken and how we fixed it?
  • In the commit, concatinate => concatenate

packages/core/test/acceptance/styling_spec.ts Outdated Show resolved Hide resolved
packages/core/test/acceptance/styling_spec.ts Outdated Show resolved Hide resolved
packages/core/test/acceptance/styling_spec.ts Outdated Show resolved Hide resolved
@mhevery mhevery requested review from kara and removed request for alxhub February 14, 2020 03:52
…` 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
Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the great commit message

@kara kara added action: presubmit The PR is in need of a google3 presubmit and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Feb 14, 2020
@mhevery mhevery removed the action: presubmit The PR is in need of a google3 presubmit label Feb 14, 2020
@alxhub alxhub closed this in 8c75f21 Feb 14, 2020
alxhub pushed a commit that referenced this pull request 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 pull request 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
action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime cla: yes target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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