[react_native] JS files from D2091817: Support nested text nodes in TextInput.
This commit is contained in:
parent
ff48f78742
commit
e2dc2db9dc
|
@ -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 (
|
||||
|
|
Loading…
Reference in New Issue