refactor(animations): collect parser / lookup errors in the same place

This commit is contained in:
Matias Niemelä
2016-07-09 00:43:17 -07:00
parent 6d02d2f107
commit 79eda30f0f
6 changed files with 96 additions and 15 deletions

View File

@ -6,6 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {BaseException, SecurityContext} from '@angular/core';
import {EMPTY_STATE as EMPTY_ANIMATION_STATE, LifecycleHooks, isDefaultChangeDetectionStrategy} from '../../core_private';
import * as cdAst from '../expression_parser/ast';
import {isBlank, isPresent} from '../facade/lang';
@ -136,10 +138,6 @@ function bindAndWriteToRenderer(
case PropertyBindingType.Animation:
var animationName = boundProp.name;
var animation = view.componentView.animations.get(animationName);
if (!isPresent(animation)) {
throw new BaseException(
`Internal Error: couldn't find an animation entry for ${boundProp.name}`);
}
// it's important to normalize the void value as `void` explicitly
// so that the styles data can be obtained from the stringmap

View File

@ -275,7 +275,7 @@ class ViewBuilderVisitor implements TemplateAstVisitor {
ast.hasViewContainer, true, ast.references);
this.view.nodes.push(compileElement);
var compiledAnimations = this._animationCompiler.compileComponent(this.view.component);
var compiledAnimations = this._animationCompiler.compileComponent(this.view.component, [ast]);
this.nestedViewCount++;
var embeddedView = new CompileView(

View File

@ -36,7 +36,7 @@ export class ViewCompiler {
component: CompileDirectiveMetadata, template: TemplateAst[], styles: o.Expression,
pipes: CompilePipeMetadata[]): ViewCompileResult {
var dependencies: Array<ViewFactoryDependency|ComponentFactoryDependency> = [];
var compiledAnimations = this._animationCompiler.compileComponent(component);
var compiledAnimations = this._animationCompiler.compileComponent(component, template);
var statements: o.Statement[] = [];
compiledAnimations.map(entry => {
statements.push(entry.statesMapStatement);