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 i18n placeholders for slef-closing elements (#…
…52195) Fixes handling of placeholders for self-closing tags. Self-closing tags set a combined value for the start tag placeholder, rather than separate values for the start and close placeholders. This commit also enables a number of now passing tests. For some of these tests I had create a separate golden file due to the different ordering of the const array. In the template pipeline, i18n and attribute const collection happen in different pahses and we therefore get a different order than TemplateDefinitionBuilder, which collected everything in one pass. The order should not affect the overall behavior. PR Close #52195
- Loading branch information
1 parent
fb487ea
commit 9f4927e
Showing
8 changed files
with
108 additions
and
28 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
27 changes: 27 additions & 0 deletions
27
...e/test_cases/r3_view_compiler_i18n/ng-container_ng-template/self_closing_tags.pipeline.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,27 @@ | ||
function MyComponent_ng_template_3_Template(rf, ctx) { | ||
if (rf & 1) { | ||
$r3$.ɵɵi18nStart(0, 1); | ||
$r3$.ɵɵelement(1, "img", 2); | ||
$r3$.ɵɵi18nEnd(); | ||
} | ||
} | ||
… | ||
consts: () => { | ||
__i18nMsg__('{$tagImg} is my logo #1 ', [['tagImg', String.raw`\uFFFD#2\uFFFD\uFFFD/#2\uFFFD`]], {original_code: {tagImg: '<img src="logo.png" title="Logo" />'}}, {}) | ||
__i18nMsg__('{$tagImg} is my logo #2 ', [['tagImg', String.raw`\uFFFD#1\uFFFD\uFFFD/#1\uFFFD`]], {original_code: {tagImg: '<img src="logo.png" title="Logo" />'}}, {}) | ||
return [ | ||
$i18n_0$, | ||
$i18n_1$, | ||
["src", "logo.png", "title", "Logo"] | ||
]; | ||
}, | ||
template: function MyComponent_Template(rf, ctx) { | ||
if (rf & 1) { | ||
$r3$.ɵɵelementContainerStart(0); | ||
$r3$.ɵɵi18nStart(1, 0); | ||
$r3$.ɵɵelement(2, "img", 2); | ||
$r3$.ɵɵi18nEnd(); | ||
$r3$.ɵɵelementContainerEnd(); | ||
$r3$.ɵɵtemplate(3, MyComponent_ng_template_3_Template, 2, 0, "ng-template"); | ||
} | ||
} |
File renamed without changes.
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
22 changes: 22 additions & 0 deletions
22
...liance/test_cases/r3_view_compiler_i18n/self-closing_i18n_instructions/styles.pipeline.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,22 @@ | ||
decls: 4, | ||
vars: 0, | ||
consts: () => { | ||
__i18nMsg__('Text #1', [], {}, {}) | ||
__i18nMsg__('Text #2', [], {}, {}) | ||
return [ | ||
$i18n_0$, | ||
$i18n_1$, | ||
[__AttributeMarker.Classes__, "myClass"], | ||
[__AttributeMarker.Styles__, "padding", "10px"] | ||
]; | ||
}, | ||
template: function MyComponent_Template(rf, ctx) { | ||
if (rf & 1) { | ||
$r3$.ɵɵelementStart(0, "span", 2); | ||
$r3$.ɵɵi18n(1, 0); | ||
$r3$.ɵɵelementEnd(); | ||
$r3$.ɵɵelementStart(2, "span", 3); | ||
$r3$.ɵɵi18n(3, 1); | ||
$r3$.ɵɵelementEnd(); | ||
} | ||
} |
File renamed without changes.
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