Skip to content

Commit e1ab28c

Browse files
committed
improve coverage
1 parent 7f429e9 commit e1ab28c

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

src/platforms/web/runtime/components/transition.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
}

test/unit/modules/vdom/modules/attrs.spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Vue from 'vue'
12
import { patch } from 'web/runtime/patch'
23
import VNode from 'core/vdom/vnode'
34
import { 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
})

test/unit/modules/vdom/modules/dom-props.spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Vue from 'vue'
12
import { patch } from 'web/runtime/patch'
23
import 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
})

0 commit comments

Comments
 (0)