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 {
4949
5050 // filter out text nodes (possible whitespaces)
5151 children = children . filter ( c => c . tag )
52+ /* istanbul ignore if */
5253 if ( ! children . length ) {
5354 return
5455 }
Original file line number Diff line number Diff line change 1+ import Vue from 'vue'
12import { patch } from 'web/runtime/patch'
23import VNode from 'core/vdom/vnode'
34import { xlinkNS } from 'web/util/index'
@@ -74,4 +75,28 @@ describe('vdom attrs module', () => {
7475 const elm = patch ( null , vnode )
7576 expect ( elm . getAttributeNS ( xlinkNS , 'disabled' ) ) . toBe ( 'true' )
7677 } )
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+ } )
77102} )
Original file line number Diff line number Diff line change 1+ import Vue from 'vue'
12import { patch } from 'web/runtime/patch'
23import VNode from 'core/vdom/vnode'
34
@@ -52,4 +53,28 @@ describe('vdom domProps module', () => {
5253 expect ( elm2 . textContent ) . toBe ( 'hi' )
5354 expect ( vnode2 . children . length ) . toBe ( 0 )
5455 } )
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+ } )
5580} )
You can’t perform that action at this time.
0 commit comments