[react_native] JS files from D2091817: Support nested text nodes in TextInput.

This commit is contained in:
Krzysztof Magiera 2015-05-29 18:16:57 -02:00
parent ff48f78742
commit e2dc2db9dc
1 changed files with 19 additions and 0 deletions

View File

@ -407,6 +407,14 @@ var TextInput = React.createClass({
}
},
getChildContext: function() {
return {isInAParentText: true};
},
childContextTypes: {
isInAParentText: React.PropTypes.bool
},
render: function() {
if (Platform.OS === 'ios') {
return this._renderIOS();
@ -524,6 +532,16 @@ var TextInput = React.createClass({
_renderAndroid: function() {
var autoCapitalize = autoCapitalizeConsts[this.props.autoCapitalize];
var children = this.props.children;
var childCount = 0;
ReactChildren.forEach(children, () => ++childCount);
invariant(
!(this.props.value && childCount),
'Cannot specify both value and children.'
);
if (childCount > 1) {
children = <Text>{children}</Text>;
}
var textContainer =
<AndroidTextInput
ref="input"
@ -541,6 +559,7 @@ var TextInput = React.createClass({
password={this.props.password || this.props.secureTextEntry}
placeholder={this.props.placeholder}
text={this.state.bufferedValue}
children={children}
/>;
return (