Skip to content

Commit 362a322

Browse files
committed
don`t cast empty string to Boolean if prop types include String and Boolean (fix #4538)
1 parent 5c34b1b commit 362a322

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: src/core/util/props.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ export function validateProp (
2121
const absent = !hasOwn(propsData, key)
2222
let value = propsData[key]
2323
// handle boolean props
24-
if (isBooleanType(prop.type)) {
24+
if (isType(Boolean, prop.type)) {
2525
if (absent && !hasOwn(prop, 'default')) {
2626
value = false
27-
} else if (value === '' || value === hyphenate(key)) {
27+
} else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) {
2828
value = true
2929
}
3030
}
@@ -168,12 +168,12 @@ function getType (fn) {
168168
return match && match[1]
169169
}
170170

171-
function isBooleanType (fn) {
171+
function isType (type, fn) {
172172
if (!Array.isArray(fn)) {
173-
return getType(fn) === 'Boolean'
173+
return getType(fn) === getType(type)
174174
}
175175
for (let i = 0, len = fn.length; i < len; i++) {
176-
if (getType(fn[i]) === 'Boolean') {
176+
if (getType(fn[i]) === getType(type)) {
177177
return true
178178
}
179179
}

0 commit comments

Comments
 (0)