File tree Expand file tree Collapse file tree 2 files changed +22
-8
lines changed
src/platforms/web/runtime/modules
test/unit/features/directives Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,12 @@ function updateStyle (oldVnode: VNodeWithData, vnode: VNodeWithData) {
42
42
43
43
let cur , name
44
44
const el : any = vnode . elm
45
- const oldStyle : any = oldVnode . data . style || { }
45
+ const oldStaticStyle : any = oldVnode . data . staticStyle
46
+ const oldStyleBinding : any = oldVnode . data . style || { }
47
+
48
+ // if static style exists, stylebinding already merged into it when doing normalizeStyleData
49
+ const oldStyle = oldStaticStyle || oldStyleBinding
50
+
46
51
const style = normalizeStyleBinding ( vnode . data . style ) || { }
47
52
48
53
vnode . data . style = style . __ob__ ? extend ( { } , style ) : style
Original file line number Diff line number Diff line change @@ -280,19 +280,28 @@ describe('Directive v-bind:style', () => {
280
280
281
281
it ( 'should not merge for different adjacent elements' , ( done ) => {
282
282
const vm = new Vue ( {
283
- template : '<div>' +
284
- '<section style="color: blue" v-if="!bool"></section>' +
285
- '<div></div>' +
286
- '<section style="margin: 0" v-if="bool"></section>' +
287
- '</div>' ,
283
+ template :
284
+ '<div>' +
285
+ '<section style="color: blue" :style="style" v-if="!bool"></section>' +
286
+ '<div></div>' +
287
+ '<section style="margin-top: 12px" v-if="bool"></section>' +
288
+ '</div>' ,
288
289
data : {
289
- bool : false
290
+ bool : false ,
291
+ style : {
292
+ fontSize : '12px'
293
+ }
290
294
}
291
295
} ) . $mount ( )
296
+ const style = vm . $el . children [ 0 ] . style
297
+ expect ( style . fontSize ) . toBe ( '12px' )
298
+ expect ( style . color ) . toBe ( 'blue' )
292
299
waitForUpdate ( ( ) => {
293
300
vm . bool = true
294
301
} ) . then ( ( ) => {
295
- expect ( vm . $el . children [ 1 ] . style . color ) . not . toBe ( 'blue' )
302
+ expect ( style . color ) . toBe ( '' )
303
+ expect ( style . fontSize ) . toBe ( '' )
304
+ expect ( style . marginTop ) . toBe ( '12px' )
296
305
} ) . then ( done )
297
306
} )
298
307
} )
You can’t perform that action at this time.
0 commit comments