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
Allow for passing null / undefined into a typed, none required prop #2411
Comments
Shouldn't the prop check for a default value first? It would keep it more in line with what happens if you omit the prop completely. Here's another JSBin showing the different ways to pass a non value prop through. I'm thinking it should fall back to the default value in all cases. |
I have thought about this before, and didn't implement it because user may explicitly want to pass down undefined - but now I think it is appropriate to map it to the semantics of JS function calls so that default value would be used if the passed down prop is undefined. |
See 04116fc |
Thanks. I was going to suggest a |
@yyx990803 I'm a bit confused by the commit, it says `if (raw === null) {
but I can't see any code for handling undefined, and the commit actually says that if it is null, then it's set to default. when is undefined passed as a prop handled? |
// check default value I found this bit in vue.js v2 dist, is it around this part that defaults are now handled? I can't find a comment of Build a function that applies props to a vm. anywhere in the current v2 vue.js build |
If a prop is declared with type validation but
required:false
, the validation will fail when passing either null or undefined as the value.I think that the type validation should only occur on none required props if an actual value (not null or undefined) has been passed. I believe this is similar to issue #1070.
Here's a JSBin demonstrating this.
The text was updated successfully, but these errors were encountered: