fix(core): incorrectly validating properties on ng-content and ng-container (#37773)

Fixes the following issues related to how we validate properties during JIT:
- The invalid property warning was printing `null` as the node name
for `ng-content`. The problem is that when generating a template from
 `ng-content` we weren't capturing the node name.
- We weren't running property validation on `ng-container` at all.
This used to be supported on ViewEngine and seems like an oversight.

In the process of making these changes, I found and cleaned up a
few places where we were passing in `LView` unnecessarily.

PR Close #37773
This commit is contained in:
crisbeto
2020-07-15 07:03:04 +02:00
committed by Andrew Kushnir
parent 4f65f473e4
commit 17ddab98fb
6 changed files with 116 additions and 15 deletions

View File

@ -1551,6 +1551,43 @@ describe('compiler compliance', () => {
const result = compile(files, angularFiles);
expectEmit(result.source, SimpleComponentDefinition, 'Incorrect MyApp definition');
});
it('should capture the node name of ng-content with a structural directive', () => {
const files = {
app: {
'spec.ts': `
import {Component, Directive, NgModule, TemplateRef} from '@angular/core';
@Component({selector: 'simple', template: '<ng-content *ngIf="showContent"></ng-content>'})
export class SimpleComponent {}
`
}
};
const SimpleComponentDefinition = `
SimpleComponent.ɵcmp = $r3$.ɵɵdefineComponent({
type: SimpleComponent,
selectors: [["simple"]],
ngContentSelectors: $c0$,
decls: 1,
vars: 1,
consts: [[4, "ngIf"]],
template: function SimpleComponent_Template(rf, ctx) {
if (rf & 1) {
i0.ɵɵprojectionDef();
i0.ɵɵtemplate(0, SimpleComponent_ng_content_0_Template, 1, 0, "ng-content", 0);
}
if (rf & 2) {
i0.ɵɵproperty("ngIf", ctx.showContent);
}
},
encapsulation: 2
});`;
const result = compile(files, angularFiles);
expectEmit(
result.source, SimpleComponentDefinition, 'Incorrect SimpleComponent definition');
});
});
describe('queries', () => {