@@ -104,42 +104,53 @@ export function main() {
104104 var pv = builder . build ( new DomElementSchemaRegistry ( ) , templateCloner ) ;
105105 expect ( pv . elementBinders [ 0 ] . propertyBindings [ 0 ] . property ) . toEqual ( 'readOnly' ) ;
106106 } ) ;
107-
108107 } ) ;
109108
110- describe ( 'property binding types' , ( ) => {
111- it ( 'should detect property names' , ( ) => {
112- builder . bindElement ( el ( '<div/>' ) ) . bindProperty ( 'tabindex' , emptyExpr ( ) ) ;
113- var pv = builder . build ( new DomElementSchemaRegistry ( ) , templateCloner ) ;
114- expect ( pv . elementBinders [ 0 ] . propertyBindings [ 0 ] . type ) . toEqual ( PropertyBindingType . PROPERTY ) ;
115- } ) ;
109+ describe ( 'property binding' , ( ) => {
110+ describe ( 'types' , ( ) => {
111+ it ( 'should detect property names' , ( ) => {
112+ builder . bindElement ( el ( '<div/>' ) ) . bindProperty ( 'tabindex' , emptyExpr ( ) ) ;
113+ var pv = builder . build ( new DomElementSchemaRegistry ( ) , templateCloner ) ;
114+ expect ( pv . elementBinders [ 0 ] . propertyBindings [ 0 ] . type )
115+ . toEqual ( PropertyBindingType . PROPERTY ) ;
116+ } ) ;
116117
117- it ( 'should detect attribute names' , ( ) => {
118- builder . bindElement ( el ( '<div/>' ) ) . bindProperty ( 'attr.someName' , emptyExpr ( ) ) ;
119- var pv = builder . build ( new DomElementSchemaRegistry ( ) , templateCloner ) ;
120- expect ( pv . elementBinders [ 0 ] . propertyBindings [ 0 ] . type )
121- . toEqual ( PropertyBindingType . ATTRIBUTE ) ;
122- } ) ;
118+ it ( 'should detect attribute names' , ( ) => {
119+ builder . bindElement ( el ( '<div/>' ) ) . bindProperty ( 'attr.someName' , emptyExpr ( ) ) ;
120+ var pv = builder . build ( new DomElementSchemaRegistry ( ) , templateCloner ) ;
121+ expect ( pv . elementBinders [ 0 ] . propertyBindings [ 0 ] . type )
122+ . toEqual ( PropertyBindingType . ATTRIBUTE ) ;
123+ } ) ;
123124
124- it ( 'should detect class names' , ( ) => {
125- builder . bindElement ( el ( '<div/>' ) ) . bindProperty ( 'class.someName' , emptyExpr ( ) ) ;
126- var pv = builder . build ( new DomElementSchemaRegistry ( ) , templateCloner ) ;
127- expect ( pv . elementBinders [ 0 ] . propertyBindings [ 0 ] . type ) . toEqual ( PropertyBindingType . CLASS ) ;
128- } ) ;
125+ it ( 'should detect class names' , ( ) => {
126+ builder . bindElement ( el ( '<div/>' ) ) . bindProperty ( 'class.someName' , emptyExpr ( ) ) ;
127+ var pv = builder . build ( new DomElementSchemaRegistry ( ) , templateCloner ) ;
128+ expect ( pv . elementBinders [ 0 ] . propertyBindings [ 0 ] . type ) . toEqual ( PropertyBindingType . CLASS ) ;
129+ } ) ;
129130
130- it ( 'should detect style names' , ( ) => {
131- builder . bindElement ( el ( '<div/>' ) ) . bindProperty ( 'style.someName' , emptyExpr ( ) ) ;
132- var pv = builder . build ( new DomElementSchemaRegistry ( ) , templateCloner ) ;
133- expect ( pv . elementBinders [ 0 ] . propertyBindings [ 0 ] . type ) . toEqual ( PropertyBindingType . STYLE ) ;
134- } ) ;
131+ it ( 'should detect style names' , ( ) => {
132+ builder . bindElement ( el ( '<div/>' ) ) . bindProperty ( 'style.someName' , emptyExpr ( ) ) ;
133+ var pv = builder . build ( new DomElementSchemaRegistry ( ) , templateCloner ) ;
134+ expect ( pv . elementBinders [ 0 ] . propertyBindings [ 0 ] . type ) . toEqual ( PropertyBindingType . STYLE ) ;
135+ } ) ;
135136
136- it ( 'should detect style units' , ( ) => {
137- builder . bindElement ( el ( '<div/>' ) ) . bindProperty ( 'style.someName.someUnit' , emptyExpr ( ) ) ;
138- var pv = builder . build ( new DomElementSchemaRegistry ( ) , templateCloner ) ;
139- expect ( pv . elementBinders [ 0 ] . propertyBindings [ 0 ] . unit ) . toEqual ( 'someUnit' ) ;
137+ it ( 'should detect style units' , ( ) => {
138+ builder . bindElement ( el ( '<div/>' ) ) . bindProperty ( 'style.someName.someUnit' , emptyExpr ( ) ) ;
139+ var pv = builder . build ( new DomElementSchemaRegistry ( ) , templateCloner ) ;
140+ expect ( pv . elementBinders [ 0 ] . propertyBindings [ 0 ] . unit ) . toEqual ( 'someUnit' ) ;
141+ } ) ;
140142 } ) ;
141- } ) ;
142143
144+ it ( 'should not create a property binding when there is already same directive property binding' ,
145+ ( ) => {
146+ var binder = builder . bindElement ( el ( '<div/>' ) ) ;
143147
148+ binder . bindProperty ( 'tabindex' , emptyExpr ( ) ) ;
149+ binder . bindDirective ( 0 ) . bindProperty ( 'tabindex' , emptyExpr ( ) , 'tabindex' ) ;
150+
151+ var pv = builder . build ( new DomElementSchemaRegistry ( ) , templateCloner ) ;
152+ expect ( pv . elementBinders [ 0 ] . propertyBindings . length ) . toEqual ( 0 ) ;
153+ } ) ;
154+ } ) ;
144155 } ) ;
145156}
0 commit comments