File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
test/unit/features/options Expand file tree Collapse file tree 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) {
257257 const props = vm . $options . props
258258 for ( const key in methods ) {
259259 if ( process . env . NODE_ENV !== 'production' ) {
260- if ( methods [ key ] == null ) {
260+ if ( typeof methods [ key ] ! == 'function' ) {
261261 warn (
262- `Method "${ key } " has an undefined value in the component definition. ` +
262+ `Method "${ key } " has type " ${ typeof methods [ key ] } " in the component definition. ` +
263263 `Did you reference the function correctly?` ,
264264 vm
265265 )
@@ -277,7 +277,7 @@ function initMethods (vm: Component, methods: Object) {
277277 )
278278 }
279279 }
280- vm [ key ] = methods [ key ] == null ? noop : bind ( methods [ key ] , vm )
280+ vm [ key ] = typeof methods [ key ] ! == 'function' ? noop : bind ( methods [ key ] , vm )
281281 }
282282}
283283
Original file line number Diff line number Diff line change @@ -19,13 +19,13 @@ describe('Options methods', () => {
1919 expect ( vm . a ) . toBe ( 2 )
2020 } )
2121
22- it ( 'should warn undefined methods' , ( ) => {
22+ it ( 'should warn methods of not function type ' , ( ) => {
2323 new Vue ( {
2424 methods : {
25- hello : undefined
25+ hello : { }
2626 }
2727 } )
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 ( )
2929 } )
3030
3131 it ( 'should warn methods conflicting with data' , ( ) => {
You can’t perform that action at this time.
0 commit comments