@@ -20,6 +20,10 @@ const _INITIAL_KEYFRAME = 0;
2020const _TERMINAL_KEYFRAME = 1 ;
2121const _ONE_SECOND = 1000 ;
2222
23+ declare type Styles = {
24+ [ key : string ] : string | number
25+ } ;
26+
2327export class AnimationParseError extends ParseError {
2428 constructor ( message : string ) { super ( null , message ) ; }
2529 toString ( ) : string { return `${ this . msg } ` ; }
@@ -90,11 +94,11 @@ export class AnimationParser {
9094function _parseAnimationDeclarationStates (
9195 stateMetadata : CompileAnimationStateDeclarationMetadata ,
9296 errors : AnimationParseError [ ] ) : AnimationStateDeclarationAst [ ] {
93- var styleValues : { [ key : string ] : string | number } [ ] = [ ] ;
97+ var styleValues : Styles [ ] = [ ] ;
9498 stateMetadata . styles . styles . forEach ( stylesEntry => {
9599 // TODO (matsko): change this when we get CSS class integration support
96100 if ( isStringMap ( stylesEntry ) ) {
97- styleValues . push ( < { [ key : string ] : string | number } > stylesEntry ) ;
101+ styleValues . push ( stylesEntry as Styles ) ;
98102 } else {
99103 errors . push ( new AnimationParseError (
100104 `State based animations cannot contain references to other states` ) ) ;
@@ -169,16 +173,6 @@ function _parseAnimationTransitionExpr(
169173 return expressions ;
170174}
171175
172- function _fetchSylesFromState ( stateName : string , stateStyles : { [ key : string ] : AnimationStylesAst } ) :
173- CompileAnimationStyleMetadata {
174- var entry = stateStyles [ stateName ] ;
175- if ( isPresent ( entry ) ) {
176- var styles = < { [ key : string ] : string | number } [ ] > entry . styles ;
177- return new CompileAnimationStyleMetadata ( 0 , styles ) ;
178- }
179- return null ;
180- }
181-
182176function _normalizeAnimationEntry ( entry : CompileAnimationMetadata | CompileAnimationMetadata [ ] ) :
183177 CompileAnimationMetadata {
184178 return isArray ( entry ) ? new CompileAnimationSequenceMetadata ( < CompileAnimationMetadata [ ] > entry ) :
@@ -234,7 +228,7 @@ function _normalizeStyleStepEntry(
234228 }
235229
236230 var newSteps : CompileAnimationMetadata [ ] = [ ] ;
237- var combinedStyles : { [ key : string ] : string | number } [ ] ;
231+ var combinedStyles : Styles [ ] ;
238232 steps . forEach ( step => {
239233 if ( step instanceof CompileAnimationStyleMetadata ) {
240234 // this occurs when a style step is followed by a previous style step
@@ -290,7 +284,7 @@ function _normalizeStyleStepEntry(
290284function _resolveStylesFromState (
291285 stateName : string , stateStyles : { [ key : string ] : AnimationStylesAst } ,
292286 errors : AnimationParseError [ ] ) {
293- var styles : { [ key : string ] : string | number } [ ] = [ ] ;
287+ var styles : Styles [ ] = [ ] ;
294288 if ( stateName [ 0 ] != ':' ) {
295289 errors . push ( new AnimationParseError ( `Animation states via styles must be prefixed with a ":"` ) ) ;
296290 } else {
@@ -302,7 +296,7 @@ function _resolveStylesFromState(
302296 } else {
303297 value . styles . forEach ( stylesEntry => {
304298 if ( isStringMap ( stylesEntry ) ) {
305- styles . push ( < { [ key : string ] : string | number } > stylesEntry ) ;
299+ styles . push ( stylesEntry as Styles ) ;
306300 }
307301 } ) ;
308302 }
@@ -336,15 +330,13 @@ function _parseAnimationKeyframes(
336330 var lastOffset = 0 ;
337331 keyframeSequence . steps . forEach ( styleMetadata => {
338332 var offset = styleMetadata . offset ;
339- var keyframeStyles : { [ key : string ] : string | number } = { } ;
333+ var keyframeStyles : Styles = { } ;
340334 styleMetadata . styles . forEach ( entry => {
341- StringMapWrapper . forEach (
342- < { [ key : string ] : string | number } > entry ,
343- ( value : any /** TODO #9100 */ , prop : any /** TODO #9100 */ ) => {
344- if ( prop != 'offset' ) {
345- keyframeStyles [ prop ] = value ;
346- }
347- } ) ;
335+ Object . keys ( entry ) . forEach ( prop => {
336+ if ( prop != 'offset' ) {
337+ keyframeStyles [ prop ] = ( entry as Styles ) [ prop ] ;
338+ }
339+ } ) ;
348340 } ) ;
349341
350342 if ( isPresent ( offset ) ) {
@@ -381,24 +373,22 @@ function _parseAnimationKeyframes(
381373 let entry = rawKeyframes [ i ] ;
382374 let styles = entry [ 1 ] ;
383375
384- StringMapWrapper . forEach (
385- styles , ( value : any /** TODO #9100 */ , prop : any /** TODO #9100 */ ) => {
386- if ( ! isPresent ( firstKeyframeStyles [ prop ] ) ) {
387- firstKeyframeStyles [ prop ] = FILL_STYLE_FLAG ;
388- }
389- } ) ;
376+ Object . keys ( styles ) . forEach ( prop => {
377+ if ( ! isPresent ( firstKeyframeStyles [ prop ] ) ) {
378+ firstKeyframeStyles [ prop ] = FILL_STYLE_FLAG ;
379+ }
380+ } ) ;
390381 }
391382
392383 for ( i = limit - 1 ; i >= 0 ; i -- ) {
393384 let entry = rawKeyframes [ i ] ;
394385 let styles = entry [ 1 ] ;
395386
396- StringMapWrapper . forEach (
397- styles , ( value : any /** TODO #9100 */ , prop : any /** TODO #9100 */ ) => {
398- if ( ! isPresent ( lastKeyframeStyles [ prop ] ) ) {
399- lastKeyframeStyles [ prop ] = value ;
400- }
401- } ) ;
387+ Object . keys ( styles ) . forEach ( prop => {
388+ if ( ! isPresent ( lastKeyframeStyles [ prop ] ) ) {
389+ lastKeyframeStyles [ prop ] = styles [ prop ] ;
390+ }
391+ } ) ;
402392 }
403393
404394 return rawKeyframes . map (
@@ -422,11 +412,9 @@ function _parseTransitionAnimation(
422412 if ( entry instanceof CompileAnimationStyleMetadata ) {
423413 entry . styles . forEach ( stylesEntry => {
424414 // by this point we know that we only have stringmap values
425- var map = < { [ key : string ] : string | number } > stylesEntry ;
426- StringMapWrapper . forEach (
427- map , ( value : any /** TODO #9100 */ , prop : any /** TODO #9100 */ ) => {
428- collectedStyles . insertAtTime ( prop , time , value ) ;
429- } ) ;
415+ var map = stylesEntry as Styles ;
416+ Object . keys ( map ) . forEach (
417+ prop => { collectedStyles . insertAtTime ( prop , time , map [ prop ] ) ; } ) ;
430418 } ) ;
431419 previousStyles = entry . styles ;
432420 return ;
@@ -472,7 +460,7 @@ function _parseTransitionAnimation(
472460 } else {
473461 let styleData = < CompileAnimationStyleMetadata > styles ;
474462 let offset = _TERMINAL_KEYFRAME ;
475- let styleAst = new AnimationStylesAst ( < { [ key : string ] : string | number } [ ] > styleData . styles ) ;
463+ let styleAst = new AnimationStylesAst ( styleData . styles as Styles [ ] ) ;
476464 var keyframe = new AnimationKeyframeAst ( offset , styleAst ) ;
477465 keyframes = [ keyframe ] ;
478466 }
@@ -484,9 +472,8 @@ function _parseTransitionAnimation(
484472
485473 keyframes . forEach (
486474 ( keyframe : any /** TODO #9100 */ ) => keyframe . styles . styles . forEach (
487- ( entry : any /** TODO #9100 */ ) => StringMapWrapper . forEach (
488- entry , ( value : any /** TODO #9100 */ , prop : any /** TODO #9100 */ ) =>
489- collectedStyles . insertAtTime ( prop , currentTime , value ) ) ) ) ;
475+ ( entry : any /** TODO #9100 */ ) => Object . keys ( entry ) . forEach (
476+ prop => { collectedStyles . insertAtTime ( prop , currentTime , entry [ prop ] ) ; } ) ) ) ;
490477 } else {
491478 // if the code reaches this stage then an error
492479 // has already been populated within the _normalizeStyleSteps()
@@ -559,10 +546,11 @@ function _parseTimeExpression(
559546function _createStartKeyframeFromEndKeyframe (
560547 endKeyframe : AnimationKeyframeAst , startTime : number , duration : number ,
561548 collectedStyles : StylesCollection , errors : AnimationParseError [ ] ) : AnimationKeyframeAst {
562- var values : { [ key : string ] : string | number } = { } ;
549+ var values : Styles = { } ;
563550 var endTime = startTime + duration ;
564- endKeyframe . styles . styles . forEach ( ( styleData : { [ key : string ] : string | number } ) => {
565- StringMapWrapper . forEach ( styleData , ( val : any /** TODO #9100 */ , prop : any /** TODO #9100 */ ) => {
551+ endKeyframe . styles . styles . forEach ( ( styleData : Styles ) => {
552+ Object . keys ( styleData ) . forEach ( prop => {
553+ const val = styleData [ prop ] ;
566554 if ( prop == 'offset' ) return ;
567555
568556 var resultIndex = collectedStyles . indexOfAtOrBeforeTime ( prop , startTime ) ;
0 commit comments