File tree 2 files changed +6
-6
lines changed
test/unit/features/options
2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -257,9 +257,9 @@ function initMethods (vm: Component, methods: Object) {
257
257
const props = vm . $options . props
258
258
for ( const key in methods ) {
259
259
if ( process . env . NODE_ENV !== 'production' ) {
260
- if ( methods [ key ] == null ) {
260
+ if ( typeof methods [ key ] ! == 'function' ) {
261
261
warn (
262
- `Method "${ key } " has an undefined value in the component definition. ` +
262
+ `Method "${ key } " has type " ${ typeof methods [ key ] } " in the component definition. ` +
263
263
`Did you reference the function correctly?` ,
264
264
vm
265
265
)
@@ -277,7 +277,7 @@ function initMethods (vm: Component, methods: Object) {
277
277
)
278
278
}
279
279
}
280
- vm [ key ] = methods [ key ] == null ? noop : bind ( methods [ key ] , vm )
280
+ vm [ key ] = typeof methods [ key ] ! == 'function' ? noop : bind ( methods [ key ] , vm )
281
281
}
282
282
}
283
283
Original file line number Diff line number Diff line change @@ -19,13 +19,13 @@ describe('Options methods', () => {
19
19
expect ( vm . a ) . toBe ( 2 )
20
20
} )
21
21
22
- it ( 'should warn undefined methods' , ( ) => {
22
+ it ( 'should warn methods of not function type ' , ( ) => {
23
23
new Vue ( {
24
24
methods : {
25
- hello : undefined
25
+ hello : { }
26
26
}
27
27
} )
28
- expect ( ` Method "hello" has an undefined value in the component definition` ) . toHaveBeenWarned ( )
28
+ expect ( ' Method "hello" has type "object" in the component definition' ) . toHaveBeenWarned ( )
29
29
} )
30
30
31
31
it ( 'should warn methods conflicting with data' , ( ) => {
You can’t perform that action at this time.
0 commit comments