Skip to content

fix(ivy): error for empty bindings on ng-template #30829

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

Closed

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Jun 3, 2019

Fixes Ivy throwing an error if it runs into an empty property binding on an ng-template (e.g. <ng-template [something]=""></ng-template>) by not generating an update instruction for it.

Fixes #30801.
This PR resoves FW-1356.

@crisbeto crisbeto added comp: ivy action: review The PR is still awaiting reviews from at least one requested reviewer type: bug/fix labels Jun 3, 2019
@crisbeto crisbeto marked this pull request as ready for review June 3, 2019 17:39
@crisbeto crisbeto requested review from a team as code owners June 3, 2019 17:39
@ngbot ngbot bot modified the milestone: needsTriage Jun 3, 2019
@AndrewKushnir
Copy link
Contributor

Presubmit

@AndrewKushnir AndrewKushnir added action: presubmit The PR is in need of a google3 presubmit action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release and removed action: review The PR is still awaiting reviews from at least one requested reviewer action: presubmit The PR is in need of a google3 presubmit target: major This PR is targeted for the next major release labels Jun 3, 2019
@Airblader
Copy link
Contributor

Based on @JoostK's comment I was expecting that the fix would be in the visit method of EmptyExpr to not return undefined(?)

@AndrewKushnir AndrewKushnir removed the action: merge The PR is ready for merge by the caretaker label Jun 4, 2019
@JoostK
Copy link
Member

JoostK commented Jun 4, 2019

@Airblader Changing EmptyExpr.visit not to return undefined would mean that we'd need to return something else. Since the actually correct behavior (at least according to what VE has always done) would be that should be that no binding code should be generated at all, easiest is to just deal with the undefined value.

Going forward, it seems like a good idea to either have type-safety regarding the potential undefined value here, or the template parser should be changed to always error on an empty binding. Then, EmptyExpr.visit could simply throw, as it should be an illegal operation to compile a template containing EmptyExpr nodes. FYI: there's 6 places where an EmptyExpr could be created during parsing, 5 of which do produce an error. Only the empty property binding has slipped through.

From a bugfix perspective, this fix looks adequate to me.

@crisbeto crisbeto force-pushed the FW-1356/ivy-blank-template-bindings branch from bf08bfa to 8cd8855 Compare June 4, 2019 20:03
@crisbeto
Copy link
Member Author

crisbeto commented Jun 4, 2019

Thank you for the feedback @JoostK. Setting back the merge ready label since I've updated it to address the comment.

@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Jun 4, 2019
Fixes Ivy throwing an error if it runs into an empty property binding on an `ng-template` (e.g. `<ng-template [something]=""></ng-template>`) by not generating an update instruction for it.

Fixes angular#30801.
This PR resoves FW-1356.
@crisbeto crisbeto force-pushed the FW-1356/ivy-blank-template-bindings branch from 8cd8855 to a4f4269 Compare June 4, 2019 20:21
@mhevery mhevery closed this in b51d8dd Jun 6, 2019
@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 Sep 15, 2019
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 cla: yes target: major This PR is targeted for the next major release type: bug/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ivy fails to compile a template with [ngTemplateOutletContext]=""
7 participants