Skip to content

fix: update context after setMethods #696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions packages/test-utils/src/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,11 @@ export default class Wrapper implements BaseWrapper {
// $FlowIgnore : Problem with possibly null this.vm
this.vm.$options.methods[key] = methods[key]
})

if (this.vnode) {
const context = this.vnode.context
if (context.$options.render) context._update(context._render())
}
}

/**
Expand Down Expand Up @@ -743,13 +748,6 @@ export default class Wrapper implements BaseWrapper {
eventObject.keyCode = modifiers[event[1]]
}

// If this element's event handler has been reset by setMethod, it won't trigger
// Make sure that this element is updated with the latest event handler
if (this.vnode) {
const context = this.vnode.context
if (context.$options.render) context._update(context._render())
}

this.element.dispatchEvent(eventObject)
if (this.vnode) {
orderWatchers(this.vm || this.vnode.context.$root)
Expand Down