angular/packages/compiler/src
Dylan Hunn f600f0fb27 refactor(compiler): Show an error when a property binding duplicates an i18n attribute (#54063)
Consider the following very quirky Angular template, which has both an i18n attribute binding and a property binding to `in`:
```
<cmp [in]="foo" in="bar" i18n-in />
```

What would you expect the above template to do? `TemplateDefinitionBuilder` will emit the following Ivy instructions:
```
// Element constant attributes
consts: () => {
    __i18nMsg__('bar', [], {}, {})
    return [["in", i18n_0, __AttributeMarker.I18n__, "in"]];
}
// ...
function MyComponent_Template(rf, ctx) {
    if (rf & 1) {
        // Create mode
        i0.ɵɵelement(0, "cmp", 0);
    }
}
```

This makes some sense -- we create a single element, and attach an i18n message to the `in` attribute. But is this actually correct? Notice that the property binding is completely missing!

Indeed, Template Pipeline actually produces this code:
```
// Element constant attributes
consts: () => {
    __i18nMsg__('bar', [], {}, {})
    return [["in", i18n_0, __AttributeMarker.I18n__, "in"]];
}
// ...
function MyComponent_Template(rf, ctx) {
    if (rf & 1) {
        // Create mode
        i0.ɵɵelement(0, "cmp", 0);
    } else if (rf & 2) {
        // Update mode
        i0.ɵɵproperty("in", ctx.foo);
    }
}
```

Aha! There's the property binding! Arguably, this is a bug in `TemplateDefinitionBuilder`, but after some discussion on Slack, we have decided to ban this practice in a future Angular version.

For now, we allow Template Pipeline to have slightly different output, but print an error to warn the user of the issue.

PR Close #54063
2024-02-02 20:52:39 +00:00
..
compiler_util refactor(compiler): allow some invalid expressions in two-way bindings that previously worked by accident (#54154) 2024-02-01 14:39:32 +00:00
expression_parser refactor(compiler): preserve expression in two-way listeners (#54154) 2024-02-01 14:39:32 +00:00
i18n fix(compiler): produce placeholder for blocks in i18n bundles (#52958) 2023-11-20 08:59:24 -08:00
ml_parser refactor(compiler): Not all attribute values beginning with a colon are namespaced (#53574) 2023-12-15 19:48:28 +00:00
output refactor(core): properly emit input flags using bitwise or (#53808) 2024-01-10 12:21:04 +00:00
render3 fix(compiler-cli): handle default imports in defer blocks (#53695) 2024-02-01 15:58:21 +00:00
schema fix(core): hardening attribute and property binding rules for <iframe> elements (#47964) 2022-11-09 00:47:56 -08:00
template/pipeline refactor(compiler): Show an error when a property binding duplicates an i18n attribute (#54063) 2024-02-02 20:52:39 +00:00
template_parser refactor(compiler): allow some invalid expressions in two-way bindings that previously worked by accident (#54154) 2024-02-01 14:39:32 +00:00
assertions.ts refactor(compiler): remove unused assertion function (#44411) 2022-01-04 15:54:09 -08:00
chars.ts refactor(compiler): share isQuote() via chars.ts (#43129) 2021-08-16 13:07:23 -07:00
compiler.ts refactor(compiler): provide a private API to perform direct style encapsulation (#53363) 2023-12-08 14:29:18 -08:00
compiler_facade_interface.ts refactor(compiler): support JIT for signal-based queries (#54019) 2024-01-24 16:13:31 +01:00
config.ts refactor(compiler): remove mentions of unused compiler options. (#53746) 2024-01-17 16:41:35 -08:00
constant_pool.ts refactor(compiler): Add an escape hatch to use non-unique const pool names (#53574) 2023-12-15 19:48:27 +00:00
core.ts refactor(core): detect signal input transforms independently of flag (#53808) 2024-01-10 12:21:04 +00:00
injectable_compiler_2.ts perf(compiler): further reduce bundle size using arrow functions (#52010) 2023-10-04 07:25:54 -07:00
jit_compiler_facade.ts feat(compiler): Add a TSConfig option useTemplatePipeline (#54057) 2024-01-24 18:36:23 -05:00
parse_util.ts refactor: replace deprecated String.prototype.substr() (#45397) 2022-03-24 11:48:09 -07:00
resource_loader.ts refactor(compiler): ensure compatibility with noImplicitOverride (#42512) 2021-07-12 13:11:14 -07:00
selector.ts feat(compiler): allow self-closing tags on custom elements (#48535) 2023-01-04 12:07:37 -08:00
shadow_css.ts feat(compiler): scope selectors in @starting-style (#53943) 2024-01-17 09:14:11 -08:00
style_url_resolver.ts refactor(compiler): make template preparser null-safe (#44411) 2022-01-04 15:54:10 -08:00
util.ts refactor(compiler): use globalThis for global (#50063) 2023-07-14 18:32:01 +00:00
version.ts docs: fix package name in version.ts files in different packages (#41208) 2021-05-10 10:26:34 -04:00