Skip to content

Conversation

@JeanMeche
Copy link
Member

@JeanMeche JeanMeche commented Sep 14, 2024

Before this commit, @let declerations with an array were mistaken for a component in the lView and throwing an unexpected error.

This commit fixes this.

…tion`

Before this commit, `@let` decleration with an array where  mistaken for a component in the lView and throwing an unexpected error.

This commit fixes this.
@angular-robot angular-robot bot added the area: core Issues related to the framework runtime label Sep 14, 2024
@ngbot ngbot bot added this to the Backlog milestone Sep 14, 2024
@JeanMeche JeanMeche changed the title fix(core): Handle @let declaration with array when preparingForHydration fix(core): Handle @let declaration with array in preparingForHydration Sep 14, 2024
@JeanMeche JeanMeche marked this pull request as ready for review September 14, 2024 14:54
@pullapprove pullapprove bot requested a review from atscott September 14, 2024 14:54
ngh[CONTAINERS] ??= {};
ngh[CONTAINERS][noOffsetIndex] = serializeLContainer(lView[i], context);
} else if (Array.isArray(lView[i])) {
} else if (Array.isArray(lView[i]) && (tNode.type & TNodeType.LetDeclaration) === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This fix looks good and we can move it up within this function where we skip a given slot if it doesn't represent a node that requires annotations, i.e. we can extend this condition with an extra check:

    if (!isTNodeShape(tNode)) {
      continue;
    }

to

    if (!isTNodeShape(tNode) || isLetDeclaration(tNode)) {
      continue;
    }

(there is also a comment above this check that would require an update)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure the change you're suggesting is correct. The condition after this else if is handling let declarations specifically.

Copy link
Contributor

Choose a reason for hiding this comment

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

@JeanMeche thanks for additional info. The fix looks good, but we should probably look into that a bit more to make sure that we don't generate an extra annotations for nodes that follow @let, e.g. for this situation we do not want to generate extra info in nghData for <div>:

@let name = 'Andrew';
<div>Hi {{ name }}!</div>

I believe the code in the else if block that you've mentioned would add extra annotation.

If you get a chance, could you please compare what we have in the nghData object for the mentioned template vs when @let is not present?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is an extra entry in the NODES when there is a @let declared. But it looks like they are required (not having them breaks hydration in our unit tests). Maybe @crisbeto can chime in on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

According to the current logic they are required, but we can update the logic within the locateNextRNode function to skip over LetDeclaration TNodes instead, so adding extra paths to the NODES set would not be required (+ also doing extra DOM "walks" to find those elements). Note: no need to block this PR, we can explore this more as a followup.

@AndrewKushnir AndrewKushnir added target: patch This PR is targeted for the next patch release action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Sep 14, 2024
@AndrewKushnir AndrewKushnir removed the request for review from atscott September 14, 2024 16:50
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

LGTM for this fix and let's take a look at #57816 (comment) as a followup.

@AndrewKushnir AndrewKushnir added action: presubmit The PR is in need of a google3 presubmit 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 Sep 14, 2024
@AndrewKushnir
Copy link
Contributor

Presubmit.

@AndrewKushnir
Copy link
Contributor

Caretaker note: presubmit failures are unrelated to this change, this PR is ready for merge.

@AndrewKushnir AndrewKushnir 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 Sep 16, 2024
@ngbot
Copy link

ngbot bot commented Sep 16, 2024

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "google-internal-tests" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken main, please try rebasing to main and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@pkozlowski-opensource
Copy link
Member

This PR was merged into the repository by commit 4231e8f.

The changes were merged into the following branches: main, 18.2.x

@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 Oct 18, 2024
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 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.

4 participants