@@ -65,6 +65,58 @@ export function main() {
65
65
} ) ;
66
66
} ) ) ;
67
67
68
+ it ( 'should add and remove styles specified using style.unit notation' ,
69
+ inject (
70
+ [ TestComponentBuilder , AsyncTestCompleter ] ,
71
+ ( tcb : TestComponentBuilder , async : AsyncTestCompleter ) => {
72
+ var template = `<div [ngStyle]="{'max-width.px': expr}"></div>` ;
73
+
74
+ tcb . overrideTemplate ( TestComponent , template )
75
+ . createAsync ( TestComponent )
76
+ . then ( ( fixture ) => {
77
+
78
+ fixture . debugElement . componentInstance . expr = '40' ;
79
+ fixture . detectChanges ( ) ;
80
+ expect ( getDOM ( ) . getStyle (
81
+ fixture . debugElement . children [ 0 ] . nativeElement , 'max-width' ) )
82
+ . toEqual ( '40px' ) ;
83
+
84
+ fixture . debugElement . componentInstance . expr = null ;
85
+ fixture . detectChanges ( ) ;
86
+ expect ( getDOM ( ) . getStyle (
87
+ fixture . debugElement . children [ 0 ] . nativeElement , 'max-width' ) )
88
+ . toEqual ( '' ) ;
89
+
90
+ async . done ( ) ;
91
+ } ) ;
92
+ } ) ) ;
93
+
94
+ it ( 'should update styles using style.unit notation when unit changes' ,
95
+ inject (
96
+ [ TestComponentBuilder , AsyncTestCompleter ] ,
97
+ ( tcb : TestComponentBuilder , async : AsyncTestCompleter ) => {
98
+ var template = `<div [ngStyle]="expr"></div>` ;
99
+
100
+ tcb . overrideTemplate ( TestComponent , template )
101
+ . createAsync ( TestComponent )
102
+ . then ( ( fixture ) => {
103
+
104
+ fixture . debugElement . componentInstance . expr = { 'max-width.px' : '40' } ;
105
+ fixture . detectChanges ( ) ;
106
+ expect ( getDOM ( ) . getStyle (
107
+ fixture . debugElement . children [ 0 ] . nativeElement , 'max-width' ) )
108
+ . toEqual ( '40px' ) ;
109
+
110
+ fixture . debugElement . componentInstance . expr = { 'max-width.em' : '40' } ;
111
+ fixture . detectChanges ( ) ;
112
+ expect ( getDOM ( ) . getStyle (
113
+ fixture . debugElement . children [ 0 ] . nativeElement , 'max-width' ) )
114
+ . toEqual ( '40em' ) ;
115
+
116
+ async . done ( ) ;
117
+ } ) ;
118
+ } ) ) ;
119
+
68
120
// keyValueDiffer is sensitive to key order #9115
69
121
it ( 'should change styles specified in an object expression' ,
70
122
inject (
0 commit comments