refactor(core): expose host ref in DirectiveFixture by crisbeto · Pull Request #70578 · angular/angular · GitHub
Skip to content

refactor(core): expose host ref in DirectiveFixture - #70578

Open
crisbeto wants to merge 1 commit into
angular:mainfrom
crisbeto:host-ref
Open

refactor(core): expose host ref in DirectiveFixture#70578
crisbeto wants to merge 1 commit into
angular:mainfrom
crisbeto:host-ref

Conversation

@crisbeto

@crisbeto crisbeto commented Sep 5, 2026

Copy link
Copy Markdown
Member

Exposes the host component ref in the DirectiveFixture so consumers can access things like onDestroy. This is something we need for test harnesses in the CDK.

@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release labels Sep 5, 2026
@pullapprove
pullapprove Bot requested review from atscott and kirjs September 5, 2026 07:10
@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label Sep 5, 2026
@ngbot ngbot Bot added this to the Backlog milestone Sep 5, 2026
Exposes the host component ref in the `DirectiveFixture` so consumers can access things like `onDestroy`. This is something we need for test harnesses in the CDK.

@JeanMeche JeanMeche Sep 5, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't it a bit weird that we get a ComponentRef in a DirectiveFixture ? There might not be a component at all (when applied on a regular element)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah it's the reason why I didn't get expose it initially. Another option can be to just expose onDestroy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we maybe add some tests around hostRef ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants