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(compiler): recover event parse when animation event name is empty #39925

Closed
wants to merge 1 commit into from

Conversation

ivanwonder
Copy link
Contributor

Now when the animation trigger output event is missing its phase value name, the BoundEvent will be ignored, but it's useful for completion in language service.

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

@google-cla google-cla bot added the cla: yes label Dec 2, 2020
@pullapprove pullapprove bot requested a review from JoostK December 2, 2020 06:16
@jessicajaniuk jessicajaniuk added the area: compiler Issues related to `ngc`, Angular's template compiler label Dec 2, 2020
@ngbot ngbot bot added this to the needsTriage milestone Dec 2, 2020
Comment on lines +411 to +409
expect(() => parse('<div (@)></div>'))
.toThrowError(/Animation event name is missing in binding/);
Copy link
Member

Choose a reason for hiding this comment

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

I think it may be helpful to merge this expect with the last test.

Also, could you add tests for when the phase is not start or done, or missing?


if (eventName.length === 0) {
this._reportError(`Animation event name is missing in binding`, sourceSpan);
}
if (phase) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need this outer conditional anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

parseEvent(
name: string, expression: string, sourceSpan: ParseSourceSpan, handlerSpan: ParseSourceSpan,
targetMatchableAttrs: string[][], targetEvents: ParsedEvent[], keySpan?: ParseSourceSpan) {
if (name.length === 0) {
this._reportError(`Event name is missing in binding`, sourceSpan);
}
if (isAnimationLabel(name)) {
name = name.substr(1);
this._parseAnimationEvent(name, expression, sourceSpan, handlerSpan, targetEvents, keySpan);
} else {
this._parseRegularEvent(
name, expression, sourceSpan, handlerSpan, targetMatchableAttrs, targetEvents, keySpan);
}
}

But I think the conditional here doesn't work for animation events. Maybe it should be moved into _parseRegularEvent. So the conditional for animation event should be added here.

@pullapprove pullapprove bot removed the area: compiler Issues related to `ngc`, Angular's template compiler label Dec 9, 2020
@ngbot ngbot bot removed this from the needsTriage milestone Dec 9, 2020
Copy link
Member

@JoostK JoostK left a comment

Choose a reason for hiding this comment

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

LGTM, just one comment.

expect(() => parse('<div (@event.invalidPhase)></div>'))
.toThrowError(
/The provided animation output phase value "invalidphase" for "@event" is not supported \(use start or done\)/);
expect(() => parse('<div (@event.)></div>'))
Copy link
Member

Choose a reason for hiding this comment

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

Could you add another expect without the period?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I don't understand what the another expect is. Do you mean merge this expect into the last test?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, what I meant was to duplicate this expectation to verify a template which omits the period:

expect(() => parse('<div (@event)></div>'))

Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done.

@JoostK JoostK added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews area: compiler Issues related to `ngc`, Angular's template compiler compiler: parser target: patch This PR is targeted for the next patch release type: bug/fix labels Dec 9, 2020
@ngbot ngbot bot modified the milestone: Backlog Dec 9, 2020
@JoostK JoostK added action: merge The PR is ready for merge by the caretaker action: presubmit The PR is in need of a google3 presubmit and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Dec 10, 2020
@AndrewKushnir
Copy link
Contributor

Presubmit.

@AndrewKushnir AndrewKushnir removed the action: presubmit The PR is in need of a google3 presubmit label Jan 6, 2021
Now when the animation trigger output event is missing its phase value name, the `BoundEvent` will be ignored,
but it's useful for completion in language service.
@atscott atscott added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Jan 7, 2021
@atscott
Copy link
Contributor

atscott commented Jan 7, 2021

FYI - This is merging to master branch only. I'll create a separate PR to merge to 11.0.x

Edit: Because the reason for this PR is to accommodate the language service, I think it's okay to only merge to master which targets the 11.1 release.

@atscott atscott closed this in 15b15be Jan 7, 2021
@ivanwonder
Copy link
Contributor Author

FYI - This is merging to master branch only. I'll create a separate PR to merge to 11.0.x

Edit: Because the reason for this PR is to accommodate the language service, I think it's okay to only merge to master which targets the 11.1 release.

Yes, it's okay to only merge to master.
This is the other PR I try to provide the animation completions.
#40347 #40300

@ivanwonder ivanwonder deleted the recover-event-parse branch January 8, 2021 01:19
@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 Feb 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 compiler: parser target: minor This PR is targeted for the next minor release type: bug/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants