-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Closed
Description
Vue.js version
2.0.1
Reproduction Link
https://jsfiddle.net/alexman/f7sb0rd3/9/
Steps to reproduce
Create a component with a prop of type [String, Boolean] and instantiate it with a boolean value or shorthand prop notation. (<my-component my-prop></my-component>)
What is Expected?
Booleans are accepted and passed to the validator as a boolean value.
What is actually happening?
You'll see that it will not validate booleans / shorthand prop notation.
Defining it reversed, [Boolean, String], does seem to work as expected except for not being able to pass false as a value.
Observations
I noticed validateProp() does the following "magic", which doesn't seem to take the option of an array of types into account?
if (getType(prop.type) === 'Boolean') {
if (absent && !hasOwn(prop, 'default')) {
value = false
} else if (value === '' || value === hyphenate(key)) {
value = true
}
}
Metadata
Metadata
Assignees
Labels
No labels