Skip to content

Invalid properties when passing empty string to a component #1107

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

Closed
benjaminreid opened this issue Jul 31, 2015 · 0 comments
Closed

Invalid properties when passing empty string to a component #1107

benjaminreid opened this issue Jul 31, 2015 · 0 comments

Comments

@benjaminreid
Copy link

Hello,

I have a simple component with a property of foo which defaults to empty string:

Vue.component('my-component', {
    template: '<pre>{{ $data | json }}</pre>',
    props: {
        foo: {
            type: String,
            default: ''
        }
    }
});

When using this component like so:

<my-component></my-component>

The result is as expected:

{
  "foo": ""
}

But when passing an empty string as a property value (I know this could be worked around, but it's a scenario that I've run into) like so:

<my-component foo=""></my-component>

The result is as follows with this error [Vue warn]: Invalid prop: type check failed for foo="". Expected String, got Number..

{}

I'd expect the property to still be an empty string. Is this a bug, or expected behaviour?

Fiddle for example: http://jsfiddle.net/6szLn2fm/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant