From 362a32207b4db8d5acefc849f390b5efe1d9fb6f Mon Sep 17 00:00:00 2001 From: fliptheweb Date: Wed, 21 Dec 2016 23:46:34 +0700 Subject: [PATCH] don`t cast empty string to Boolean if prop types include String and Boolean (fix #4538) --- src/core/util/props.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/util/props.js b/src/core/util/props.js index 7b4d679174a..0f8da5367e9 100644 --- a/src/core/util/props.js +++ b/src/core/util/props.js @@ -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 } } @@ -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 } }