Skip to content

Commit

Permalink
don`t cast empty string to Boolean if prop types include String and B…
Browse files Browse the repository at this point in the history
…oolean (fix #4538) (#4539)
  • Loading branch information
fliptheweb authored and yyx990803 committed Dec 21, 2016
1 parent 56bfa1d commit 451ea37
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/util/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export function validateProp (
const absent = !hasOwn(propsData, key)
let value = propsData[key]
// handle boolean props
if (isBooleanType(prop.type)) {
if (isType(Boolean, prop.type)) {
if (absent && !hasOwn(prop, 'default')) {
value = false
} else if (value === '' || value === hyphenate(key)) {
} else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) {
value = true
}
}
Expand Down Expand Up @@ -168,12 +168,12 @@ function getType (fn) {
return match && match[1]
}

function isBooleanType (fn) {
function isType (type, fn) {
if (!Array.isArray(fn)) {
return getType(fn) === 'Boolean'
return getType(fn) === getType(type)
}
for (let i = 0, len = fn.length; i < len; i++) {
if (getType(fn[i]) === 'Boolean') {
if (getType(fn[i]) === getType(type)) {
return true
}
}
Expand Down

0 comments on commit 451ea37

Please sign in to comment.