-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Compilation fails on empty values on v-bind #7973
Comments
You're not passing a null value as the :content - you're passing nothing. To properly pass a JS null it should be: Remember this is a "bound" attribute - the text inside the quotes is not used literally - its used as a JS expression, evaluated against the data/scope of the vue instance. |
Maybe a warning can be added in dev mode |
In the example given you are correct, but what if I were to pass along a null value from something like PHP though? It still fails, it acts as If I have not given it anything at all and the entire compilation breaks.
This is the bothersome part right here, it is that I am actually supplying a |
You should do
|
Note this is supposed to fail, because by definition, using createElement('review', { attrs: { content: }}) What we can do is giving a proper compilation warning instead of a runtime error. This can be a good first contribution. |
I'd like to have a try |
Related: #3969 |
By the way what is being suggested here by @jacekkarczmarczyk will not work for numbers since they are being converted to strings this way.
|
closed via #7940 |
* refactor: add empty v-bind warnings re vuejs#7973 * Update index.js
* refactor: add empty v-bind warnings re vuejs#7973 * Update index.js
Version
2.5.13
Reproduction link
https://jsfiddle.net/jt3hjuwg/
Steps to reproduce
I am referencing this closed issue:
#3969
I feel like something should be done about this issue because it has left me with some white pages along the way and without a clear error message. If you pass in a null value as a prop the entire compilation breaks down with your evaluated html simply being dumped into the console.
Is there really not a better way to handle this? Obviously a user should or could check for these values before actually showing the component but in large application a piece of data can sometimes be null either by accident or oversight
If nothing can be done about this could someone at least please explain why this happens because in my eyes a component not getting a prop does not justify the entire compilation failing.
What is expected?
The application should not fail compilation.
What is actually happening?
It fails compilation.
The text was updated successfully, but these errors were encountered: