Evan You 10 anni fa
parent
commit
e1ab28c8c6

+ 1 - 0
src/platforms/web/runtime/components/transition.js

@@ -49,6 +49,7 @@ export default {
 
     // filter out text nodes (possible whitespaces)
     children = children.filter(c => c.tag)
+    /* istanbul ignore if */
     if (!children.length) {
       return
     }

+ 25 - 0
test/unit/modules/vdom/modules/attrs.spec.js

@@ -1,3 +1,4 @@
+import Vue from 'vue'
 import { patch } from 'web/runtime/patch'
 import VNode from 'core/vdom/vnode'
 import { xlinkNS } from 'web/util/index'
@@ -74,4 +75,28 @@ describe('vdom attrs module', () => {
     const elm = patch(null, vnode)
     expect(elm.getAttributeNS(xlinkNS, 'disabled')).toBe('true')
   })
+
+  it('should handle mutating observed attrs object', done => {
+    const vm = new Vue({
+      data: {
+        attrs: {
+          id: 'foo'
+        }
+      },
+      render (h) {
+        return h('div', {
+          attrs: this.attrs
+        })
+      }
+    }).$mount()
+
+    expect(vm.$el.id).toBe('foo')
+    vm.attrs.id = 'bar'
+    waitForUpdate(() => {
+      expect(vm.$el.id).toBe('bar')
+      vm.attrs = { id: 'baz' }
+    }).then(() => {
+      expect(vm.$el.id).toBe('baz')
+    }).then(done)
+  })
 })

+ 25 - 0
test/unit/modules/vdom/modules/dom-props.spec.js

@@ -1,3 +1,4 @@
+import Vue from 'vue'
 import { patch } from 'web/runtime/patch'
 import VNode from 'core/vdom/vnode'
 
@@ -52,4 +53,28 @@ describe('vdom domProps module', () => {
     expect(elm2.textContent).toBe('hi')
     expect(vnode2.children.length).toBe(0)
   })
+
+  it('should handle mutating observed props object', done => {
+    const vm = new Vue({
+      data: {
+        props: {
+          id: 'foo'
+        }
+      },
+      render (h) {
+        return h('div', {
+          domProps: this.props
+        })
+      }
+    }).$mount()
+
+    expect(vm.$el.id).toBe('foo')
+    vm.props.id = 'bar'
+    waitForUpdate(() => {
+      expect(vm.$el.id).toBe('bar')
+      vm.props = { id: 'baz' }
+    }).then(() => {
+      expect(vm.$el.id).toBe('baz')
+    }).then(done)
+  })
 })