File tree Expand file tree Collapse file tree 3 files changed +22
-10
lines changed
src/platforms/web/runtime/modules Expand file tree Collapse file tree 3 files changed +22
-10
lines changed Original file line number Diff line number Diff line change 11/* @flow */
22
3+ import { extend } from 'shared/util'
34import {
45 isBooleanAttr ,
56 isEnumeratedAttr ,
@@ -16,11 +17,14 @@ function updateAttrs (oldVnode: VNodeWithData, vnode: VNodeWithData) {
1617 let key , cur , old
1718 const elm = vnode . elm
1819 const oldAttrs = oldVnode . data . attrs || { }
19- const attrs = vnode . data . attrs || { }
20- const clonedAttrs = vnode . data . attrs = { }
20+ let attrs = vnode . data . attrs || { }
21+ // clone observed objects, as the user probably wants to mutate it
22+ if ( attrs . __ob__ ) {
23+ attrs = vnode . data . attrs = extend ( { } , attrs )
24+ }
2125
2226 for ( key in attrs ) {
23- cur = clonedAttrs [ key ] = attrs [ key ]
27+ cur = attrs [ key ]
2428 old = oldAttrs [ key ]
2529 if ( old !== cur ) {
2630 setAttr ( elm , key , cur )
Original file line number Diff line number Diff line change 11/* @flow */
22
3+ import { extend } from 'shared/util'
4+
35function updateDOMProps ( oldVnode : VNodeWithData , vnode : VNodeWithData ) {
46 if ( ! oldVnode . data . domProps && ! vnode . data . domProps ) {
57 return
68 }
79 let key , cur
810 const elm : any = vnode . elm
911 const oldProps = oldVnode . data . domProps || { }
10- const props = vnode . data . domProps || { }
11- const clonedProps = vnode . data . domProps = { }
12+ let props = vnode . data . domProps || { }
13+ // clone observed objects, as the user probably wants to mutate it
14+ if ( props . __ob__ ) {
15+ props = vnode . data . domProps = extend ( { } , props )
16+ }
1217
1318 for ( key in oldProps ) {
1419 if ( props [ key ] == null ) {
1520 elm [ key ] = undefined
1621 }
1722 }
1823 for ( key in props ) {
19- cur = clonedProps [ key ] = props [ key ]
24+ cur = props [ key ]
2025 if ( key === 'value' ) {
2126 // store value as _value as well since
2227 // non-string values will be stringified
Original file line number Diff line number Diff line change 11/* @flow */
22
3- import { cached , camelize , toObject } from 'shared/util'
3+ import { cached , extend , camelize , toObject } from 'shared/util'
44
55const prefixes = [ 'Webkit' , 'Moz' , 'ms' ]
66
@@ -28,23 +28,26 @@ function updateStyle (oldVnode: VNodeWithData, vnode: VNodeWithData) {
2828 const elm : any = vnode . elm
2929 const oldStyle : any = oldVnode . data . style || { }
3030 let style = vnode . data . style || { }
31+ const needClone = style . __ob__
3132
3233 // handle array syntax
3334 if ( Array . isArray ( style ) ) {
34- style = toObject ( style )
35+ style = vnode . data . style = toObject ( style )
3536 }
3637
3738 // clone the style for future updates,
3839 // in case the user mutates the style object in-place.
39- const clonedStyle = vnode . data . style = { }
40+ if ( needClone ) {
41+ style = vnode . data . style = extend ( { } , style )
42+ }
4043
4144 for ( name in oldStyle ) {
4245 if ( ! style [ name ] ) {
4346 elm . style [ normalize ( name ) ] = ''
4447 }
4548 }
4649 for ( name in style ) {
47- cur = clonedStyle [ name ] = style [ name ]
50+ cur = style [ name ]
4851 if ( cur !== oldStyle [ name ] ) {
4952 // ie9 setting to null has no effect, must use empty string
5053 elm . style [ normalize ( name ) ] = cur || ''
You can’t perform that action at this time.
0 commit comments