-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Improve error msg for non-reactive properties #6735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove the code style changes? |
||
has(target, key) { | ||
const has = key in target | ||
const isAllowed = allowedGlobals(key) || key.charAt(0) === '_' | ||
if (!has && !isAllowed) { | ||
|
@@ -53,15 +55,15 @@ if (process.env.NODE_ENV !== 'production') { | |
} | ||
|
||
const getHandler = { | ||
get (target, key) { | ||
get(target, key) { | ||
if (typeof key === 'string' && !(key in target)) { | ||
warnNonPresent(target, key) | ||
} | ||
return target[key] | ||
} | ||
} | ||
|
||
initProxy = function initProxy (vm) { | ||
initProxy = function initProxy(vm) { | ||
if (hasProxy) { | ||
// determine which proxy handler to use | ||
const options = vm.$options | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to use concatenations for each line to avoid the whitespace between the lines.