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(ivy): ensure eventListeners added outside angular context are not called #34514

Closed
wants to merge 1 commit into from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Dec 20, 2019

View Engine debug node does not call event listeners added outside the Angular context. This PR updates Ivy to mimic that behavior (not calling those listeners either when using debugElement.triggerEventHandler)

@atscott atscott added area: testing Issues related to Angular testing features, such as TestBed action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release comp: ivy labels Dec 20, 2019
@atscott atscott requested a review from a team as a code owner December 20, 2019 18:35
@ngbot ngbot bot added this to the needsTriage milestone Dec 20, 2019
if (listener.name === getIdentifiableWrappedEventHandlerName()) {
const unwrappedListener = listener(Function);
return invokedListeners.indexOf(unwrappedListener) === -1 &&
unwrappedListener.call(node, eventObj);
Copy link
Contributor

Choose a reason for hiding this comment

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

we use call(node,...) here, should we also use callback.call(node) in

callback(eventObj);
?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I can see, the listeners here are retrieved from the LView and those would have been registered in the components/component templates. I think the this context in those functions would be the component class. I made the change because I think it's more correct but I don't think it ends up having downstream effects.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, I will try to verify it.

packages/core/test/debug/debug_node_spec.ts Outdated Show resolved Hide resolved
packages/core/src/core_private_export.ts Outdated Show resolved Hide resolved
packages/core/test/debug/debug_node_spec.ts Outdated Show resolved Hide resolved
packages/core/src/debug/debug_node.ts Outdated Show resolved Hide resolved
packages/platform-browser/src/dom/dom_renderer.ts Outdated Show resolved Hide resolved
@atscott atscott changed the title fix(ivy): ensure eventListeners added outside angular context are cal… fix(ivy): ensure eventListeners added outside angular context are not called Jan 14, 2020
Copy link
Member

@alxhub alxhub left a comment

Choose a reason for hiding this comment

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

This looks good to me as a solution to the problem we worked on.

I'll defer to Misko, et al. for runtime approval though.

@atscott atscott force-pushed the eventlisteners branch 3 times, most recently from f9f197e to 587a94c Compare January 16, 2020 22:27
@atscott atscott requested a review from a team as a code owner January 16, 2020 22:27
@atscott atscott force-pushed the eventlisteners branch 2 times, most recently from 58d04a3 to 5f5b8aa Compare January 17, 2020 18:53
@atscott
Copy link
Contributor Author

atscott commented Jan 17, 2020

presubmit

@atscott atscott added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jan 21, 2020
@atscott atscott force-pushed the eventlisteners branch 2 times, most recently from c0a9d77 to d0e14b8 Compare January 22, 2020 16:50
@AndrewKushnir AndrewKushnir added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Jan 22, 2020
@AndrewKushnir
Copy link
Contributor

@atscott FYI, it looks like size checks are failing in test_aio_local CircleCI job, so I'm adding "cleanup" label for now.

@atscott atscott removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Jan 22, 2020
… called...

by DebugElement.triggerEventHandler. ZoneJS tracks the eventListeners on
a node but we need to be able to differentiate between those added by
Angular and those that were added outside the Angular context. This fix
aligns with the behavior that was present in View Engine (not calling
those listeners). If we decide later that we want to call those
listeners, we still need a way to differentiate between those that
we have wrapped in dom_renderer and those that were not (because they
were added outside the Angular context).
AndrewKushnir pushed a commit that referenced this pull request Jan 22, 2020
… called... (#34514)

by DebugElement.triggerEventHandler. ZoneJS tracks the eventListeners on
a node but we need to be able to differentiate between those added by
Angular and those that were added outside the Angular context. This fix
aligns with the behavior that was present in View Engine (not calling
those listeners). If we decide later that we want to call those
listeners, we still need a way to differentiate between those that
we have wrapped in dom_renderer and those that were not (because they
were added outside the Angular context).

PR Close #34514
sonukapoor pushed a commit to sonukapoor/angular that referenced this pull request Feb 13, 2020
… called... (angular#34514)

by DebugElement.triggerEventHandler. ZoneJS tracks the eventListeners on
a node but we need to be able to differentiate between those added by
Angular and those that were added outside the Angular context. This fix
aligns with the behavior that was present in View Engine (not calling
those listeners). If we decide later that we want to call those
listeners, we still need a way to differentiate between those that
we have wrapped in dom_renderer and those that were not (because they
were added outside the Angular context).

PR Close angular#34514
@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 22, 2020
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: testing Issues related to Angular testing features, such as TestBed cla: yes target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants