Commit 7828f59
fix(angular): use regex-based else-if pattern matching to match Angular's ELSE_IF_PATTERN (#36)
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>1 parent 9feb2a8 commit 7828f59
3 files changed
Lines changed: 27 additions & 3 deletions
File tree
- crates/oxc_angular_compiler
- src
- parser/html
- transform
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
1501 | 1502 | | |
1502 | 1503 | | |
1503 | 1504 | | |
1504 | | - | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
1505 | 1510 | | |
1506 | 1511 | | |
1507 | 1512 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1070 | 1070 | | |
1071 | 1071 | | |
1072 | 1072 | | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
1073 | 1088 | | |
1074 | 1089 | | |
1075 | 1090 | | |
| |||
0 commit comments