diff --git a/src/core/instance/lifecycle.js b/src/core/instance/lifecycle.js index 501800dc996..27756af66fc 100644 --- a/src/core/instance/lifecycle.js +++ b/src/core/instance/lifecycle.js @@ -257,11 +257,10 @@ export function updateChildComponent ( } // update listeners - if (listeners) { - const oldListeners = vm.$options._parentListeners - vm.$options._parentListeners = listeners - updateComponentListeners(vm, listeners, oldListeners) - } + listeners = listeners || emptyObject + const oldListeners = vm.$options._parentListeners + vm.$options._parentListeners = listeners + updateComponentListeners(vm, listeners, oldListeners) // resolve slots + force update if has children if (hasChildren) { diff --git a/test/unit/modules/vdom/patch/edge-cases.spec.js b/test/unit/modules/vdom/patch/edge-cases.spec.js index c78a2fd24ba..df60d0132ee 100644 --- a/test/unit/modules/vdom/patch/edge-cases.spec.js +++ b/test/unit/modules/vdom/patch/edge-cases.spec.js @@ -301,4 +301,30 @@ describe('vdom patch: edge cases', () => { expect(vm.$el.children[0].style.color).toBe('green') }).then(done) }) + + // #7294 + it('should cleanup component inline events on patch when no events are present', done => { + const log = jasmine.createSpy() + const vm = new Vue({ + data: { ok: true }, + template: ` +
+ + +
+ `, + components: { + foo: { + render () {} + } + }, + methods: { log } + }).$mount() + + vm.ok = false + waitForUpdate(() => { + vm.$children[0].$emit('custom') + expect(log).not.toHaveBeenCalled() + }).then(done) + }) })