File tree 2 files changed +25
-2
lines changed
2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,18 @@ export default function (Vue) {
38
38
if ( eventRE . test ( name ) ) {
39
39
name = name . replace ( eventRE , '' )
40
40
handler = ( vm . _scope || vm . _context ) . $eval ( attrs [ i ] . value , true )
41
- handler . _fromParent = true
42
- vm . $on ( name . replace ( eventRE ) , handler )
41
+ if ( typeof handler === 'function' ) {
42
+ handler . _fromParent = true
43
+ vm . $on ( name . replace ( eventRE ) , handler )
44
+ } else if ( process . env . NODE_ENV !== 'production' ) {
45
+ warn (
46
+ 'v-on:' + name + '="' + attrs [ i ] . value + '"' + (
47
+ vm . $options . name
48
+ ? ' on component <' + vm . $options . name + '>'
49
+ : ''
50
+ ) + ' expects a function value, got ' + handler
51
+ )
52
+ }
43
53
}
44
54
}
45
55
}
Original file line number Diff line number Diff line change @@ -237,6 +237,19 @@ describe('Instance Events', function () {
237
237
expect ( vm . a ) . toBe ( 1 )
238
238
} )
239
239
240
+ it ( 'warn missing handler for child component v-on' , function ( ) {
241
+ new Vue ( {
242
+ el : document . createElement ( 'div' ) ,
243
+ template : '<comp @test="onThat"></comp>' ,
244
+ components : {
245
+ comp : { }
246
+ }
247
+ } )
248
+ expect ( hasWarned (
249
+ 'v-on:test="onThat" on component <comp> expects a function value'
250
+ ) ) . toBe ( true )
251
+ } )
252
+
240
253
it ( 'passing $arguments' , function ( ) {
241
254
new Vue ( {
242
255
el : document . createElement ( 'div' ) ,
You can’t perform that action at this time.
0 commit comments