File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed
src/platforms/web/runtime/components
test/unit/modules/vdom/modules Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ export default {
49
49
50
50
// filter out text nodes (possible whitespaces)
51
51
children = children . filter ( c => c . tag )
52
+ /* istanbul ignore if */
52
53
if ( ! children . length ) {
53
54
return
54
55
}
Original file line number Diff line number Diff line change
1
+ import Vue from 'vue'
1
2
import { patch } from 'web/runtime/patch'
2
3
import VNode from 'core/vdom/vnode'
3
4
import { xlinkNS } from 'web/util/index'
@@ -74,4 +75,28 @@ describe('vdom attrs module', () => {
74
75
const elm = patch ( null , vnode )
75
76
expect ( elm . getAttributeNS ( xlinkNS , 'disabled' ) ) . toBe ( 'true' )
76
77
} )
78
+
79
+ it ( 'should handle mutating observed attrs object' , done => {
80
+ const vm = new Vue ( {
81
+ data : {
82
+ attrs : {
83
+ id : 'foo'
84
+ }
85
+ } ,
86
+ render ( h ) {
87
+ return h ( 'div' , {
88
+ attrs : this . attrs
89
+ } )
90
+ }
91
+ } ) . $mount ( )
92
+
93
+ expect ( vm . $el . id ) . toBe ( 'foo' )
94
+ vm . attrs . id = 'bar'
95
+ waitForUpdate ( ( ) => {
96
+ expect ( vm . $el . id ) . toBe ( 'bar' )
97
+ vm . attrs = { id : 'baz' }
98
+ } ) . then ( ( ) => {
99
+ expect ( vm . $el . id ) . toBe ( 'baz' )
100
+ } ) . then ( done )
101
+ } )
77
102
} )
Original file line number Diff line number Diff line change
1
+ import Vue from 'vue'
1
2
import { patch } from 'web/runtime/patch'
2
3
import VNode from 'core/vdom/vnode'
3
4
@@ -52,4 +53,28 @@ describe('vdom domProps module', () => {
52
53
expect ( elm2 . textContent ) . toBe ( 'hi' )
53
54
expect ( vnode2 . children . length ) . toBe ( 0 )
54
55
} )
56
+
57
+ it ( 'should handle mutating observed props object' , done => {
58
+ const vm = new Vue ( {
59
+ data : {
60
+ props : {
61
+ id : 'foo'
62
+ }
63
+ } ,
64
+ render ( h ) {
65
+ return h ( 'div' , {
66
+ domProps : this . props
67
+ } )
68
+ }
69
+ } ) . $mount ( )
70
+
71
+ expect ( vm . $el . id ) . toBe ( 'foo' )
72
+ vm . props . id = 'bar'
73
+ waitForUpdate ( ( ) => {
74
+ expect ( vm . $el . id ) . toBe ( 'bar' )
75
+ vm . props = { id : 'baz' }
76
+ } ) . then ( ( ) => {
77
+ expect ( vm . $el . id ) . toBe ( 'baz' )
78
+ } ) . then ( done )
79
+ } )
55
80
} )
You can’t perform that action at this time.
0 commit comments