From 622e87c196c67cebef33750adf6527b79bdc930c Mon Sep 17 00:00:00 2001 From: Kingdaro Date: Sat, 10 Sep 2016 16:18:21 -0400 Subject: [PATCH 1/3] add undefined check for instance methods --- src/core/instance/state.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/instance/state.js b/src/core/instance/state.js index b6a104f0170..79d09353f18 100644 --- a/src/core/instance/state.js +++ b/src/core/instance/state.js @@ -142,7 +142,9 @@ function initMethods (vm: Component) { const methods = vm.$options.methods if (methods) { for (const key in methods) { - vm[key] = bind(methods[key], vm) + if (methods[key] != null) { + vm[key] = bind(methods[key], vm) + } } } } From 3cb17d419788cef84d3c800f12c368e83c79bc5b Mon Sep 17 00:00:00 2001 From: Kingdaro Date: Sat, 10 Sep 2016 16:22:34 -0400 Subject: [PATCH 2/3] added a warning for undefined methods --- src/core/instance/state.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/instance/state.js b/src/core/instance/state.js index 79d09353f18..1ba5044927a 100644 --- a/src/core/instance/state.js +++ b/src/core/instance/state.js @@ -144,6 +144,8 @@ function initMethods (vm: Component) { for (const key in methods) { if (methods[key] != null) { vm[key] = bind(methods[key], vm) + } else { + warn(`The method ${key} on vue instance is undefined.`, vm) } } } From 236fdc30c79dd4d35b755e353bf2a586a494dd09 Mon Sep 17 00:00:00 2001 From: Darius Tall Date: Sun, 11 Sep 2016 09:14:25 -0400 Subject: [PATCH 3/3] add production ENV check --- src/core/instance/state.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/instance/state.js b/src/core/instance/state.js index 1ba5044927a..8a7545f9bd9 100644 --- a/src/core/instance/state.js +++ b/src/core/instance/state.js @@ -144,7 +144,7 @@ function initMethods (vm: Component) { for (const key in methods) { if (methods[key] != null) { vm[key] = bind(methods[key], vm) - } else { + } else if (process.env.NODE_ENV !== 'production') { warn(`The method ${key} on vue instance is undefined.`, vm) } }