-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(compiler): Fix order of compound template/element param valu…
…es (#53209) As part of this fix, I realized that child i18n blocks don't need their own context. Instead, we can just add their params directly to the context for their root block, and forgo the step of merging the contexts. PR Close #53209
- Loading branch information
1 parent
44108f2
commit a31f65d
Showing
13 changed files
with
239 additions
and
167 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
69 changes: 69 additions & 0 deletions
69
.../r3_view_compiler_i18n/ng-container_ng-template/structural_directives_same_placeholder.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,69 @@ | ||
function MyComponent_div_2_Template(rf, ctx) { | ||
if (rf & 1) { | ||
i0.ɵɵi18nStart(0, 0, 1); | ||
i0.ɵɵelement(1, "div"); | ||
i0.ɵɵi18nEnd(); | ||
} | ||
} | ||
function MyComponent_div_3_div_2_Template(rf, ctx) { | ||
if (rf & 1) { | ||
i0.ɵɵi18nStart(0, 0, 3); | ||
i0.ɵɵelement(1, "div"); | ||
i0.ɵɵi18nEnd(); | ||
} | ||
} | ||
function MyComponent_div_3_Template(rf, ctx) { | ||
if (rf & 1) { | ||
i0.ɵɵi18nStart(0, 0, 2); | ||
i0.ɵɵelementStart(1, "div"); | ||
i0.ɵɵtemplate(2, MyComponent_div_3_div_2_Template, 2, 0, "div", 1); | ||
i0.ɵɵelementEnd(); | ||
i0.ɵɵi18nEnd(); | ||
} | ||
if (rf & 2) { | ||
const $ctx_r1$ = i0.ɵɵnextContext(); | ||
i0.ɵɵadvance(2); | ||
i0.ɵɵproperty("ngIf", $ctx_r1$.someFlag); | ||
} | ||
} | ||
function MyComponent_img_4_Template(rf, ctx) { | ||
if (rf & 1) { | ||
i0.ɵɵi18nStart(0, 0, 4); | ||
i0.ɵɵelement(1, "img"); | ||
i0.ɵɵi18nEnd(); | ||
} | ||
} | ||
function MyComponent_img_5_Template(rf, ctx) { | ||
if (rf & 1) { | ||
i0.ɵɵi18nStart(0, 0, 5); | ||
i0.ɵɵelement(1, "img"); | ||
i0.ɵɵi18nEnd(); | ||
} | ||
} | ||
… | ||
decls: 6, | ||
vars: 4, | ||
consts: () => { | ||
__i18nMsgWithPostprocess__('{$startTagDiv}Content{$closeTagDiv}{$startTagDiv}{$startTagDiv}Content{$closeTagDiv}{$closeTagDiv}{$tagImg}{$tagImg}', [['closeTagDiv', String.raw`[\uFFFD/#1:1\uFFFD\uFFFD/*2:1\uFFFD|\uFFFD/#1:3\uFFFD\uFFFD/*2:3\uFFFD|\uFFFD/#1:2\uFFFD\uFFFD/*3:2\uFFFD]`], ['startTagDiv', String.raw`[\uFFFD*2:1\uFFFD\uFFFD#1:1\uFFFD|\uFFFD*3:2\uFFFD\uFFFD#1:2\uFFFD|\uFFFD*2:3\uFFFD\uFFFD#1:3\uFFFD]`], ['tagImg', String.raw`[\uFFFD*4:4\uFFFD\uFFFD/*4:4\uFFFD\uFFFD#1:4\uFFFD\uFFFD/#1:4\uFFFD\uFFFD*4:4\uFFFD\uFFFD/*4:4\uFFFD|\uFFFD*5:5\uFFFD\uFFFD/*5:5\uFFFD\uFFFD#1:5\uFFFD\uFFFD/#1:5\uFFFD\uFFFD*5:5\uFFFD\uFFFD/*5:5\uFFFD]`]], {original_code: {closeTagDiv: '</div>', startTagDiv: '<div *ngIf=\"someFlag\">', tagImg: '<img *ngIf=\"someOtherFlag\" />' }}, {}, []) | ||
return [i18n_0, [4, "ngIf"]]; | ||
}, | ||
template: function MyComponent_Template(rf, ctx) { | ||
if (rf & 1) { | ||
i0.ɵɵelementStart(0, "div"); | ||
i0.ɵɵi18nStart(1, 0); | ||
i0.ɵɵtemplate(2, MyComponent_div_2_Template, 2, 0, "div", 1)(3, MyComponent_div_3_Template, 3, 1, "div", 1)(4, MyComponent_img_4_Template, 2, 0, "img", 1)(5, MyComponent_img_5_Template, 2, 0, "img", 1); | ||
i0.ɵɵi18nEnd(); | ||
i0.ɵɵelementEnd(); | ||
} | ||
if (rf & 2) { | ||
i0.ɵɵadvance(2); | ||
i0.ɵɵproperty("ngIf", ctx.someFlag); | ||
i0.ɵɵadvance(1); | ||
i0.ɵɵproperty("ngIf", ctx.someFlag); | ||
i0.ɵɵadvance(1); | ||
i0.ɵɵproperty("ngIf", ctx.someOtherFlag); | ||
i0.ɵɵadvance(1); | ||
i0.ɵɵproperty("ngIf", ctx.someOtherFlag); | ||
} | ||
} | ||
|
22 changes: 22 additions & 0 deletions
22
.../r3_view_compiler_i18n/ng-container_ng-template/structural_directives_same_placeholder.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,22 @@ | ||
import {Component, NgModule} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'my-component', | ||
template: ` | ||
<div i18n> | ||
<div *ngIf="someFlag">Content</div> | ||
<div *ngIf="someFlag"> | ||
<div *ngIf="someFlag">Content</div> | ||
</div> | ||
<img *ngIf="someOtherFlag" /> | ||
<img *ngIf="someOtherFlag" /> | ||
</div> | ||
`, | ||
}) | ||
export class MyComponent { | ||
} | ||
|
||
@NgModule({declarations: [MyComponent]}) | ||
export class MyModule { | ||
} |
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
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
62 changes: 0 additions & 62 deletions
62
packages/compiler/src/template/pipeline/src/phases/merge_i18n_contexts.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.