Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ab12c7b

Browse filesBrowse files
committed
Merge pull request vuejs#2102 from rhyzx/fix-inline-statement-propagation
Fix inline statement propagation
2 parents 52e8638 + 130b747 commit ab12c7b
Copy full SHA for ab12c7b

File tree

Expand file treeCollapse file tree

2 files changed

+52
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+52
-1
lines changed

‎src/instance/api/data.js

Copy file name to clipboardExpand all lines: src/instance/api/data.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ export default function (Vue) {
2424
var self = this
2525
return function statementHandler () {
2626
self.$arguments = toArray(arguments)
27-
res.get.call(self, self)
27+
var result = res.get.call(self, self)
2828
self.$arguments = null
29+
return result
2930
}
3031
} else {
3132
try {

‎test/unit/specs/api/events_spec.js

Copy file name to clipboardExpand all lines: test/unit/specs/api/events_spec.js
+50Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,56 @@ describe('Events API', function () {
154154
expect(spy.calls.count()).toBe(2)
155155
})
156156

157+
it('handle $dispatch by v-on inline-statement', function () {
158+
var parent = new Vue({
159+
el: document.createElement('div'),
160+
template: '<child1 @test="onTest()" v-ref:child></child1>',
161+
methods: {
162+
onTest: function () {
163+
spy()
164+
}
165+
},
166+
components: {
167+
child1: {
168+
template: '<child2 @test="onTest()" v-ref:child></child2>',
169+
methods: {
170+
onTest: function () {
171+
spy()
172+
}
173+
},
174+
components: {
175+
child2: {
176+
template: '<child3 @test="onTest()" v-ref:child></child3>',
177+
methods: {
178+
onTest: function () {
179+
spy()
180+
return true
181+
}
182+
},
183+
components: {
184+
child3: {
185+
template: '<child4 v-ref:child></child4>',
186+
// `v-on` on component will be treat as its inner handler
187+
// so propagation cancelling is ignored on `<child4 @test="handler">`
188+
components: {
189+
child4: {}
190+
}
191+
}
192+
}
193+
}
194+
}
195+
}
196+
}
197+
})
198+
parent
199+
.$refs.child // child1
200+
.$refs.child // child2
201+
.$refs.child // child3
202+
.$refs.child // child4
203+
.$dispatch('test')
204+
expect(spy.calls.count()).toBe(2)
205+
})
206+
157207
it('$dispatch cancel', function () {
158208
var child = new Vue({ parent: vm })
159209
var child2 = new Vue({ parent: child })

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.