Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): ng-template directive invoke twice at the root of cont…
…rol flow (#52515) Discovered this while validating #52414 against Angular Material. We were projecting `<ng-template>` nodes at the root of `@if` and `@for` with the `ng-template` tag name which enables directive matching and applies the directive to the control flow node. These changes fix the issue by never passing along the `ng-template` tag name. PR Close #52515
- Loading branch information
Showing
10 changed files
with
240 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
12 changes: 12 additions & 0 deletions
12
...er-cli/test/compliance/test_cases/r3_view_compiler_control_flow/for_template_root_node.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({ | ||
template: ` | ||
@for (item of items; track item) { | ||
<ng-template foo="1" bar="2">{{item}}</ng-template> | ||
} | ||
`, | ||
}) | ||
export class MyApp { | ||
items = [1, 2, 3]; | ||
} |
3 changes: 3 additions & 0 deletions
3
...st/compliance/test_cases/r3_view_compiler_control_flow/for_template_root_node_template.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
consts: [["foo", "1", "bar", "2"]] | ||
… | ||
$r3$.ɵɵrepeaterCreate(0, MyApp_For_1_Template, 1, 0, null, 0, i0.ɵɵrepeaterTrackByIdentity); |
12 changes: 12 additions & 0 deletions
12
...ler-cli/test/compliance/test_cases/r3_view_compiler_control_flow/if_template_root_node.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({ | ||
template: ` | ||
@if (expr) { | ||
<ng-template foo="1" bar="2">{{expr}}</ng-template> | ||
} | ||
`, | ||
}) | ||
export class MyApp { | ||
expr = true; | ||
} |
3 changes: 3 additions & 0 deletions
3
...est/compliance/test_cases/r3_view_compiler_control_flow/if_template_root_node_template.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
consts: [["foo", "1", "bar", "2"]] | ||
… | ||
$r3$.ɵɵtemplate(0, MyApp_Conditional_0_Template, 1, 0, null, 0); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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