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

fix(core): properly get root nodes from embedded views with <ng-content> #36051

Closed

Conversation

pkozlowski-opensource
Copy link
Member

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

@pkozlowski-opensource pkozlowski-opensource added area: core Issues related to the framework runtime comp: ivy action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Mar 13, 2020
@ngbot ngbot bot modified the milestone: needsTriage Mar 13, 2020
@pkozlowski-opensource pkozlowski-opensource changed the title fix(common): properly get root nodes from embedded views with <ng-content> fix(core): properly get root nodes from embedded views with <ng-content> Mar 21, 2020
@pkozlowski-opensource pkozlowski-opensource marked this pull request as ready for review March 21, 2020 11:29
@pullapprove pullapprove bot requested a review from mhevery March 21, 2020 11:29
Copy link
Contributor

@Shijir Shijir left a comment

Choose a reason for hiding this comment

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

Thank you, @pkozlowski-opensource! This is awesome. Looking forward to its merge.

Copy link
Contributor

@mhevery mhevery left a comment

Choose a reason for hiding this comment

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

just comment nits

const projectionSlots = componentHost.projection;
const slotIdx = tNode.projection as number;

if (projectionSlots !== null && projectionSlots.length > slotIdx) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment explaining this condition.

Copy link
Member Author

Choose a reason for hiding this comment

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

Simplified the code - turns out that most of checks were not necessary (added an assert). This code is gone so things should be easier to reason about.

if (Array.isArray(nodesInSlot)) {
result.push(...nodesInSlot);
} else {
const parentView = getLViewParent(componentView);
Copy link
Contributor

Choose a reason for hiding this comment

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

comments what is going on here would be helpfull.

Copy link
Member Author

Choose a reason for hiding this comment

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

Simplified the code and added an assert that should serve as documentation.

@mhevery mhevery added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 16, 2020
Copy link
Contributor

@mhevery mhevery left a comment

Choose a reason for hiding this comment

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

with nits

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 pkozlowski-opensource added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Apr 20, 2020
Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

LGTM

@kara kara removed the action: review The PR is still awaiting reviews from at least one requested reviewer label May 4, 2020
@kara kara added the action: presubmit The PR is in need of a google3 presubmit label May 4, 2020
@kara
Copy link
Contributor

kara commented May 4, 2020

presubmit

@kara kara added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed action: presubmit The PR is in need of a google3 presubmit labels May 5, 2020
@kara
Copy link
Contributor

kara commented May 5, 2020

merge-assistance: can't remove the pending review

@alxhub alxhub closed this in e30e132 May 5, 2020
alxhub pushed a commit that referenced this pull request 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 pull request 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
action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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