fix(core): fix `isComponentView()` and `isEmbeddedView()` tests (#14789)

fixes #14778
This commit is contained in:
Victor Berchet 2017-03-01 08:03:14 -08:00 committed by Igor Minar
parent d1182af1a4
commit 5753de50f0
2 changed files with 11 additions and 2 deletions

View File

@ -34,6 +34,15 @@ export function main() {
});
});
// https://github.com/angular/angular/issues/14778
it('should accept the component as the context', async(() => {
const template = `<ng-container *ngTemplateOutlet="tpl; context: this"></ng-container>` +
`<ng-template #tpl>{{context.foo}}</ng-template>`;
fixture = createTestComponent(template);
detectChangesAndExpectText('bar');
}));
it('should do nothing if templateRef is `null`', async(() => {
const template = `<ng-container [ngTemplateOutlet]="null"></ng-container>`;
fixture = createTestComponent(template);

View File

@ -141,11 +141,11 @@ export function elementEventFullName(target: string, name: string): string {
}
export function isComponentView(view: ViewData): boolean {
return view.component === view.context && !!view.parent;
return !!view.parent && !!(view.parentNodeDef.flags & NodeFlags.Component);
}
export function isEmbeddedView(view: ViewData): boolean {
return view.component !== view.context && !!view.parent;
return !!view.parent && !(view.parentNodeDef.flags & NodeFlags.Component);
}
export function filterQueryId(queryId: number): number {