Repository navigation
fix(compiler): check @defer blocks in the control flow content projection diagnostic - #71398
Open
aminesbdev wants to merge 1 commit into
Open
aminesbdev wants to merge 1 commit into
aminesbdev wants to merge 1 commit into
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
…ection diagnostic The content of a `@defer` block is always projected into the default slot, because the block doesn't copy the tag name and attributes of its root node like `@if`, `@for`, `@switch` and `@boundary` do. The `controlFlowPreventingContentProjection` diagnostic (NG8011) didn't look at `@defer` blocks, so a node matching a specific `ng-content` selector ended up in the default slot, or wasn't rendered, without any warning. The diagnostic now reports the root nodes of `@defer` blocks, including their `@placeholder`, `@loading` and `@error` blocks, even when there is a single root node. The message points to `ngProjectAs`, since keeping a single root node doesn't help for `@defer` blocks. Fixes angular#71397
aminesbdev
force-pushed
the
fix/compiler-ng8011-defer
branch
from
October 16, 2026 17:09
3daab79 to
4b3c07c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
The content of a
@deferblock always goes to the defaultng-contentslot, because the block doesn't copy the tag name and attributes of its root node (#58110, tracked in #64504). NG8011 doesn't check@deferblocks, so this happens without any warning:<h2 card-title>is projected into the default slot instead of[card-title], or not rendered if the component has no default slot.Issue Number: Fixes #71397
What is the new behavior?
TcbControlFlowContentProjectionOpalso goes through the@deferblocks of the element, including their@placeholder,@loadingand@errorblocks, and reports each root node that matches a specific slot. Unlike the other blocks, a single root node is reported too, since it isn't projected either.The suggestions in the existing message (keep a single root node) don't apply here, so the out-of-band recorder gets a separate
deferredBlockPreventingContentProjectionmethod. It uses the same error code and the samecontrolFlowPreventingContentProjectionoption, and points tongProjectAs:I added four tests: the main block, the secondary blocks, content that only matches the catch-all slot, and the
ngProjectAsworkaround. The two that expect a diagnostic fail without the change. Like the other specs of this diagnostic, they're listed inngp_known_failures.ts.Does this PR introduce a breaking change?
Other information
The generated code doesn't change. The new warning only shows up for a
@deferblock placed directly inside a component withng-contentselectors, when one of its root nodes matches a specific selector. That node is already in the wrong slot today, so each warning points to a real bug, but it can be new on code that compiles cleanly now. If that's a problem for the internal rollout, I can retarget the PR.🤖 Generated with Claude Code