@@ -3,8 +3,10 @@ import {SetterFn} from 'angular2/src/reflection/types';
33import { AST } from './parser/ast' ;
44import { DirectiveIndex , DirectiveRecord } from './directive_record' ;
55
6- const DIRECTIVE = "directive" ;
76const DIRECTIVE_LIFECYCLE = "directiveLifecycle" ;
7+ const BINDING = "native" ;
8+
9+ const DIRECTIVE = "directive" ;
810const ELEMENT_PROPERTY = "elementProperty" ;
911const ELEMENT_ATTRIBUTE = "elementAttribute" ;
1012const ELEMENT_CLASS = "elementClass" ;
@@ -13,24 +15,12 @@ const TEXT_NODE = "textNode";
1315const EVENT = "event" ;
1416const HOST_EVENT = "hostEvent" ;
1517
16- export class BindingRecord {
17- constructor ( public mode : string , public implicitReceiver : any , public ast : AST ,
18- public elementIndex : number , public propertyName : string , public propertyUnit : string ,
19- public eventName : string , public setter : SetterFn , public lifecycleEvent : string ,
20- public directiveRecord : DirectiveRecord ) { }
21-
22- callOnChange ( ) : boolean {
23- return isPresent ( this . directiveRecord ) && this . directiveRecord . callOnChange ;
24- }
25-
26- isDefaultChangeDetection ( ) : boolean {
27- return isBlank ( this . directiveRecord ) || this . directiveRecord . isDefaultChangeDetection ( ) ;
28- }
18+ export class BindingTarget {
19+ constructor ( public mode : string , public elementIndex : number , public name : string ,
20+ public unit : string , public debug : string ) { }
2921
3022 isDirective ( ) : boolean { return this . mode === DIRECTIVE ; }
3123
32- isDirectiveLifecycle ( ) : boolean { return this . mode === DIRECTIVE_LIFECYCLE ; }
33-
3424 isElementProperty ( ) : boolean { return this . mode === ELEMENT_PROPERTY ; }
3525
3626 isElementAttribute ( ) : boolean { return this . mode === ELEMENT_ATTRIBUTE ; }
@@ -40,87 +30,118 @@ export class BindingRecord {
4030 isElementStyle ( ) : boolean { return this . mode === ELEMENT_STYLE ; }
4131
4232 isTextNode ( ) : boolean { return this . mode === TEXT_NODE ; }
33+ }
4334
44- static createForDirective ( ast : AST , propertyName : string , setter : SetterFn ,
45- directiveRecord : DirectiveRecord ) : BindingRecord {
46- return new BindingRecord ( DIRECTIVE , 0 , ast , 0 , propertyName , null , null , setter , null ,
47- directiveRecord ) ;
35+ export class BindingRecord {
36+ constructor ( public mode : string , public target : BindingTarget , public implicitReceiver : any ,
37+ public ast : AST , public setter : SetterFn , public lifecycleEvent : string ,
38+ public directiveRecord : DirectiveRecord ) { }
39+
40+ isDirectiveLifecycle ( ) : boolean { return this . mode === DIRECTIVE_LIFECYCLE ; }
41+
42+ callOnChange ( ) : boolean {
43+ return isPresent ( this . directiveRecord ) && this . directiveRecord . callOnChange ;
4844 }
4945
46+ isDefaultChangeDetection ( ) : boolean {
47+ return isBlank ( this . directiveRecord ) || this . directiveRecord . isDefaultChangeDetection ( ) ;
48+ }
49+
50+
5051 static createDirectiveOnCheck ( directiveRecord : DirectiveRecord ) : BindingRecord {
51- return new BindingRecord ( DIRECTIVE_LIFECYCLE , 0 , null , 0 , null , null , null , null , "onCheck" ,
52- directiveRecord ) ;
52+ return new BindingRecord ( DIRECTIVE_LIFECYCLE , null , 0 , null , null , "onCheck" , directiveRecord ) ;
5353 }
5454
5555 static createDirectiveOnInit ( directiveRecord : DirectiveRecord ) : BindingRecord {
56- return new BindingRecord ( DIRECTIVE_LIFECYCLE , 0 , null , 0 , null , null , null , null , "onInit" ,
57- directiveRecord ) ;
56+ return new BindingRecord ( DIRECTIVE_LIFECYCLE , null , 0 , null , null , "onInit" , directiveRecord ) ;
5857 }
5958
6059 static createDirectiveOnChange ( directiveRecord : DirectiveRecord ) : BindingRecord {
61- return new BindingRecord ( DIRECTIVE_LIFECYCLE , 0 , null , 0 , null , null , null , null , "onChange" ,
62- directiveRecord ) ;
60+ return new BindingRecord ( DIRECTIVE_LIFECYCLE , null , 0 , null , null , "onChange" , directiveRecord ) ;
61+ }
62+
63+
64+
65+ static createForDirective ( ast : AST , propertyName : string , setter : SetterFn ,
66+ directiveRecord : DirectiveRecord ) : BindingRecord {
67+ var t = new BindingTarget ( DIRECTIVE , null , propertyName , null , ast . toString ( ) ) ;
68+ return new BindingRecord ( DIRECTIVE , t , 0 , ast , setter , null , directiveRecord ) ;
6369 }
6470
71+
72+
6573 static createForElementProperty ( ast : AST , elementIndex : number ,
6674 propertyName : string ) : BindingRecord {
67- return new BindingRecord ( ELEMENT_PROPERTY , 0 , ast , elementIndex , propertyName , null , null , null ,
68- null , null ) ;
75+ var t = new BindingTarget ( ELEMENT_PROPERTY , elementIndex , propertyName , null , ast . toString ( ) ) ;
76+ return new BindingRecord ( BINDING , t , 0 , ast , null , null , null ) ;
6977 }
7078
7179 static createForElementAttribute ( ast : AST , elementIndex : number ,
7280 attributeName : string ) : BindingRecord {
73- return new BindingRecord ( ELEMENT_ATTRIBUTE , 0 , ast , elementIndex , attributeName , null , null ,
74- null , null , null ) ;
81+ var t = new BindingTarget ( ELEMENT_ATTRIBUTE , elementIndex , attributeName , null , ast . toString ( ) ) ;
82+ return new BindingRecord ( BINDING , t , 0 , ast , null , null , null ) ;
7583 }
7684
7785 static createForElementClass ( ast : AST , elementIndex : number , className : string ) : BindingRecord {
78- return new BindingRecord ( ELEMENT_CLASS , 0 , ast , elementIndex , className , null , null , null , null ,
79- null ) ;
86+ var t = new BindingTarget ( ELEMENT_CLASS , elementIndex , className , null , ast . toString ( ) ) ;
87+ return new BindingRecord ( BINDING , t , 0 , ast , null , null , null ) ;
8088 }
8189
8290 static createForElementStyle ( ast : AST , elementIndex : number , styleName : string ,
8391 unit : string ) : BindingRecord {
84- return new BindingRecord ( ELEMENT_STYLE , 0 , ast , elementIndex , styleName , unit , null , null , null ,
85- null ) ;
92+ var t = new BindingTarget ( ELEMENT_STYLE , elementIndex , styleName , unit , ast . toString ( ) ) ;
93+ return new BindingRecord ( BINDING , t , 0 , ast , null , null , null ) ;
8694 }
8795
96+
97+
8898 static createForHostProperty ( directiveIndex : DirectiveIndex , ast : AST ,
8999 propertyName : string ) : BindingRecord {
90- return new BindingRecord ( ELEMENT_PROPERTY , directiveIndex , ast , directiveIndex . elementIndex ,
91- propertyName , null , null , null , null , null ) ;
100+ var t = new BindingTarget ( ELEMENT_PROPERTY , directiveIndex . elementIndex , propertyName , null ,
101+ ast . toString ( ) ) ;
102+ return new BindingRecord ( BINDING , t , directiveIndex , ast , null , null , null ) ;
92103 }
93104
94105 static createForHostAttribute ( directiveIndex : DirectiveIndex , ast : AST ,
95106 attributeName : string ) : BindingRecord {
96- return new BindingRecord ( ELEMENT_ATTRIBUTE , directiveIndex , ast , directiveIndex . elementIndex ,
97- attributeName , null , null , null , null , null ) ;
107+ var t = new BindingTarget ( ELEMENT_ATTRIBUTE , directiveIndex . elementIndex , attributeName , null ,
108+ ast . toString ( ) ) ;
109+ return new BindingRecord ( BINDING , t , directiveIndex , ast , null , null , null ) ;
98110 }
99111
100112 static createForHostClass ( directiveIndex : DirectiveIndex , ast : AST ,
101113 className : string ) : BindingRecord {
102- return new BindingRecord ( ELEMENT_CLASS , directiveIndex , ast , directiveIndex . elementIndex ,
103- className , null , null , null , null , null ) ;
114+ var t = new BindingTarget ( ELEMENT_CLASS , directiveIndex . elementIndex , className , null ,
115+ ast . toString ( ) ) ;
116+ return new BindingRecord ( BINDING , t , directiveIndex , ast , null , null , null ) ;
104117 }
105118
106119 static createForHostStyle ( directiveIndex : DirectiveIndex , ast : AST , styleName : string ,
107120 unit : string ) : BindingRecord {
108- return new BindingRecord ( ELEMENT_STYLE , directiveIndex , ast , directiveIndex . elementIndex ,
109- styleName , unit , null , null , null , null ) ;
121+ var t = new BindingTarget ( ELEMENT_STYLE , directiveIndex . elementIndex , styleName , unit ,
122+ ast . toString ( ) ) ;
123+ return new BindingRecord ( BINDING , t , directiveIndex , ast , null , null , null ) ;
110124 }
111125
126+
127+
112128 static createForTextNode ( ast : AST , elementIndex : number ) : BindingRecord {
113- return new BindingRecord ( TEXT_NODE , 0 , ast , elementIndex , null , null , null , null , null , null ) ;
129+ var t = new BindingTarget ( TEXT_NODE , elementIndex , null , null , ast . toString ( ) ) ;
130+ return new BindingRecord ( BINDING , t , 0 , ast , null , null , null ) ;
114131 }
115132
133+
134+
116135 static createForEvent ( ast : AST , eventName : string , elementIndex : number ) : BindingRecord {
117- return new BindingRecord ( EVENT , 0 , ast , elementIndex , null , null , eventName , null , null , null ) ;
136+ var t = new BindingTarget ( EVENT , elementIndex , eventName , null , ast . toString ( ) ) ;
137+ return new BindingRecord ( EVENT , t , 0 , ast , null , null , null ) ;
118138 }
119139
120140 static createForHostEvent ( ast : AST , eventName : string ,
121141 directiveRecord : DirectiveRecord ) : BindingRecord {
122142 var directiveIndex = directiveRecord . directiveIndex ;
123- return new BindingRecord ( EVENT , directiveIndex , ast , directiveIndex . elementIndex , null , null ,
124- eventName , null , null , directiveRecord ) ;
143+ var t =
144+ new BindingTarget ( HOST_EVENT , directiveIndex . elementIndex , eventName , null , ast . toString ( ) ) ;
145+ return new BindingRecord ( HOST_EVENT , t , directiveIndex , ast , null , null , directiveRecord ) ;
125146 }
126147}
0 commit comments