Skip to content

refactor: don't depend on @Inject for _MatMenuBase DI #15975

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

Merged
merged 1 commit into from
May 10, 2019

Conversation

alxhub
Copy link
Member

@alxhub alxhub commented May 7, 2019

In Ivy, undecorated base classes (like _MatMenuBase) don't have the same
behavior as View Engine; specifically, inheriting the constructor from the
base class will not work in the DI system. Even in View Engine this was
often counter-intuitive - only constructors with DI decorators would be
properly inherited in JIT.

This commit updates _MatMenuBase to not rely on this implementation detail
of Angular, and instead moves the injected constructor onto _MatMenu itself.

Fixes #15937

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 7, 2019
@alxhub alxhub force-pushed the ivy/mat-menu-di branch from 0dba8db to 33b5d8c Compare May 7, 2019 21:02
In Ivy, undecorated base classes (like _MatMenuBase) don't have the same
behavior as View Engine; specifically, inheriting the constructor from the
base class will not work in the DI system. Even in View Engine this was
often counter-intuitive - only constructors with DI decorators would be
properly inherited in JIT.

This commit updates _MatMenuBase to not rely on this implementation detail
of Angular, and instead moves the injected constructor onto _MatMenu itself.
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful pr: lgtm action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels May 7, 2019
Copy link
Member

@devversion devversion left a comment

Choose a reason for hiding this comment

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

LGTM.

devversion added a commit to devversion/material2 that referenced this pull request May 8, 2019
With Ivy, directives or components no longer properly inherit
a constructor from a parent base class which is undecorated.

See more details here: FW-1238

In order to avoid dependency injection issues with Ivy, a new
custom TSLint rule reports a failure when a directive/component
uses dependency injection in a way that breaks with Ivy.

Related to angular#15975
devversion added a commit to devversion/material2 that referenced this pull request May 8, 2019
With Ivy, directives or components no longer properly inherit
a constructor from a parent base class which is undecorated.

See more details here: FW-1238

In order to avoid dependency injection issues with Ivy, a new
custom TSLint rule reports a failure when a directive/component
uses dependency injection in a way that breaks with Ivy.

Related to angular#15975
@JoostK
Copy link
Member

JoostK commented May 9, 2019

The MDC based impl needs the same fix, as I'm a hitting a failure after rebasing ivy-2019.

I'm putting the fix in in the ivy-2019 branch manually now, if it's possible to also get the change in here that would be awesome :)

@jelbourn jelbourn merged commit 10c546c into angular:master May 10, 2019
jelbourn pushed a commit that referenced this pull request May 10, 2019
With Ivy, directives or components no longer properly inherit
a constructor from a parent base class which is undecorated.

See more details here: FW-1238

In order to avoid dependency injection issues with Ivy, a new
custom TSLint rule reports a failure when a directive/component
uses dependency injection in a way that breaks with Ivy.

Related to #15975
RudolfFrederiksen pushed a commit to RudolfFrederiksen/material2 that referenced this pull request Jun 21, 2019
In Ivy, undecorated base classes (like _MatMenuBase) don't have the same
behavior as View Engine; specifically, inheriting the constructor from the
base class will not work in the DI system. Even in View Engine this was
often counter-intuitive - only constructors with DI decorators would be
properly inherited in JIT.

This commit updates _MatMenuBase to not rely on this implementation detail
of Angular, and instead moves the injected constructor onto _MatMenu itself.
RudolfFrederiksen pushed a commit to RudolfFrederiksen/material2 that referenced this pull request Jun 21, 2019
With Ivy, directives or components no longer properly inherit
a constructor from a parent base class which is undecorated.

See more details here: FW-1238

In order to avoid dependency injection issues with Ivy, a new
custom TSLint rule reports a failure when a directive/component
uses dependency injection in a way that breaks with Ivy.

Related to angular#15975
@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 10, 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 PR author has agreed to Google's Contributor License Agreement P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mat-Menu error in IVY
5 participants