angular-cn/packages/compiler-cli
Pete Bacon Darwin f535f31d78 fix(ivy): match attribute selectors for content projection with inline-templates (#29041)
The content projection mechanism is static, in that it only looks at the static
template nodes before directives are matched and change detection is run.
When you have a selector-based content projection the selection is based
on nodes that are available in the template.

For example:

```
<ng-content selector="[some-attr]"></ng-content>
```

would match

```
<div some-attr="..."></div>
```

If you have an inline-template in your projected nodes. For example:

```
<div *ngIf="..." some-attr="..."></div>
```

This gets pre-parsed and converted to a canonical form.

For example:

```
<ng-template [ngIf]="...">
  <div some-attr=".."></div>
</ng-template>
```

Note that only structural attributes (e.g. `*ngIf`) stay with the `<ng-template>`
node. The other attributes move to the contained element inside the template.

When this happens in ivy, the ng-template content is removed
from the component template function and is compiled into its own
template function. But this means that the information about the
attributes that were on the content are lost and the projection
selection mechanism is unable to match the original
`<div *ngIf="..." some-attr>`.

This commit adds support for this in ivy. Attributes are separated into three
groups (Bindings, Templates and "other"). For inline-templates the Bindings
and "other" types are hoisted back from the contained node to the `template()`
instruction, so that they can be used in content projection matching.

PR Close #29041
2019-03-07 11:27:36 -08:00
..
integrationtest build: rules_nodejs 0.26.0 & use @npm instead of @ngdeps now that downstream angular build uses angular bundles (#28871) 2019-02-28 12:06:36 -08:00
src fix(ivy): never use imported type references as values (#29111) 2019-03-05 16:47:41 -08:00
test fix(ivy): match attribute selectors for content projection with inline-templates (#29041) 2019-03-07 11:27:36 -08:00
BUILD.bazel build: rules_nodejs 0.26.0 & use @npm instead of @ngdeps now that downstream angular build uses angular bundles (#28871) 2019-02-28 12:06:36 -08:00
index.ts feat(compiler-cli): expose ngtsc as a TscPlugin (#28435) 2019-01-29 16:41:59 -08:00
ngtools2.ts refactor(compiler-cli): expose ngtools api separately (#18978) 2017-08-31 14:37:13 -07:00
package.json docs: cleanup contributors (#28930) 2019-03-06 14:48:30 -08:00
tsconfig-build.json build: Move non-bazel deps to devDependencies (#26691) 2018-10-30 16:19:13 -04:00
tsconfig.json build(compiler-cli): fix tsconfig.json circularity issue (#22722) 2018-03-15 21:18:07 -07:00