angular-cn/packages/core
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
..
global build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
schematics feat(core): Add schematic to fix invalid `Route` configs (#40067) 2021-01-05 10:09:28 -08:00
src fix(core): ensure sanitizer works if DOMParser return null body (#40107) 2021-01-06 10:32:24 -08:00
test fix(compiler): incorrectly interpreting some HostBinding names (#40233) 2021-01-07 13:15:46 -08:00
testing refactor(core): remove unused fakeAsyncFallback and asyncFallback (#37879) 2020-11-20 08:34:59 -08:00
BUILD.bazel fix(core): disable tsickle pass when producing APF packages (#37221) 2020-05-21 09:14:47 -07:00
PACKAGE.md docs: add package doc files (#26047) 2018-10-05 15:42:14 -07:00
index.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
package.json build: update peerDependencies of zone.js to 0.10~0.11 (#39809) 2020-11-25 14:25:48 -08:00
public_api.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00