fix(animations): validate against trigger() names that use @ symbols (#20326)
PR Close #20326
This commit is contained in:
parent
7c44637fbf
commit
1861e416a1
@ -90,6 +90,11 @@ export class AnimationAstBuilderVisitor implements AnimationDslVisitor {
|
|||||||
let depCount = context.depCount = 0;
|
let depCount = context.depCount = 0;
|
||||||
const states: StateAst[] = [];
|
const states: StateAst[] = [];
|
||||||
const transitions: TransitionAst[] = [];
|
const transitions: TransitionAst[] = [];
|
||||||
|
if (metadata.name.charAt(0) == '@') {
|
||||||
|
context.errors.push(
|
||||||
|
'animation triggers cannot be prefixed with an `@` sign (e.g. trigger(\'@foo\', [...]))');
|
||||||
|
}
|
||||||
|
|
||||||
metadata.definitions.forEach(def => {
|
metadata.definitions.forEach(def => {
|
||||||
this._resetContextStyleTimingState(context);
|
this._resetContextStyleTimingState(context);
|
||||||
if (def.type == AnimationMetadataType.State) {
|
if (def.type == AnimationMetadataType.State) {
|
||||||
|
@ -119,6 +119,14 @@ export function main() {
|
|||||||
expect(() => validateAndThrowAnimationSequence(steps)).not.toThrow();
|
expect(() => validateAndThrowAnimationSequence(steps)).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not allow triggers to be defined with a prefixed `@` symbol', () => {
|
||||||
|
const steps = trigger('@foo', []);
|
||||||
|
|
||||||
|
expect(() => validateAndThrowAnimationSequence(steps))
|
||||||
|
.toThrowError(
|
||||||
|
/animation triggers cannot be prefixed with an `@` sign \(e\.g\. trigger\('@foo', \[...\]\)\)/);
|
||||||
|
});
|
||||||
|
|
||||||
it('should throw an error if an animation time is invalid', () => {
|
it('should throw an error if an animation time is invalid', () => {
|
||||||
const steps = [animate('500xs', style({opacity: 1}))];
|
const steps = [animate('500xs', style({opacity: 1}))];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user