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 1
1
/* @flow */
2
2
3
+ import { extend } from 'shared/util'
3
4
import {
4
5
isBooleanAttr ,
5
6
isEnumeratedAttr ,
@@ -16,11 +17,14 @@ function updateAttrs (oldVnode: VNodeWithData, vnode: VNodeWithData) {
16
17
let key , cur , old
17
18
const elm = vnode . elm
18
19
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
+ }
21
25
22
26
for ( key in attrs ) {
23
- cur = clonedAttrs [ key ] = attrs [ key ]
27
+ cur = attrs [ key ]
24
28
old = oldAttrs [ key ]
25
29
if ( old !== cur ) {
26
30
setAttr ( elm , key , cur )
Original file line number Diff line number Diff line change 1
1
/* @flow */
2
2
3
+ import { extend } from 'shared/util'
4
+
3
5
function updateDOMProps ( oldVnode : VNodeWithData , vnode : VNodeWithData ) {
4
6
if ( ! oldVnode . data . domProps && ! vnode . data . domProps ) {
5
7
return
6
8
}
7
9
let key , cur
8
10
const elm : any = vnode . elm
9
11
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
+ }
12
17
13
18
for ( key in oldProps ) {
14
19
if ( props [ key ] == null ) {
15
20
elm [ key ] = undefined
16
21
}
17
22
}
18
23
for ( key in props ) {
19
- cur = clonedProps [ key ] = props [ key ]
24
+ cur = props [ key ]
20
25
if ( key === 'value' ) {
21
26
// store value as _value as well since
22
27
// non-string values will be stringified
Original file line number Diff line number Diff line change 1
1
/* @flow */
2
2
3
- import { cached , camelize , toObject } from 'shared/util'
3
+ import { cached , extend , camelize , toObject } from 'shared/util'
4
4
5
5
const prefixes = [ 'Webkit' , 'Moz' , 'ms' ]
6
6
@@ -28,23 +28,26 @@ function updateStyle (oldVnode: VNodeWithData, vnode: VNodeWithData) {
28
28
const elm : any = vnode . elm
29
29
const oldStyle : any = oldVnode . data . style || { }
30
30
let style = vnode . data . style || { }
31
+ const needClone = style . __ob__
31
32
32
33
// handle array syntax
33
34
if ( Array . isArray ( style ) ) {
34
- style = toObject ( style )
35
+ style = vnode . data . style = toObject ( style )
35
36
}
36
37
37
38
// clone the style for future updates,
38
39
// 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
+ }
40
43
41
44
for ( name in oldStyle ) {
42
45
if ( ! style [ name ] ) {
43
46
elm . style [ normalize ( name ) ] = ''
44
47
}
45
48
}
46
49
for ( name in style ) {
47
- cur = clonedStyle [ name ] = style [ name ]
50
+ cur = style [ name ]
48
51
if ( cur !== oldStyle [ name ] ) {
49
52
// ie9 setting to null has no effect, must use empty string
50
53
elm . style [ normalize ( name ) ] = cur || ''
You can’t perform that action at this time.
0 commit comments