-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Conversation
e26bbec
to
12f12ff
Compare
expect(() => parse('<div (@)></div>')) | ||
.toThrowError(/Animation event name is missing in binding/); |
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 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) { |
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 don't think you need this outer conditional anymore.
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.
angular/packages/compiler/src/template_parser/binding_parser.ts
Lines 418 to 432 in 12f12ff
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.
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.
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>')) |
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.
Could you add another expect without the period?
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.
Sorry, I don't understand what the another expect is. Do you mean merge this expect into the last test?
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.
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?
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.
Thanks, done.
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.
a39d456
to
a524047
Compare
FYI - This is merging to 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 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. |
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?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information