fix(ivy): process nested animation metadata (#32818)
In View Engine, animation metadata could occur in nested arrays which would be flattened in the compiler. When compiling a component for Ivy however, the compiler no longer statically evaluates a component's animation metadata and is therefore unable to flatten it statically. This resulted in an issue to find animations at runtime, as the metadata was incorrectly registered with the animation engine. Although it would be possible to statically evaluate the animation metadata in ngtsc, doing so would prevent reusable animations exported from libraries from being usable as ngtsc's partial evaluator is unable to read values inside libraries. This is unlike ngc's usage of static symbols represented in a library's `.metadata.json`, which explains how the View Engine compiler is able to flatten the animation metadata statically. As an alternative solution, the metadata flattening is now done in the runtime during the registration of the animation metadata with the animation engine. Fixes #32794 PR Close #32818
This commit is contained in:
@ -328,6 +328,36 @@ const DEFAULT_COMPONENT_ID = '1';
|
||||
]);
|
||||
});
|
||||
|
||||
// https://github.com/angular/angular/issues/32794
|
||||
it('should support nested animation triggers', () => {
|
||||
const REUSABLE_ANIMATION = [trigger(
|
||||
'myAnimation',
|
||||
[transition(
|
||||
'void => *', [style({'opacity': '0'}), animate(500, style({'opacity': '1'}))])])];
|
||||
|
||||
@Component({
|
||||
selector: 'if-cmp',
|
||||
template: `
|
||||
<div @myAnimation></div>
|
||||
`,
|
||||
animations: [REUSABLE_ANIMATION],
|
||||
})
|
||||
class Cmp {
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [Cmp]});
|
||||
|
||||
const engine = TestBed.inject(ɵAnimationEngine);
|
||||
const fixture = TestBed.createComponent(Cmp);
|
||||
fixture.detectChanges();
|
||||
engine.flush();
|
||||
|
||||
expect(getLog().length).toEqual(1);
|
||||
expect(getLog().pop() !.keyframes).toEqual([
|
||||
{offset: 0, opacity: '0'}, {offset: 1, opacity: '1'}
|
||||
]);
|
||||
});
|
||||
|
||||
it('should allow a transition to use a function to determine what method to run', () => {
|
||||
let valueToMatch = '';
|
||||
let capturedElement: any;
|
||||
|
Reference in New Issue
Block a user