Skip to content

Commit

Permalink
fix(core): fix isComponentView() and isEmbeddedView() tests (#14789)
Browse files Browse the repository at this point in the history
fixes #14778
  • Loading branch information
vicb authored and IgorMinar committed Mar 1, 2017
1 parent d1182af commit 5753de5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions modules/@angular/core/src/view/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5753de5

Please sign in to comment.