From 46976afa8287b2de762cb582d05732a4ac619e3d Mon Sep 17 00:00:00 2001 From: kutyel Date: Tue, 3 Oct 2017 16:29:15 +0200 Subject: [PATCH 1/2] Improve error msg for non-reactive properties --- src/core/instance/proxy.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/core/instance/proxy.js b/src/core/instance/proxy.js index 8e581877bde..c39a4ca41b6 100644 --- a/src/core/instance/proxy.js +++ b/src/core/instance/proxy.js @@ -15,9 +15,11 @@ if (process.env.NODE_ENV !== 'production') { const warnNonPresent = (target, key) => { warn( - `Property or method "${key}" is not defined on the instance but ` + - `referenced during render. Make sure to declare reactive data ` + - `properties in the data option.`, + `Property or method "${key}" is not defined on the instance but + referenced during render. Make sure that this property is reactive, + either in the data option, or for class-based components, by + initializing the property. + See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.`, target ) } @@ -29,7 +31,7 @@ if (process.env.NODE_ENV !== 'production') { if (hasProxy) { const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta') config.keyCodes = new Proxy(config.keyCodes, { - set (target, key, value) { + set(target, key, value) { if (isBuiltInModifier(key)) { warn(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`) return false @@ -42,7 +44,7 @@ if (process.env.NODE_ENV !== 'production') { } const hasHandler = { - has (target, key) { + has(target, key) { const has = key in target const isAllowed = allowedGlobals(key) || key.charAt(0) === '_' if (!has && !isAllowed) { @@ -53,7 +55,7 @@ if (process.env.NODE_ENV !== 'production') { } const getHandler = { - get (target, key) { + get(target, key) { if (typeof key === 'string' && !(key in target)) { warnNonPresent(target, key) } @@ -61,7 +63,7 @@ if (process.env.NODE_ENV !== 'production') { } } - initProxy = function initProxy (vm) { + initProxy = function initProxy(vm) { if (hasProxy) { // determine which proxy handler to use const options = vm.$options From 4aa5c94dd1a127dd976ed76e8ea4ed84dda3d34f Mon Sep 17 00:00:00 2001 From: Flavio Corpa Date: Tue, 3 Oct 2017 17:38:52 +0200 Subject: [PATCH 2/2] Concat strings --- src/core/instance/proxy.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/instance/proxy.js b/src/core/instance/proxy.js index c39a4ca41b6..2e45f4636a1 100644 --- a/src/core/instance/proxy.js +++ b/src/core/instance/proxy.js @@ -15,11 +15,11 @@ if (process.env.NODE_ENV !== 'production') { const warnNonPresent = (target, key) => { warn( - `Property or method "${key}" is not defined on the instance but - referenced during render. Make sure that this property is reactive, - either in the data option, or for class-based components, by - initializing the property. - See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.`, + `Property or method "${key}" is not defined on the instance but` + + 'referenced during render. Make sure that this property is reactive, ' + + 'either in the data option, or for class-based components, by ' + + 'initializing the property.' + + 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target ) } @@ -31,7 +31,7 @@ if (process.env.NODE_ENV !== 'production') { if (hasProxy) { const isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta') config.keyCodes = new Proxy(config.keyCodes, { - set(target, key, value) { + set (target, key, value) { if (isBuiltInModifier(key)) { warn(`Avoid overwriting built-in modifier in config.keyCodes: .${key}`) return false @@ -44,7 +44,7 @@ if (process.env.NODE_ENV !== 'production') { } const hasHandler = { - has(target, key) { + has (target, key) { const has = key in target const isAllowed = allowedGlobals(key) || key.charAt(0) === '_' if (!has && !isAllowed) { @@ -55,7 +55,7 @@ if (process.env.NODE_ENV !== 'production') { } const getHandler = { - get(target, key) { + get (target, key) { if (typeof key === 'string' && !(key in target)) { warnNonPresent(target, key) } @@ -63,7 +63,7 @@ if (process.env.NODE_ENV !== 'production') { } } - initProxy = function initProxy(vm) { + initProxy = function initProxy (vm) { if (hasProxy) { // determine which proxy handler to use const options = vm.$options