Skip to content

Commit

Permalink
[ReactNative] Fix secure text entry
Browse files Browse the repository at this point in the history
Summary:
@public

`validAttributes` strikes again.

Test Plan: secure box in example is actually secure
  • Loading branch information
sahrens committed Jun 10, 2015
1 parent 6c6b8be commit 3102fc5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 48 deletions.
54 changes: 6 additions & 48 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ var Platform = require('Platform');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var ReactChildren = require('ReactChildren');
var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
var StyleSheet = require('StyleSheet');
var Text = require('Text');
var TextInputState = require('TextInputState');
Expand All @@ -29,36 +28,7 @@ var TouchableWithoutFeedback = require('TouchableWithoutFeedback');
var createReactNativeComponentClass = require('createReactNativeComponentClass');
var emptyFunction = require('emptyFunction');
var invariant = require('invariant');
var merge = require('merge');

var RCTTextViewAttributes = merge(ReactNativeViewAttributes.UIView, {
autoCorrect: true,
autoCapitalize: true,
clearTextOnFocus: true,
color: true,
editable: true,
fontFamily: true,
fontSize: true,
fontStyle: true,
fontWeight: true,
keyboardType: true,
returnKeyType: true,
enablesReturnKeyAutomatically: true,
secureTextEntry: true,
selectTextOnFocus: true,
mostRecentEventCounter: true,
placeholder: true,
placeholderTextColor: true,
text: true,
});

var RCTTextFieldAttributes = merge(RCTTextViewAttributes, {
caretHidden: true,
enabled: true,
clearButtonMode: true,
clearTextOnFocus: true,
selectTextOnFocus: true,
});
var requireNativeComponent = require('requireNativeComponent');

var onlyMultiline = {
onSelectionChange: true,
Expand All @@ -82,16 +52,14 @@ var AndroidTextInputAttributes = {
testID: true,
};

var viewConfigIOS = {
uiViewClassName: 'RCTTextField',
validAttributes: RCTTextFieldAttributes,
};

var viewConfigAndroid = {
uiViewClassName: 'AndroidTextInput',
validAttributes: AndroidTextInputAttributes,
};

var RCTTextView = requireNativeComponent('RCTTextView', null);
var RCTTextField = requireNativeComponent('RCTTextField', null);

type DefaultProps = {
bufferDelay: number;
};
Expand Down Expand Up @@ -164,7 +132,7 @@ var TextInput = React.createClass({
*/
keyboardType: PropTypes.oneOf([
// Cross-platform
'default',
'default',
'numeric',
'email-address',
// iOS-only
Expand Down Expand Up @@ -296,7 +264,7 @@ var TextInput = React.createClass({
*/
mixins: [NativeMethodsMixin, TimerMixin],

viewConfig: ((Platform.OS === 'ios' ? viewConfigIOS :
viewConfig: ((Platform.OS === 'ios' ? RCTTextField.viewConfig :
(Platform.OS === 'android' ? viewConfigAndroid : {})) : Object),

isFocused: function(): boolean {
Expand Down Expand Up @@ -577,16 +545,6 @@ var styles = StyleSheet.create({
},
});

var RCTTextView = createReactNativeComponentClass({
validAttributes: RCTTextViewAttributes,
uiViewClassName: 'RCTTextView',
});

var RCTTextField = createReactNativeComponentClass({
validAttributes: RCTTextFieldAttributes,
uiViewClassName: 'RCTTextField',
});

var AndroidTextInput = createReactNativeComponentClass({
validAttributes: AndroidTextInputAttributes,
uiViewClassName: 'AndroidTextInput',
Expand Down
1 change: 1 addition & 0 deletions Libraries/ReactNative/createReactNativeComponentClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var createReactNativeComponentClass = function(
this.previousFlattenedStyle = null;
};
Constructor.displayName = viewConfig.uiViewClassName;
Constructor.viewConfig = viewConfig;
Constructor.prototype = new ReactNativeBaseComponent(viewConfig);
Constructor.prototype.constructor = Constructor;

Expand Down

0 comments on commit 3102fc5

Please sign in to comment.