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(common): ngStyle should ignore undefined values #34422

Conversation

@mnahkies
Copy link
Contributor

mnahkies commented Dec 16, 2019

Prior to ivy, undefined values passed in an object to the ngStyle directive were ignored. Restore this behavior by ignoring keys that point to undefined values.

closes #34310

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?

Since ivy, objects with keys set to undefined passed to ngstyle will alter the computed styles.

Issue Number: 34310

What is the new behavior?

Restore original behavior of keys set to undefined being ignored.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Note, when running (all) tests locally I had 8 failed tests on both tip of master, and this branch. I'm unsure if this is something I've done wrong, or just the state of master currently. I was however able to observe my new test failing without my changes, and passing with the changes applied.

It would be great if there could be a single "pre-flight" check script to run prior to pushing that would execute an equivalent of a full CI build locally, as the documentation for build/test/analyse feels quite fragmented at the moment.

@mnahkies mnahkies requested a review from angular/fw-core as a code owner Dec 16, 2019
@googlebot googlebot added the cla: yes label Dec 16, 2019
Prior to ivy, undefined values passed in an object to the
ngStyle directive were ignored. Restore this behavior by
ignoring keys that point to undefined values.

closes #34310
@mnahkies mnahkies force-pushed the mnahkies:bug-34310-handle-undefined-values-ngstyle branch from a9341fa to aa2471e Dec 16, 2019
@mnahkies mnahkies changed the title fix(common): ngStyle should filter out undefined values fix(common): ngStyle should ignore undefined values Dec 16, 2019
@mnahkies

This comment has been minimized.

Copy link
Contributor Author

mnahkies commented Dec 16, 2019

My original approach was to filter out undefined keys at the ngStyle directive level. This failed on CI, and by running the command that CI had used locally I was able to see that the ngStyle directive expects users to be able to mutate the object passed to it.

I've now adjusted my approach to skip over values that are undefined in the styling differ, and the tests that were failing now pass locally.

@matsko
matsko approved these changes Dec 16, 2019
Copy link
Member

matsko left a comment

LGTM

@kara
kara approved these changes Dec 16, 2019
Copy link
Contributor

kara left a comment

LGTM

@kara

This comment has been minimized.

Copy link
Contributor

kara commented Dec 16, 2019

kara added a commit that referenced this pull request Dec 16, 2019
Prior to ivy, undefined values passed in an object to the
ngStyle directive were ignored. Restore this behavior by
ignoring keys that point to undefined values.

closes #34310

PR Close #34422
@kara kara closed this in 1144ce9 Dec 16, 2019
@mnahkies mnahkies deleted the mnahkies:bug-34310-handle-undefined-values-ngstyle branch Dec 16, 2019
@angular-automatic-lock-bot

This comment has been minimized.

Copy link

angular-automatic-lock-bot bot commented Jan 16, 2020

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 Jan 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants
You can’t perform that action at this time.