angular/packages/compiler-cli/test/compliance/test_cases
Kristiyan Kostadinov 104546569e fix(compiler): incorrectly interpreting some HostBinding names (#40233)
Currently when analyzing the metadata of a directive, we bundle together the bindings from `host`
and the `HostBinding` and `HostListener` together. This can become a problem later on in the
compilation pipeline, because we try to evaluate the value of the binding, causing something like
`@HostBinding('class.foo') public true = 1;` to be treated the same as
`host: {'[class.foo]': 'true'}`.

While looking into the issue, I noticed another one that is closely related: we weren't treating
quoted property names correctly. E.g. `@HostBinding('class.foo') public "foo-bar" = 1;` was being
interpreted as `classProp('foo', ctx.foo - ctx.bar)` due to the same issue where property names
were being evaluated.

These changes resolve both of the issues by treating all `HostBinding` instance as if they're
reading the property from `this`. E.g. the `@HostBinding('class.foo') public true = 1;` from above
is now being treated as `host: {'[class.foo]': 'this.true'}` which further down the pipeline becomes
`classProp('foo', ctx.true)`. This doesn't have any payload size implications for existing code,
because we've always been prefixing implicit property reads with `ctx.`. If the property doesn't
have an identifier that can be read using dotted access, we convert it to a quoted one (e.g.
`classProp('foo', ctx['is-foo']))`.

Fixes #40220.
Fixes #40230.
Fixes #18698.

PR Close #40233
2021-01-07 13:15:46 -08:00
..
r3_compiler_compliance refactor(core): express trusted constants with tagged template literals (#40082) 2021-01-05 13:56:57 -08:00
r3_view_compiler refactor(compiler-cli): emit forwardRef invocation for forward type references (#40117) 2020-12-22 08:39:58 -08:00
r3_view_compiler_bindings fix(compiler): incorrectly interpreting some HostBinding names (#40233) 2021-01-07 13:15:46 -08:00
r3_view_compiler_di/di refactor(compiler-cli): use ngDevMode guard for setClassMetadata call (#39987) 2020-12-10 13:23:13 -08:00
r3_view_compiler_directives/matching refactor(compiler-cli): use ngDevMode guard for setClassMetadata call (#39987) 2020-12-10 13:23:13 -08:00
r3_view_compiler_i18n test(compiler-cli): tidy up the line-ending compliance test TEST_CASES (#40237) 2021-01-07 13:12:53 -08:00
r3_view_compiler_input_outputs refactor(compiler-cli): use ngDevMode guard for setClassMetadata call (#39987) 2020-12-10 13:23:13 -08:00
r3_view_compiler_listener refactor(compiler-cli): use ngDevMode guard for setClassMetadata call (#39987) 2020-12-10 13:23:13 -08:00
r3_view_compiler_providers refactor(compiler-cli): use ngDevMode guard for setClassMetadata call (#39987) 2020-12-10 13:23:13 -08:00
r3_view_compiler_styling fix(compiler): incorrectly interpreting some HostBinding names (#40233) 2021-01-07 13:15:46 -08:00
r3_view_compiler_template refactor(compiler-cli): use ngDevMode guard for setClassMetadata call (#39987) 2020-12-10 13:23:13 -08:00
source_mapping test(compiler-cli): add external template source-map tests (#40237) 2021-01-07 13:12:53 -08:00
BUILD.bazel test(compiler-cli): generate golden files for partial compilation (#39617) 2020-11-13 11:25:56 -08:00
list_golden_update_rules.ts refactor(compiler-cli): use semver range checking for partial versions (#39847) 2020-12-04 10:26:17 -08:00
test_case_schema.json test(compiler-cli): improve compliance test compile mode filtering (#39939) 2020-12-07 16:21:04 -08:00