Fix button render with null or undefined child. (#5473)

* Fix button render with null or undefined child.

Fix bug #5472

* Add missing semicolon

* Make if statement braced.

......
This commit is contained in:
Sebastian Blade 2017-03-24 13:10:27 +08:00 committed by Benjy Cui
parent 9b8ef5a0b7
commit 041bbee2c0

View File

@ -12,6 +12,10 @@ function isString(str) {
// Insert one space between two chinese characters automatically. // Insert one space between two chinese characters automatically.
function insertSpace(child) { function insertSpace(child) {
// Check the child if is undefined or null.
if (child == null) {
return;
}
if (isString(child.type) && isTwoCNChar(child.props.children)) { if (isString(child.type) && isTwoCNChar(child.props.children)) {
return React.cloneElement(child, {}, return React.cloneElement(child, {},
child.props.children.split('').join(' ')); child.props.children.split('').join(' '));