@@ -19,6 +19,8 @@ import {DOM} from 'angular2/src/dom/dom_adapter';
19
19
import { DomTestbed , TestView , elRef } from './dom_testbed' ;
20
20
21
21
import { ViewDefinition , DirectiveMetadata , RenderViewRef } from 'angular2/src/render/api' ;
22
+ import { DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES } from 'angular2/src/render/dom/dom_renderer' ;
23
+ import { bind } from 'angular2/di' ;
22
24
23
25
export function main ( ) {
24
26
describe ( 'DomRenderer integration' , ( ) => {
@@ -126,6 +128,47 @@ export function main() {
126
128
} ) ;
127
129
} ) ) ;
128
130
131
+
132
+ it ( 'should NOT reflect property values as attributes if flag is NOT set' ,
133
+ inject ( [ AsyncTestCompleter , DomTestbed ] , ( async , tb ) => {
134
+ tb . compileAll ( [
135
+ someComponent ,
136
+ new ViewDefinition (
137
+ { componentId : 'someComponent' , template : '<input [title]="y">' , directives : [ ] } )
138
+ ] )
139
+ . then ( ( protoViewDtos ) => {
140
+ var rootView = tb . createRootView ( protoViewDtos [ 0 ] ) ;
141
+ var cmpView = tb . createComponentView ( rootView . viewRef , 0 , protoViewDtos [ 1 ] ) ;
142
+ var el = DOM . childNodes ( tb . rootEl ) [ 0 ] ;
143
+ tb . renderer . setElementProperty ( elRef ( cmpView . viewRef , 0 ) , 'maxLength' , '20' ) ;
144
+ expect ( ( < HTMLInputElement > el ) . getAttribute ( 'ng-reflect-max-length' ) ) . toEqual ( null ) ;
145
+ async . done ( ) ;
146
+ } ) ;
147
+ } ) ) ;
148
+
149
+ describe ( 'reflection' , ( ) => {
150
+ beforeEachBindings ( ( ) => [ bind ( DOM_REFLECT_PROPERTIES_AS_ATTRIBUTES ) . toValue ( true ) ] ) ;
151
+ it ( 'should reflect property values as attributes if flag is set' ,
152
+ inject ( [ AsyncTestCompleter , DomTestbed ] , ( async , tb ) => {
153
+ tb . compileAll ( [
154
+ someComponent ,
155
+ new ViewDefinition ( {
156
+ componentId : 'someComponent' ,
157
+ template : '<input [title]="y">' ,
158
+ directives : [ ]
159
+ } )
160
+ ] )
161
+ . then ( ( protoViewDtos ) => {
162
+ var rootView = tb . createRootView ( protoViewDtos [ 0 ] ) ;
163
+ var cmpView = tb . createComponentView ( rootView . viewRef , 0 , protoViewDtos [ 1 ] ) ;
164
+ var el = DOM . childNodes ( tb . rootEl ) [ 0 ] ;
165
+ tb . renderer . setElementProperty ( elRef ( cmpView . viewRef , 0 ) , 'maxLength' , '20' ) ;
166
+ expect ( ( < HTMLInputElement > el ) . getAttribute ( 'ng-reflect-max-length' ) ) . toEqual ( '20' ) ;
167
+ async . done ( ) ;
168
+ } ) ;
169
+ } ) ) ;
170
+ } ) ;
171
+
129
172
if ( DOM . supportsDOMEvents ( ) ) {
130
173
it ( 'should call actions on the element independent of the compilation' ,
131
174
inject ( [ AsyncTestCompleter , DomTestbed ] , ( async , tb ) => {
0 commit comments