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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Child custom element's OnInit hook is called before parent's one #28265

Open
artaommahe opened this issue Jan 20, 2019 · 1 comment
Open

Child custom element's OnInit hook is called before parent's one #28265

artaommahe opened this issue Jan 20, 2019 · 1 comment
Labels
area: core Issues related to the framework runtime area: elements Issues related to Angular Elements core: lifecycle hooks P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent state: confirmed
Milestone

Comments

@artaommahe
Copy link
Contributor

artaommahe commented Jan 20, 2019

馃悶 bug report

Affected Package

The issue is caused by package @angular/elements

Is this a regression?

Dunno

Description

Wrong OnInit hooks call order when custom elements (parent + child) are added with some delay after (regular) angular component inited.

馃敩 Minimal Reproduction

https://stackblitz.com/edit/angular-elements-init-order?file=app%2Fapp.component.html

  1. on toggle
> child OnInit
> parent OnInit
  1. same wrong order on replacing *ngIf="visible" with *ngIf="true"
  2. same wrong order on uncommenting window.setTimeout with innerHTML usage in AppComponent's OnInit hook
  3. correct order on removing <ng-container *ngIf="visible">
> parent OnInit
> child OnInit

馃實 Your Environment

Angular Version:
7.1.4

Anything else relevant?

No such issue with native custom elements and setTimeout + innerHTML usage
https://stackblitz.com/edit/custom-elements-init-order?file=index.ts

> parent connected
> child connected

Real word use-case: adding unknown markup with custom elements from api response.

@AndrewKushnir AndrewKushnir added the area: elements Issues related to Angular Elements label Jan 20, 2019
@ngbot ngbot bot added this to the needsTriage milestone Jan 20, 2019
@gkalpak
Copy link
Member

gkalpak commented Jun 2, 2020

This is still an issue in v9: Updated StackBlitz
It is strange that this only happens with <ng-container *ngIf="..."> (we need both ng-container and ngIf). (I will also add the comp: core label, because I am not sure this can be fixed purely in @angular/elements.)

@gkalpak gkalpak added area: core Issues related to the framework runtime state: needs more investigation triage #1 labels Jun 2, 2020
@jelbourn jelbourn added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Oct 19, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues related to the framework runtime area: elements Issues related to Angular Elements core: lifecycle hooks P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent state: confirmed
Projects
None yet
Development

No branches or pull requests

5 participants