fix(animations): make sure @.disabled works in non-animation components

Note 4.3 only!

Prior to this fix when [@.disabled] was used in a component that
contained zero animation code it wouldn't register properly because the
renderer associated with that component was not an animation renderer.
This patch ensures that it gets registered even when there are no
animations set.
This commit is contained in:
Matias Niemelä
2017-07-11 15:41:12 -04:00
committed by Alex Rickabaugh
parent 5db6f38b73
commit 5344be5182
3 changed files with 84 additions and 20 deletions

View File

@ -2281,6 +2281,57 @@ export function main() {
expect(cmp.startEvent.totalTime).toEqual(9876);
// the done event isn't fired because it's an actual animation
}));
it('should work when there are no animations on the component handling the disable/enable flag',
() => {
@Component({
selector: 'parent-cmp',
template: `
<div [@.disabled]="disableExp">
<child-cmp #child></child-cmp>
</div>
`
})
class ParentCmp {
@ViewChild('child') public child: ChildCmp|null = null;
disableExp = false;
}
@Component({
selector: 'child-cmp',
template: `
<div [@myAnimation]="exp"></div>
`,
animations: [trigger(
'myAnimation',
[transition(
'* => go, * => goAgain',
[style({opacity: 0}), animate('1s', style({opacity: 1}))])])]
})
class ChildCmp {
public exp = '';
}
TestBed.configureTestingModule({declarations: [ParentCmp, ChildCmp]});
const fixture = TestBed.createComponent(ParentCmp);
const cmp = fixture.componentInstance;
cmp.disableExp = true;
fixture.detectChanges();
resetLog();
const child = cmp.child !;
child.exp = 'go';
fixture.detectChanges();
expect(getLog().length).toEqual(0);
resetLog();
cmp.disableExp = false;
child.exp = 'goAgain';
fixture.detectChanges();
expect(getLog().length).toEqual(1);
});
});
});