fix(core): allow to detach OnPush components (#16394)

Fixes #9720
This commit is contained in:
Tobias Bosch
2017-04-27 16:15:10 -07:00
committed by Miško Hevery
parent 392d584572
commit aa8bba4865
4 changed files with 26 additions and 9 deletions

View File

@ -1175,6 +1175,21 @@ export function main() {
expect(renderLog.log).toEqual([]);
}));
it('Detached should disable OnPush', fakeAsync(() => {
const ctx = createCompFixture('<push-cmp [value]="value"></push-cmp>');
ctx.componentInstance.value = 0;
ctx.detectChanges();
renderLog.clear();
const cmp: CompWithRef = queryDirs(ctx.debugElement, PushComp)[0];
cmp.changeDetectorRef.detach();
ctx.componentInstance.value = 1;
ctx.detectChanges();
expect(renderLog.log).toEqual([]);
}));
it('Detached view can be checked locally', fakeAsync(() => {
const ctx = createCompFixture('<wrap-comp-with-ref></wrap-comp-with-ref>');
const cmp: CompWithRef = queryDirs(ctx.debugElement, CompWithRef)[0];
@ -1225,7 +1240,6 @@ export function main() {
ctx.detectChanges();
expect(cmp.renderCount).toBe(count);
}));
});