Conversation
crisbeto
force-pushed
the
30278/$event-access
branch
from
October 18, 2020 15:41
0135583 to
326ea9f
Compare
crisbeto
marked this pull request as ready for review
October 18, 2020 17:23
AndrewKushnir
requested review from
alxhub
and removed request for
AndrewKushnir
October 18, 2020 17:55
alxhub
approved these changes
Oct 29, 2020
…ions Currently expressions `$event.foo()` and `this.$event.foo()`, as well as `$any(foo)` and `this.$any(foo)`, are treated as the same expression by the compiler, because `this` is considered the same implicit receiver as when the receiver is omitted. This introduces the following issues: 1. Any time something called `$any` is used, it'll be stripped away, leaving only the first parameter. 2. If something called `$event` is used anywhere in a template, it'll be preserved as `$event`, rather than being rewritten to `ctx.$event`, causing the value to undefined at runtime. This applies to listener, property and text bindings. These changes resolve the first issue and part of the second one by preserving anything that is accessed through `this`, even if it's one of the "special" ones like `$any` or `$event`. Furthermore, these changes only expose the `$event` global variable inside event listeners, whereas previously it was available everywhere. Fixes angular#30278.
crisbeto
force-pushed
the
30278/$event-access
branch
from
October 29, 2020 20:42
326ea9f to
72e9cae
Compare
ayazhafiz
approved these changes
Oct 29, 2020
ayazhafiz
left a comment
Contributor
There was a problem hiding this comment.
Nice change, LGTM for language service
Member
|
@crisbeto Looks like this breaks codelyzer, so it doesn't land cleanly. While its marked as a fix here, it does modify the type of |
Member
Author
|
@josephperrott I've made the new method optional. Can we give it another try? |
Member
|
Updating to |
josephperrott
pushed a commit
that referenced
this pull request
Oct 30, 2020
…ions (#39323) Currently expressions `$event.foo()` and `this.$event.foo()`, as well as `$any(foo)` and `this.$any(foo)`, are treated as the same expression by the compiler, because `this` is considered the same implicit receiver as when the receiver is omitted. This introduces the following issues: 1. Any time something called `$any` is used, it'll be stripped away, leaving only the first parameter. 2. If something called `$event` is used anywhere in a template, it'll be preserved as `$event`, rather than being rewritten to `ctx.$event`, causing the value to undefined at runtime. This applies to listener, property and text bindings. These changes resolve the first issue and part of the second one by preserving anything that is accessed through `this`, even if it's one of the "special" ones like `$any` or `$event`. Furthermore, these changes only expose the `$event` global variable inside event listeners, whereas previously it was available everywhere. Fixes #30278. PR Close #39323
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently expressions like
$event.foo()andthis.$event.foo(), as well as$any(foo)andthis.$any(foo), are treated as the same expression by the compiler, becausethisis considered the same implicit receiver as when the receiver is omitted. This introduces the following issues:$anyis used, it'll be stripped away, leaving only the first parameter.$eventis used anywhere in a template, it'll be preserved as$event, rather than being rewritten toctx.$event, causing the value to undefined at runtime. This applies to listener, property and text bindings.These changes resolve the first issue and part of the second one by preserving anything that is accessed through
this, even if it's one of the "special" ones like$anyor$event. Furthermore, these changes only expose the$eventglobal variable inside event listeners, whereas previously it was available everywhere.Fixes #30278.