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

feat(compiler): support nullish coalescing in templates #41437

Closed
wants to merge 2 commits into from

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Apr 3, 2021

Adds support for nullish coalescing expressions inside of Angular templates (e.g. {{ a ?? b ?? c}}).

Fixes #36528.

@google-cla google-cla bot added the cla: yes label Apr 3, 2021
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer area: compiler Issues related to `ngc`, Angular's template compiler target: major This PR is targeted for the next major release and removed state: WIP labels Apr 3, 2021
@ngbot ngbot bot modified the milestone: Backlog Apr 3, 2021
@crisbeto crisbeto marked this pull request as ready for review April 3, 2021 16:31
@pullapprove pullapprove bot requested a review from alxhub April 3, 2021 16:31
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @crisbeto 👍

I've started a presubmit to see if there are some cases that may require additional attention and will let you know.

@AndrewKushnir AndrewKushnir 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 Apr 6, 2021
@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Apr 6, 2021
@AndrewKushnir
Copy link
Contributor

Quick update: presubmit looks good, I will also run a global one (TGP) tonight and will keep this thread updated. Thank you.

@AndrewKushnir
Copy link
Contributor

Global Presubmit.

@AndrewKushnir AndrewKushnir added feature Issue that requests a new feature and removed action: presubmit The PR is in need of a google3 presubmit labels Apr 7, 2021
@AndrewKushnir
Copy link
Contributor

FYI, global presubmit was successful as well, so I'm removing the "presubmit" label, which makes this PR fully ready for merge!

Adds support for nullish coalescing expressions inside of Angular templates (e.g. `{{ a ?? b ?? c}}`).

Fixes angular#36528.
@crisbeto
Copy link
Member Author

crisbeto commented Apr 7, 2021

I've rebased and pushed another commit with more tests for host bindings.

@atscott atscott closed this in ec27bd4 Apr 7, 2021
crisbeto added a commit to crisbeto/angular that referenced this pull request Apr 11, 2021
… nullish coalescing

This is follow-up from angular#41437 and it reduces the amount of code we generate for safe property accesses (`a?.b`) and nullish coalescing (`a ?? b`) by:
1. Reusing variables in nested nullish coalescing expressions.
2. Not initializing temporary variables to `null`. The way our code is generated means that the value will always be overwritten before we compare against it so the initializer didn't really matter.

Fixes angular#41491.
crisbeto added a commit to crisbeto/angular that referenced this pull request Apr 12, 2021
… nullish coalescing

This is follow-up from angular#41437 and it reduces the amount of code we generate for safe property accesses (`a?.b`) and nullish coalescing (`a ?? b`) by:
1. Reusing variables in nested nullish coalescing expressions.
2. Not initializing temporary variables to `null`. The way our code is generated means that the value will always be overwritten before we compare against it so the initializer didn't really matter.

Fixes angular#41491.
crisbeto added a commit to crisbeto/angular that referenced this pull request Apr 13, 2021
… nullish coalescing

This is follow-up from angular#41437 and it reduces the amount of code we generate for safe property accesses (`a?.b`) and nullish coalescing (`a ?? b`) by:
1. Reusing variables in nested nullish coalescing expressions.
2. Not initializing temporary variables to `null`. The way our code is generated means that the value will always be overwritten before we compare against it so the initializer didn't really matter.

Fixes angular#41491.
zarend pushed a commit that referenced this pull request Apr 14, 2021
… nullish coalescing (#41563)

This is follow-up from #41437 and it reduces the amount of code we generate for safe property accesses (`a?.b`) and nullish coalescing (`a ?? b`) by:
1. Reusing variables in nested nullish coalescing expressions.
2. Not initializing temporary variables to `null`. The way our code is generated means that the value will always be overwritten before we compare against it so the initializer didn't really matter.

Fixes #41491.

PR Close #41563
zarend pushed a commit that referenced this pull request Apr 14, 2021
… nullish coalescing (#41563)

This is follow-up from #41437 and it reduces the amount of code we generate for safe property accesses (`a?.b`) and nullish coalescing (`a ?? b`) by:
1. Reusing variables in nested nullish coalescing expressions.
2. Not initializing temporary variables to `null`. The way our code is generated means that the value will always be overwritten before we compare against it so the initializer didn't really matter.

Fixes #41491.

PR Close #41563
@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 May 8, 2021
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: compiler Issues related to `ngc`, Angular's template compiler cla: yes feature Issue that requests a new feature target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable Nullish Coalescing operator in angular template
3 participants