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) {
4242
4343 let cur , name
4444 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+
4651 const style = normalizeStyleBinding ( vnode . data . style ) || { }
4752
4853 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', () => {
280280
281281 it ( 'should not merge for different adjacent elements' , ( done ) => {
282282 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>' ,
288289 data : {
289- bool : false
290+ bool : false ,
291+ style : {
292+ fontSize : '12px'
293+ }
290294 }
291295 } ) . $mount ( )
296+ const style = vm . $el . children [ 0 ] . style
297+ expect ( style . fontSize ) . toBe ( '12px' )
298+ expect ( style . color ) . toBe ( 'blue' )
292299 waitForUpdate ( ( ) => {
293300 vm . bool = true
294301 } ) . 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' )
296305 } ) . then ( done )
297306 } )
298307} )
You can’t perform that action at this time.
0 commit comments