fix(migrations): correctly detect then/else keywords in control f…#69918
Open
surajy93 wants to merge 1 commit into
Open
fix(migrations): correctly detect then/else keywords in control f…#69918surajy93 wants to merge 1 commit into
then/else keywords in control f…#69918surajy93 wants to merge 1 commit into
Conversation
surajy93
force-pushed
the
fix-control-flow-migration-then-else-prefix
branch
from
July 23, 2026 18:57
7a398ff to
deea4ca
Compare
JeanMeche
reviewed
Jul 23, 2026
JeanMeche
left a comment
Member
There was a problem hiding this comment.
AGENT: I have left a suggestion for your consideration regarding template reference variables that include $.
surajy93
force-pushed
the
fix-control-flow-migration-then-else-prefix
branch
from
July 23, 2026 21:14
deea4ca to
7a464ec
Compare
…low migration The control flow migration determines whether an `*ngIf` uses a `then` and/or `else` clause by regex matching the raw microsyntax string for the literal keywords `then`/`else`. The regexes only checked that the keyword was preceded by a non-word character, but not that it was followed by one. As a result, a template reference name that merely starts with `then` (e.g. `else thenBlock`) or `else` was misidentified as the `then`/`else` keyword itself. This caused the migration to take the wrong code path (e.g. then+else instead of else-only), which in turn made `getTemplateName()` compute a `slice(start, end)` with `start > end`, producing an empty template name. That empty placeholder was never resolved and was silently emitted as an invalid `<ng-template [ngTemplateOutlet]=""></ng-template>`, dropping the original template content without any warning. Add a negative lookahead `(?![\w\d])` to both regexes so `then`/`else` are only matched as whole keywords, not as a prefix of a longer template reference name. Fixes angular#69914
surajy93
force-pushed
the
fix-control-flow-migration-then-else-prefix
branch
from
July 23, 2026 21:30
7a464ec to
a255135
Compare
JeanMeche
approved these changes
Jul 23, 2026
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.
…low migration
The control flow migration determines whether an
*ngIfuses athenand/orelseclause by regex matching the raw microsyntax string for the literal keywordsthen/else. The regexes only checked that the keyword was preceded by a non-word character, but not that it was followed by one.As a result, a template reference name that merely starts with
then(e.g.else thenBlock) orelsewas misidentified as thethen/elsekeyword itself. This caused the migration to take the wrong code path (e.g. then+else instead of else-only), which in turn madegetTemplateName()compute aslice(start, end)withstart > end, producing an empty template name. That empty placeholder was never resolved and was silently emitted as an invalid<ng-template [ngTemplateOutlet]=""></ng-template>, dropping the original template content without any warning.Add a negative lookahead
(?![\w\d])to both regexes sothen/elseare only matched as whole keywords, not as a prefix of a longer template reference name.Fixes #69914
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?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information