File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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 } )
You can’t perform that action at this time.
0 commit comments