Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Patch port] fix(core): resolve forward-referenced host directives during directive matching #58500

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

Closed
wants to merge 1 commit into from

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Nov 4, 2024

Note: this is a patch port of #58492.

When the compiler generates the HostDirectivesFeature, it generates either an eager call (ɵɵHostDirectivesFeature([])) or a lazy call (ɵɵHostDirectivesFeature(() => []). The lazy call is necessary when there are forward references within the hostDirectives array. Currently we resolve the lazy variant when the component definition is created which has been enough for most cases, however if the host is injected by one of its host directives, we can run into a reference error because DI is synchronous and the host's class hasn't been defined yet.

These changes resolve the issue by pushing the lazy resolution later during directive matching when all classes are guanrateed to exist.

Fixes #58485.

…e matching (angular#58492)

When the compiler generates the `HostDirectivesFeature`, it generates either an eager call (`ɵɵHostDirectivesFeature([])`) or a lazy call (`ɵɵHostDirectivesFeature(() => [])`. The lazy call is necessary when there are forward references within the `hostDirectives` array. Currently we resolve the lazy variant when the component definition is created which has been enough for most cases, however if the host is injected by one of its host directives, we can run into a reference error because DI is synchronous and the host's class hasn't been defined yet.

These changes resolve the issue by pushing the lazy resolution later during directive matching when all classes are guanrateed to exist.

Fixes angular#58485.

PR Close angular#58492
@crisbeto crisbeto added the target: patch This PR is targeted for the next patch release label Nov 4, 2024
@angular-robot angular-robot bot added the area: core Issues related to the framework runtime label Nov 4, 2024
@ngbot ngbot bot added this to the Backlog milestone Nov 4, 2024
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker PullApprove: disable labels Nov 4, 2024
@crisbeto crisbeto marked this pull request as ready for review November 4, 2024 15:50
@crisbeto
Copy link
Member Author

crisbeto commented Nov 4, 2024

I'm disabling PullApprove, because this is just a cherry-pick of #58492.

@pkozlowski-opensource
Copy link
Member

This PR was merged into the repository by commit 3aa45a2.

The changes were merged into the following branches: 18.2.x

pkozlowski-opensource pushed a commit that referenced this pull request Nov 4, 2024
…e matching (#58492) (#58500)

When the compiler generates the `HostDirectivesFeature`, it generates either an eager call (`ɵɵHostDirectivesFeature([])`) or a lazy call (`ɵɵHostDirectivesFeature(() => [])`. The lazy call is necessary when there are forward references within the `hostDirectives` array. Currently we resolve the lazy variant when the component definition is created which has been enough for most cases, however if the host is injected by one of its host directives, we can run into a reference error because DI is synchronous and the host's class hasn't been defined yet.

These changes resolve the issue by pushing the lazy resolution later during directive matching when all classes are guanrateed to exist.

Fixes #58485.

PR Close #58492

PR Close #58500
@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 Dec 5, 2024
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: core Issues related to the framework runtime PullApprove: disable target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants