From 9b0db41fbe3172dafa184ea7261cb1f2d23bd755 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 13 Oct 2017 09:59:23 -0400 Subject: [PATCH] fix: v-on="object" listeners should fire after high-priority ones fix #6805 --- .../render-helpers/bind-object-listeners.js | 2 +- test/unit/features/directives/on.spec.js | 43 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/core/instance/render-helpers/bind-object-listeners.js b/src/core/instance/render-helpers/bind-object-listeners.js index e97540fdf4..5bfc751432 100644 --- a/src/core/instance/render-helpers/bind-object-listeners.js +++ b/src/core/instance/render-helpers/bind-object-listeners.js @@ -14,7 +14,7 @@ export function bindObjectListeners (data: any, value: any): VNodeData { for (const key in value) { const existing = on[key] const ours = value[key] - on[key] = existing ? [].concat(ours, existing) : ours + on[key] = existing ? [].concat(existing, ours) : ours } } } diff --git a/test/unit/features/directives/on.spec.js b/test/unit/features/directives/on.spec.js index b65ec37948..a32bcaab2d 100644 --- a/test/unit/features/directives/on.spec.js +++ b/test/unit/features/directives/on.spec.js @@ -759,7 +759,7 @@ describe('Directive v-on', () => { const mouseup = jasmine.createSpy('mouseup') const mousedown = jasmine.createSpy('mousedown') - var vm = new Vue({ + vm = new Vue({ el, template: ` { expect(mousedown.calls.count()).toBe(1) }) + // #6805 (v-on="object" bind order problem) + it('object syntax (no argument): should fire after high-priority listeners', done => { + const MyCheckbox = { + template: '', + props: { + value: false + }, + computed: { + model: { + get () { + return this.value + }, + set (val) { + this.$emit('input', val) + } + } + } + } + + vm = new Vue({ + el, + template: ` +
+ +
+ `, + components: { MyCheckbox }, + data: { + check: false + }, + methods: { + change () { + expect(this.check).toBe(true) + done() + } + } + }) + + vm.$el.querySelector('input').click() + }) + it('warn object syntax with modifier', () => { new Vue({ template: ``