fix(angular): use regex-based else-if pattern matching to match Angular's ELSE_IF_PATTERN#36
Merged
Brooooooklyn merged 1 commit intomainfrom Feb 24, 2026
Conversation
…ar's ELSE_IF_PATTERN
Angular uses the regex `/^else[^\S\r\n]+if/` to detect "else if" connected
blocks, which means block names like "else ifx" also match as chained
else-if branches. Our parser was using exact string matching ("else if"),
causing names like "else ifx" to fall through to the default BlockType::If
and emit two independent conditionals instead of a single chained one.
Fix by reusing `is_else_if_pattern()` (made public) in the parser's block
type classification, matching Angular's regex-based connected-block detection.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
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.

Angular uses the regex
/^else[^\S\r\n]+if/to detect "else if" connectedblocks, which means block names like "else ifx" also match as chained
else-if branches. Our parser was using exact string matching ("else if"),
causing names like "else ifx" to fall through to the default BlockType::If
and emit two independent conditionals instead of a single chained one.
Fix by reusing
is_else_if_pattern()(made public) in the parser's blocktype classification, matching Angular's regex-based connected-block detection.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com
Note
Low Risk
Small, well-scoped change to control-flow block classification with a targeted regression test; low risk outside of slight behavior changes for unusual
@else …block names.Overview
Aligns
@else ifconnected-block detection with Angular by switching from exact string matching ("else if") to regex-equivalent prefix matching viais_else_if_pattern()when classifying block types.Exports
is_else_if_pattern()fromcontrol_flow.rsfor reuse in the HTML parser and adds a regression test ensuring inputs like@else ifx (...)are still chained as anElseIfbranch (mirroring Angular behavior).Written by Cursor Bugbot for commit 5c4bf54. This will update automatically on new commits. Configure here.