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(upgrade): upgrade Directive facade should not return different instance from constructor #27660

Closed
wants to merge 3 commits into from

Conversation

petebacondarwin
Copy link
Member

@petebacondarwin petebacondarwin commented Dec 13, 2018

In ngUpgrade (dynamic) we create a dynamic Angular Directive that wraps AngularJS components
that are being upgraded. The constructor of this Directive class returns a different instance
than this. It is this instance that actually contains the life-cycle hook handlers.

This would break in ivy, since the methods on the prototype of the original class are wired up,
rather than the instance methods. This results in hooks like ngOnInit not being called.

This PR refactors the code to extend the inner class that was being returned so that the
prototype chain is correct for both ViewEngine and ivy.

This change resolves a number of failing ivy tests, but also exposes other failures that were
masked by this issue. The tests have been updated accordingly.

@mary-poppins
Copy link

You can preview 1ef6aa4 at https://pr27660-1ef6aa4.ngbuilds.io/.

@mary-poppins
Copy link

You can preview c096bf7 at https://pr27660-c096bf7.ngbuilds.io/.

@mary-poppins
Copy link

You can preview b809816 at https://pr27660-b809816.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 4a1e843 at https://pr27660-4a1e843.ngbuilds.io/.

@petebacondarwin petebacondarwin changed the title test(upgrade): fix FW-812 (WIP) fix(upgrade): upgrade Directive facade should not return different instance from constructor Dec 14, 2018
Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

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

🎉

The changes here clarify that we now have a better description
of the root cause of the failure.
…stance from constructor

In ngUpgrade (dynamic) we create a dynamic Angular `Directive` that wraps AngularJS components
that are being upgraded. The constructor of this `Directive` class returns a different instance
than `this`. It is this instance that actually contains the life-cycle hook handlers.

This would break in ivy, since the methods on the prototype of the original class are wired up,
rather than the instance methods. This results in hooks like `ngOnInit` not being called.

This commit refactors the code to extend the inner class that was being returned so that the
prototype chain is correct for both ViewEngine and ivy.

This change resolves a number of failing ivy tests, but also exposes other failures that were
masked by this issue. The tests have been updated accordingly.

(FW-812)
@mary-poppins
Copy link

You can preview 9cb16e0 at https://pr27660-9cb16e0.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 0ba061f at https://pr27660-0ba061f.ngbuilds.io/.

@mary-poppins
Copy link

You can preview 1f7c9bf at https://pr27660-1f7c9bf.ngbuilds.io/.

@mhevery mhevery added the action: merge The PR is ready for merge by the caretaker label Dec 17, 2018
@mhevery
Copy link
Contributor

mhevery commented Dec 17, 2018

@mhevery mhevery closed this in 3444aee Dec 17, 2018
mhevery pushed a commit that referenced this pull request Dec 17, 2018
…stance from constructor (#27660)

In ngUpgrade (dynamic) we create a dynamic Angular `Directive` that wraps AngularJS components
that are being upgraded. The constructor of this `Directive` class returns a different instance
than `this`. It is this instance that actually contains the life-cycle hook handlers.

This would break in ivy, since the methods on the prototype of the original class are wired up,
rather than the instance methods. This results in hooks like `ngOnInit` not being called.

This commit refactors the code to extend the inner class that was being returned so that the
prototype chain is correct for both ViewEngine and ivy.

This change resolves a number of failing ivy tests, but also exposes other failures that were
masked by this issue. The tests have been updated accordingly.

(FW-812)

PR Close #27660
@petebacondarwin petebacondarwin deleted the fw-812 branch December 18, 2018 13:55
ngfelixl pushed a commit to ngfelixl/angular that referenced this pull request Jan 28, 2019
The changes here clarify that we now have a better description
of the root cause of the failure.

PR Close angular#27660
ngfelixl pushed a commit to ngfelixl/angular that referenced this pull request Jan 28, 2019
…stance from constructor (angular#27660)

In ngUpgrade (dynamic) we create a dynamic Angular `Directive` that wraps AngularJS components
that are being upgraded. The constructor of this `Directive` class returns a different instance
than `this`. It is this instance that actually contains the life-cycle hook handlers.

This would break in ivy, since the methods on the prototype of the original class are wired up,
rather than the instance methods. This results in hooks like `ngOnInit` not being called.

This commit refactors the code to extend the inner class that was being returned so that the
prototype chain is correct for both ViewEngine and ivy.

This change resolves a number of failing ivy tests, but also exposes other failures that were
masked by this issue. The tests have been updated accordingly.

(FW-812)

PR Close angular#27660
@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 14, 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 freq1: low risk: low 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.

5 participants