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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Ivy, accessing rootNodes results in throwing error when its embedded view has a hole #35967

Closed
Shijir opened this issue Mar 9, 2020 · 2 comments
Labels
area: core Issues related to the framework runtime core: content projection core: dynamic view creation freq2: medium hotlist: devrel regression Indicates than the issue relates to something that worked in a previous version type: bug/fix
Milestone

Comments

@Shijir
Copy link
Contributor

Shijir commented Mar 9, 2020

🐞 bug report

Angular v9.0.3

Is this a regression?

Possibly. This used to work fine with ViewEngine.

Description

I have this component which I dynamically create and provide its projected nodes. But these projected nodes are placed inside a ng-template which I would use to create an embedded view. However, after creating the embedded view, I am no longer could access its rootNodes as it's throwing the following error:

ERROR Error: ASSERTION ERROR: Should be one of Element, Container, Projection, ElementContainer, IcuContainer but got <unknown> [Expected=> true == false <=Actual]

This is the minimal reproduction of the dynamic component:

@Component({
  selector: 'dynamic-portal',
  template: `<ng-template #portal><ng-content></ng-content></ng-template>`,
})
export class DynamicPortal implements AfterViewInit {
  @ViewChild('portal') templateRef: TemplateRef<void>;
  view: EmbeddedViewRef<void>;

  ngAfterViewInit() {
    this.view = this.templateRef.createEmbeddedView();
    // Simply trying to access the view's rootNodes would throw an error
    console.log(this.view.rootNodes);
  }
}

🔬 Minimal Reproduction

https://stackblitz.com/...

🔥 Exception or Error


ERROR Error: ASSERTION ERROR: Should be one of Element, Container, Projection, ElementContainer, IcuContainer but got  [Expected=> true == false <=Actual]

🌍 Your Environment

Angular Version:


Angular v9.0.3
Node v12.15.0

Anything else relevant?

@Shijir Shijir changed the title In Ivy, accessing rootNodes is crushing with its embedded view has a hole In Ivy, accessing rootNodes results in throwing error when its embedded view has a hole Mar 9, 2020
@pkozlowski-opensource
Copy link
Member

I can confirm that this is a bug, minimal repo: https://ng-run.com/edit/DO0ZNKuNJH3iSck6BgyW

@ngbot ngbot bot modified the milestone: needsTriage Mar 9, 2020
@pkozlowski-opensource pkozlowski-opensource added the regression Indicates than the issue relates to something that worked in a previous version label Mar 9, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Mar 12, 2020
pkozlowski-opensource added a commit to pkozlowski-opensource/angular that referenced this issue Mar 13, 2020
…tent>

This commit fixes 2 separate issues related to root nodes retrieval from
embedded views with `<ng-content>`:

1) we did not account for the case where there were no projectable nodes
for a given `<ng-content>`;

2) we did not account for the case where projectable nodes for a given
`<ng-content>` were represented as an array of native nodes (happens in
the case of dynamically created components with projectable nodes);

Fixes angular#35967
pkozlowski-opensource added a commit to pkozlowski-opensource/angular that referenced this issue Mar 13, 2020
…tent>

This commit fixes 2 separate issues related to root nodes retrieval from
embedded views with `<ng-content>`:

1) we did not account for the case where there were no projectable nodes
for a given `<ng-content>`;

2) we did not account for the case where projectable nodes for a given
`<ng-content>` were represented as an array of native nodes (happens in
the case of dynamically created components with projectable nodes);

Fixes angular#35967
pkozlowski-opensource added a commit to pkozlowski-opensource/angular that referenced this issue Mar 21, 2020
…tent>

This commit fixes 2 separate issues related to root nodes retrieval from
embedded views with `<ng-content>`:

1) we did not account for the case where there were no projectable nodes
for a given `<ng-content>`;

2) we did not account for the case where projectable nodes for a given
`<ng-content>` were represented as an array of native nodes (happens in
the case of dynamically created components with projectable nodes);

Fixes angular#35967
pkozlowski-opensource added a commit to pkozlowski-opensource/angular that referenced this issue Mar 21, 2020
…tent>

This commit fixes 2 separate issues related to root nodes retrieval from
embedded views with `<ng-content>`:

1) we did not account for the case where there were no projectable nodes
for a given `<ng-content>`;

