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(animations): apply default params when resolved value is null or undefined #45339
Conversation
…undefined The animations package supports adding default parameter values to an animation that will be used as a fallback if some parameters aren't defined. The problem is that they're applied using a spread expression which means that any own property of the animation parameters will override the defaults, even if it resolves to null or undefined. This can lead to obscure errors like "Cannot read property toString of undefined" for an animation that looks like `{params: {foo: undefined}}` with defaults `{foo: 123}`. I ran into this issue while debugging some test failures on Material. These changes address the issue by: 1. Applying the defaults if the resolved value is null or undefined. 2. Updating the validation function to use a null check instead of `hasOwnProperty`.
d50c14c
to
deeac84
Compare
@@ -2394,6 +2394,42 @@ describe('animation tests', function() { | |||
expect(hasStyle(element, 'height', '100px')).toBeTruthy(); | |||
})); | |||
|
|||
it('should apply default params when resolved animation value is null or undefined', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going back-and-forth between doing this versus throwing a proper error. I went with this, because it seemed weird for {foo: undefined, bar: 1}
and {bar: 1}
to behave differently.
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
@crisbeto FYI this doesn't merge cleanly to 13.3.x. |
This PR was merged into the repository by commit 2a75754. |
…undefined (angular#45339) The animations package supports adding default parameter values to an animation that will be used as a fallback if some parameters aren't defined. The problem is that they're applied using a spread expression which means that any own property of the animation parameters will override the defaults, even if it resolves to null or undefined. This can lead to obscure errors like "Cannot read property toString of undefined" for an animation that looks like `{params: {foo: undefined}}` with defaults `{foo: 123}`. I ran into this issue while debugging some test failures on Material. These changes address the issue by: 1. Applying the defaults if the resolved value is null or undefined. 2. Updating the validation function to use a null check instead of `hasOwnProperty`. PR Close angular#45339
…undefined (angular#45339) The animations package supports adding default parameter values to an animation that will be used as a fallback if some parameters aren't defined. The problem is that they're applied using a spread expression which means that any own property of the animation parameters will override the defaults, even if it resolves to null or undefined. This can lead to obscure errors like "Cannot read property toString of undefined" for an animation that looks like `{params: {foo: undefined}}` with defaults `{foo: 123}`. I ran into this issue while debugging some test failures on Material. These changes address the issue by: 1. Applying the defaults if the resolved value is null or undefined. 2. Updating the validation function to use a null check instead of `hasOwnProperty`. PR Close angular#45339
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The animations package supports adding default parameter values to an animation that will be used as a fallback if some parameters aren't defined. The problem is that they're applied using a spread expression which means that any own property of the animation parameters will override the defaults, even if it resolves to null or undefined. This can lead to obscure errors like "Cannot read property toString of undefined" for an animation that looks like
{params: {foo: undefined}}
with defaults{foo: 123}
.I ran into this issue while debugging some test failures on Material.
These changes address the issue by:
hasOwnProperty
.