Skip to content

refactor(core): add context support for foreign components#69502

Draft
leonsenft wants to merge 1 commit into
angular:mainfrom
leonsenft:foreign-component-context
Draft

refactor(core): add context support for foreign components#69502
leonsenft wants to merge 1 commit into
angular:mainfrom
leonsenft:foreign-component-context

Conversation

@leonsenft

Copy link
Copy Markdown
Contributor

Enable foreign components to receive and propagate contextual data across framework boundaries.

Previously, foreign render functions only accepted component properties, and foreign content projection instructions (ɵɵforeignContent / ɵɵforeignContentFn) did not provide any mechanism to expose foreign framework context to projected Angular embedded views.

With this change:

  • Update ForeignRenderFn and ForeignComponent interfaces to accept an optional context parameter and an optional GET_CONTEXT symbol method.

  • Introduce FOREIGN_CONTEXT injection token and provideForeignRootContext helper to configure root context in Angular's DI hierarchy.

  • Update ɵɵforeignComponent instruction to resolve FOREIGN_CONTEXT from the injection tree and pass it to the foreign component's render function.

  • Update ɵɵforeignContent and ɵɵforeignContentFn instructions to accept foreignComponentConstIndex and wrap embedded view creation with a ForeignContextInjector when GET_CONTEXT is present.

Furthermore, foreign render functions are no longer run inside an Angular injection context, since it's expected they use the foreign context support directly.

@leonsenft leonsenft added the area: core Issues related to the framework runtime label Jun 24, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jun 24, 2026
@leonsenft leonsenft added area: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Jun 24, 2026
@leonsenft leonsenft force-pushed the foreign-component-context branch from f19dd77 to 7b37e64 Compare June 24, 2026 17:40
Enable foreign components to receive and propagate contextual data
across framework boundaries.

Previously, foreign render functions only accepted component properties,
and foreign content projection instructions (`ɵɵforeignContent` /
`ɵɵforeignContentFn`) did not provide any mechanism to expose foreign
framework context to projected Angular embedded views.

With this change:

- Update `ForeignRenderFn` and `ForeignComponent` interfaces to accept
  an optional context parameter and an optional `GET_CONTEXT` symbol
  method.

- Introduce `FOREIGN_CONTEXT` injection token and
  `provideForeignRootContext` helper to configure root context in
  Angular's DI hierarchy.

- Update `ɵɵforeignComponent` instruction to resolve `FOREIGN_CONTEXT`
  from the injection tree and pass it to the foreign component's render
  function.

- Update `ɵɵforeignContent` and `ɵɵforeignContentFn` instructions to
  accept `foreignComponentConstIndex` and wrap embedded view creation
  with a `ForeignContextInjector` when `GET_CONTEXT` is present.

Furthermore, foreign render functions are no longer run inside an
Angular injection context, since it's expected they use the foreign
context support directly.
@leonsenft leonsenft force-pushed the foreign-component-context branch from 7b37e64 to 3539fba Compare June 24, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: compiler Issues related to `ngc`, Angular's template compiler 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.

1 participant