diff --git a/src/core/util/props.js b/src/core/util/props.js index 460481e3c1a..2e1991eda6f 100644 --- a/src/core/util/props.js +++ b/src/core/util/props.js @@ -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 (isBooleanType(prop.type)) { if (absent && !hasOwn(prop, 'default')) { value = false } else if (value === '' || value === hyphenate(key)) { @@ -160,3 +160,17 @@ function getType (fn) { const match = fn && fn.toString().match(/^\s*function (\w+)/) return match && match[1] } + +function isBooleanType (fn) { + const isBoolean = (fnItem) => getType(fnItem) === 'Boolean' + + if (!Array.isArray(fn)) { + return isBoolean(fn) + } + for (let i = 0, len = fn.length; i < len; i++) { + if (isBoolean(fn[i])) { + return true + } + } + return false +}