@@ -5,13 +5,17 @@ import {DirectiveIndex, DirectiveRecord} from './directive_record';
55
66const DIRECTIVE = "directive" ;
77const DIRECTIVE_LIFECYCLE = "directiveLifecycle" ;
8- const ELEMENT = "element" ;
8+ const ELEMENT_PROPERTY = "elementProperty" ;
9+ const ELEMENT_ATTRIBUTE = "elementAttribute" ;
10+ const ELEMENT_CLASS = "elementClass" ;
11+ const ELEMENT_STYLE = "elementStyle" ;
912const TEXT_NODE = "textNode" ;
1013
1114export class BindingRecord {
1215 constructor ( public mode : string , public implicitReceiver : any , public ast : AST ,
13- public elementIndex : number , public propertyName : string , public setter : SetterFn ,
14- public lifecycleEvent : string , public directiveRecord : DirectiveRecord ) { }
16+ public elementIndex : number , public propertyName : string , public propertyUnit : string ,
17+ public setter : SetterFn , public lifecycleEvent : string ,
18+ public directiveRecord : DirectiveRecord ) { }
1519
1620 callOnChange ( ) : boolean {
1721 return isPresent ( this . directiveRecord ) && this . directiveRecord . callOnChange ;
@@ -25,41 +29,85 @@ export class BindingRecord {
2529
2630 isDirectiveLifecycle ( ) : boolean { return this . mode === DIRECTIVE_LIFECYCLE ; }
2731
28- isElement ( ) : boolean { return this . mode === ELEMENT ; }
32+ isElementProperty ( ) : boolean { return this . mode === ELEMENT_PROPERTY ; }
33+
34+ isElementAttribute ( ) : boolean { return this . mode === ELEMENT_ATTRIBUTE ; }
35+
36+ isElementClass ( ) : boolean { return this . mode === ELEMENT_CLASS ; }
37+
38+ isElementStyle ( ) : boolean { return this . mode === ELEMENT_STYLE ; }
2939
3040 isTextNode ( ) : boolean { return this . mode === TEXT_NODE ; }
3141
3242 static createForDirective ( ast : AST , propertyName : string , setter : SetterFn ,
3343 directiveRecord : DirectiveRecord ) : BindingRecord {
34- return new BindingRecord ( DIRECTIVE , 0 , ast , 0 , propertyName , setter , null , directiveRecord ) ;
44+ return new BindingRecord ( DIRECTIVE , 0 , ast , 0 , propertyName , null , setter , null ,
45+ directiveRecord ) ;
3546 }
3647
3748 static createDirectiveOnCheck ( directiveRecord : DirectiveRecord ) : BindingRecord {
38- return new BindingRecord ( DIRECTIVE_LIFECYCLE , 0 , null , 0 , null , null , "onCheck" ,
49+ return new BindingRecord ( DIRECTIVE_LIFECYCLE , 0 , null , 0 , null , null , null , "onCheck" ,
3950 directiveRecord ) ;
4051 }
4152
4253 static createDirectiveOnInit ( directiveRecord : DirectiveRecord ) : BindingRecord {
43- return new BindingRecord ( DIRECTIVE_LIFECYCLE , 0 , null , 0 , null , null , "onInit" ,
54+ return new BindingRecord ( DIRECTIVE_LIFECYCLE , 0 , null , 0 , null , null , null , "onInit" ,
4455 directiveRecord ) ;
4556 }
4657
4758 static createDirectiveOnChange ( directiveRecord : DirectiveRecord ) : BindingRecord {
48- return new BindingRecord ( DIRECTIVE_LIFECYCLE , 0 , null , 0 , null , null , "onChange" ,
59+ return new BindingRecord ( DIRECTIVE_LIFECYCLE , 0 , null , 0 , null , null , null , "onChange" ,
4960 directiveRecord ) ;
5061 }
5162
52- static createForElement ( ast : AST , elementIndex : number , propertyName : string ) : BindingRecord {
53- return new BindingRecord ( ELEMENT , 0 , ast , elementIndex , propertyName , null , null , null ) ;
63+ static createForElementProperty ( ast : AST , elementIndex : number ,
64+ propertyName : string ) : BindingRecord {
65+ return new BindingRecord ( ELEMENT_PROPERTY , 0 , ast , elementIndex , propertyName , null , null , null ,
66+ null ) ;
67+ }
68+
69+ static createForElementAttribute ( ast : AST , elementIndex : number ,
70+ attributeName : string ) : BindingRecord {
71+ return new BindingRecord ( ELEMENT_ATTRIBUTE , 0 , ast , elementIndex , attributeName , null , null ,
72+ null , null ) ;
73+ }
74+
75+ static createForElementClass ( ast : AST , elementIndex : number , className : string ) : BindingRecord {
76+ return new BindingRecord ( ELEMENT_CLASS , 0 , ast , elementIndex , className , null , null , null ,
77+ null ) ;
78+ }
79+
80+ static createForElementStyle ( ast : AST , elementIndex : number , styleName : string ,
81+ unit : string ) : BindingRecord {
82+ return new BindingRecord ( ELEMENT_STYLE , 0 , ast , elementIndex , styleName , unit , null , null ,
83+ null ) ;
5484 }
5585
5686 static createForHostProperty ( directiveIndex : DirectiveIndex , ast : AST ,
5787 propertyName : string ) : BindingRecord {
58- return new BindingRecord ( ELEMENT , directiveIndex , ast , directiveIndex . elementIndex ,
59- propertyName , null , null , null ) ;
88+ return new BindingRecord ( ELEMENT_PROPERTY , directiveIndex , ast , directiveIndex . elementIndex ,
89+ propertyName , null , null , null , null ) ;
90+ }
91+
92+ static createForHostAttribute ( directiveIndex : DirectiveIndex , ast : AST ,
93+ attributeName : string ) : BindingRecord {
94+ return new BindingRecord ( ELEMENT_ATTRIBUTE , directiveIndex , ast , directiveIndex . elementIndex ,
95+ attributeName , null , null , null , null ) ;
96+ }
97+
98+ static createForHostClass ( directiveIndex : DirectiveIndex , ast : AST ,
99+ className : string ) : BindingRecord {
100+ return new BindingRecord ( ELEMENT_CLASS , directiveIndex , ast , directiveIndex . elementIndex ,
101+ className , null , null , null , null ) ;
102+ }
103+
104+ static createForHostStyle ( directiveIndex : DirectiveIndex , ast : AST , styleName : string ,
105+ unit : string ) : BindingRecord {
106+ return new BindingRecord ( ELEMENT_STYLE , directiveIndex , ast , directiveIndex . elementIndex ,
107+ styleName , unit , null , null , null ) ;
60108 }
61109
62110 static createForTextNode ( ast : AST , elementIndex : number ) : BindingRecord {
63- return new BindingRecord ( TEXT_NODE , 0 , ast , elementIndex , null , null , null , null ) ;
111+ return new BindingRecord ( TEXT_NODE , 0 , ast , elementIndex , null , null , null , null , null ) ;
64112 }
65113}
0 commit comments