2) we did not account for the case where projectable nodes for a given
`<ng-content>` were represented as an array of native nodes (happens in
the case of dynamically created components with projectable nodes);

Fixes angular#35967
pkozlowski-opensource added a commit to pkozlowski-opensource/angular that referenced this issue Mar 21, 2020
This commit fixes 2 separate issues related to root nodes retrieval from
embedded views with `<ng-content>`:

1) we did not account for the case where there were no projectable nodes
for a given `<ng-content>`;

2) we did not account for the case where projectable nodes for a given
`<ng-content>` were represented as an array of native nodes (happens in
the case of dynamically created components with projectable nodes);

Fixes angular#35967
pkozlowski-opensource added a commit to pkozlowski-opensource/angular that referenced this issue Apr 16, 2020
This commit fixes 2 separate issues related to root nodes retrieval from
embedded views with `<ng-content>`:

1) we did not account for the case where there were no projectable nodes
for a given `<ng-content>`;

2) we did not account for the case where projectable nodes for a given
`<ng-content>` were represented as an array of native nodes (happens in
the case of dynamically created components with projectable nodes);

Fixes angular#35967
pkozlowski-opensource added a commit to pkozlowski-opensource/angular that referenced this issue Apr 16, 2020
This commit fixes 2 separate issues related to root nodes retrieval from
embedded views with `<ng-content>`:

1) we did not account for the case where there were no projectable nodes
for a given `<ng-content>`;

2) we did not account for the case where projectable nodes for a given
`<ng-content>` were represented as an array of native nodes (happens in
the case of dynamically created components with projectable nodes);

Fixes angular#35967
pkozlowski-opensource added a commit to pkozlowski-opensource/angular that referenced this issue Apr 20, 2020
This commit fixes 2 separate issues related to root nodes retrieval from
embedded views with `<ng-content>`:

1) we did not account for the case where there were no projectable nodes
for a given `<ng-content>`;

2) we did not account for the case where projectable nodes for a given
`<ng-content>` were represented as an array of native nodes (happens in
the case of dynamically created components with projectable nodes);

Fixes angular#35967
pkozlowski-opensource added a commit to pkozlowski-opensource/angular that referenced this issue Apr 20, 2020
This commit fixes 2 separate issues related to root nodes retrieval from
embedded views with `<ng-content>`:

1) we did not account for the case where there were no projectable nodes
for a given `<ng-content>`;

2) we did not account for the case where projectable nodes for a given
`<ng-content>` were represented as an array of native nodes (happens in
the case of dynamically created components with projectable nodes);

Fixes angular#35967
pkozlowski-opensource added a commit to pkozlowski-opensource/angular that referenced this issue Apr 20, 2020
This commit fixes 2 separate issues related to root nodes retrieval from
embedded views with `<ng-content>`:

1) we did not account for the case where there were no projectable nodes
for a given `<ng-content>`;

2) we did not account for the case where projectable nodes for a given
`<ng-content>` were represented as an array of native nodes (happens in
the case of dynamically created components with projectable nodes);

Fixes angular#35967
@alxhub alxhub closed this as completed in e30e132 May 5, 2020
alxhub pushed a commit that referenced this issue May 5, 2020
…nt> (#36051)

This commit fixes 2 separate issues related to root nodes retrieval from
embedded views with `<ng-content>`:

1) we did not account for the case where there were no projectable nodes
for a given `<ng-content>`;

2) we did not account for the case where projectable nodes for a given
`<ng-content>` were represented as an array of native nodes (happens in
the case of dynamically created components with projectable nodes);

Fixes #35967

PR Close #36051
@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 Jun 5, 2020
profanis pushed a commit to profanis/angular that referenced this issue Sep 5, 2020
…nt> (angular#36051)

This commit fixes 2 separate issues related to root nodes retrieval from
embedded views with `<ng-content>`:

1) we did not account for the case where there were no projectable nodes
for a given `<ng-content>`;

2) we did not account for the case where projectable nodes for a given
`<ng-content>` were represented as an array of native nodes (happens in
the case of dynamically created components with projectable nodes);

Fixes angular#35967

PR Close angular#36051
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime core: content projection core: dynamic view creation freq2: medium hotlist: devrel regression Indicates than the issue relates to something that worked in a previous version type: bug/fix
Projects
None yet
4 participants