@@ -28,7 +28,8 @@ import {
2828 RenderFragmentRef ,
2929 RenderElementRef ,
3030 ViewType ,
31- ViewEncapsulation
31+ ViewEncapsulation ,
32+ PropertyBindingType
3233} from "angular2/src/render/api" ;
3334import { WorkerElementRef } from 'angular2/src/web-workers/shared/api' ;
3435import { AST , ASTWithSource } from 'angular2/src/change_detection/change_detection' ;
@@ -57,6 +58,13 @@ export class Serializer {
5758 viewEncapsulationMap [ 1 ] = ViewEncapsulation . NATIVE ;
5859 viewEncapsulationMap [ 2 ] = ViewEncapsulation . NONE ;
5960 this . _enumRegistry . set ( ViewEncapsulation , viewEncapsulationMap ) ;
61+
62+ var propertyBindingTypeMap = new Map < int , any > ( ) ;
63+ propertyBindingTypeMap [ 0 ] = PropertyBindingType . PROPERTY ;
64+ propertyBindingTypeMap [ 1 ] = PropertyBindingType . ATTRIBUTE ;
65+ propertyBindingTypeMap [ 2 ] = PropertyBindingType . CLASS ;
66+ propertyBindingTypeMap [ 3 ] = PropertyBindingType . STYLE ;
67+ this . _enumRegistry . set ( PropertyBindingType , propertyBindingTypeMap ) ;
6068 }
6169
6270 serialize ( obj : any , type : Type ) : Object {
@@ -93,6 +101,8 @@ export class Serializer {
93101 return this . _renderViewStore . serializeRenderFragmentRef ( obj ) ;
94102 } else if ( type == WorkerElementRef ) {
95103 return this . _serializeWorkerElementRef ( obj ) ;
104+ } else if ( type == ElementPropertyBinding ) {
105+ return this . _serializeElementPropertyBinding ( obj ) ;
96106 } else if ( type == EventBinding ) {
97107 return this . _serializeEventBinding ( obj ) ;
98108 } else {
@@ -137,6 +147,8 @@ export class Serializer {
137147 return this . _deserializeWorkerElementRef ( map ) ;
138148 } else if ( type == EventBinding ) {
139149 return this . _deserializeEventBinding ( map ) ;
150+ } else if ( type == ElementPropertyBinding ) {
151+ return this . _deserializeElementPropertyBinding ( map ) ;
140152 } else {
141153 throw new BaseException ( "No deserializer for " + type . toString ( ) ) ;
142154 }
@@ -165,7 +177,7 @@ export class Serializer {
165177 if ( isPresent ( type ) ) {
166178 var map : Map < string , any > = new Map ( ) ;
167179 StringMapWrapper . forEach ( obj ,
168- ( key , val ) => { map . set ( key , this . deserialize ( val , type , data ) ) ; } ) ;
180+ ( val , key ) => { map . set ( key , this . deserialize ( val , type , data ) ) ; } ) ;
169181 return map ;
170182 } else {
171183 return MapWrapper . createFromStringMap ( obj ) ;
@@ -174,13 +186,29 @@ export class Serializer {
174186
175187 allocateRenderViews ( fragmentCount : number ) { this . _renderViewStore . allocate ( fragmentCount ) ; }
176188
189+ private _serializeElementPropertyBinding ( binding :
190+ ElementPropertyBinding ) : StringMap < string , any > {
191+ return {
192+ 'type' : serializeEnum ( binding . type ) ,
193+ 'astWithSource' : this . serialize ( binding . astWithSource , ASTWithSource ) ,
194+ 'property' : binding . property ,
195+ 'unit' : binding . unit
196+ } ;
197+ }
198+
199+ private _deserializeElementPropertyBinding ( map : StringMap < string , any > ) : ElementPropertyBinding {
200+ var type = deserializeEnum ( map [ 'type' ] , this . _enumRegistry . get ( PropertyBindingType ) ) ;
201+ var ast = this . deserialize ( map [ 'astWithSource' ] , ASTWithSource , "binding" ) ;
202+ return new ElementPropertyBinding ( type , ast , map [ 'property' ] , map [ 'unit' ] ) ;
203+ }
204+
177205 private _serializeEventBinding ( binding : EventBinding ) : StringMap < string , any > {
178206 return { 'fullName' : binding . fullName , 'source' : this . serialize ( binding . source , ASTWithSource ) } ;
179207 }
180208
181209 private _deserializeEventBinding ( map : StringMap < string , any > ) : EventBinding {
182210 return new EventBinding ( map [ 'fullName' ] ,
183- this . deserialize ( map [ 'source' ] , ASTWithSource , "binding " ) ) ;
211+ this . deserialize ( map [ 'source' ] , ASTWithSource , "action " ) ) ;
184212 }
185213
186214 private _serializeWorkerElementRef ( elementRef : RenderElementRef ) : StringMap < string , any > {
@@ -223,15 +251,12 @@ export class Serializer {
223251 // TODO: make ASTs serializable
224252 var ast : AST ;
225253 switch ( data ) {
226- case "interpolation " :
227- ast = this . _parser . parseInterpolation ( obj [ 'input' ] , obj [ 'location' ] ) ;
254+ case "action " :
255+ ast = this . _parser . parseAction ( obj [ 'input' ] , obj [ 'location' ] ) ;
228256 break ;
229257 case "binding" :
230258 ast = this . _parser . parseBinding ( obj [ 'input' ] , obj [ 'location' ] ) ;
231259 break ;
232- case "simpleBinding" :
233- ast = this . _parser . parseSimpleBinding ( obj [ 'input' ] , obj [ 'location' ] ) ;
234- break ;
235260 case "interpolation" :
236261 ast = this . _parser . parseInterpolation ( obj [ 'input' ] , obj [ 'location' ] ) ;
237262 break ;
0 commit comments