Skip to content
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

add getTypeList to process mutli-type prop #3885

Merged
merged 4 commits into from Oct 10, 2016
Merged

add getTypeList to process mutli-type prop #3885

merged 4 commits into from Oct 10, 2016

Conversation

defcc
Copy link
Member

@defcc defcc commented Oct 9, 2016

the getType func only returns the first prop type, even if the prop type is an array.

Add getTypeList func to get prop types.
fix #3879

@@ -21,7 +21,7 @@ export function validateProp (
const absent = !hasOwn(propsData, key)
let value = propsData[key]
// handle boolean props
if (getType(prop.type) === 'Boolean') {
if (getTypeList(prop.type).indexOf('Boolean') >= 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function is pretty perf-sensitive, I'd suggest a isBooleanType(prop.type) function that:

  • If prop.type is Array, iterate with for and return if any equals 'Boolean'
  • otherwise just check === 'Boolean'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, got it

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

Successfully merging this pull request may close these issues.

Multi-type prop validation is not consistent
3 participants