Stop using platform-specific names for props

Summary:
Follows up on [this comment](https://github.com/facebook/react-native/pull/5065#issuecomment-168353782) by nicklockwood in #5065.

Rely on using the platform annotation and keep the API / naming less redundant.
Closes https://github.com/facebook/react-native/pull/5081

Reviewed By: svcscm

Differential Revision: D2803143

Pulled By: nicklockwood

fb-gh-sync-id: 9bdf028f5022ef46fcb63aa6c3fc931fdcc46f2b
This commit is contained in:
odino 2016-01-05 10:31:42 -08:00 committed by facebook-github-bot-0
parent af24619592
commit 6edcebef9c
4 changed files with 30 additions and 10 deletions

View File

@ -94,8 +94,8 @@ var WebViewExample = React.createClass({
automaticallyAdjustContentInsets={false}
style={styles.webView}
url={this.state.url}
javaScriptEnabledAndroid={true}
domStorageEnabledAndroid={true}
javaScriptEnabled={true}
domStorageEnabled={true}
onNavigationStateChange={this.onNavigationStateChange}
onShouldStartLoadWithRequest={this.onShouldStartLoadWithRequest}
startInLoadingState={true}

View File

@ -52,13 +52,13 @@ var WebView = React.createClass({
* Used on Android only, JS is enabled by default for WebView on iOS
* @platform android
*/
javaScriptEnabledAndroid: PropTypes.bool,
javaScriptEnabled: PropTypes.bool,
/**
* Used on Android only, controls whether DOM Storage is enabled or not
* @platform android
*/
domStorageEnabledAndroid: PropTypes.bool,
domStorageEnabled: PropTypes.bool,
/**
* Sets the JS to be injected when the webpage loads.
@ -113,6 +113,16 @@ var WebView = React.createClass({
webViewStyles.push(styles.hidden);
}
var {javaScriptEnabled, domStorageEnabled} = this.props;
if (this.props.javaScriptEnabledAndroid) {
console.warn('javaScriptEnabledAndroid is deprecated. Use javaScriptEnabled instead');
javaScriptEnabled = this.props.javaScriptEnabledAndroid;
}
if (this.props.domStorageEnabledAndroid) {
console.warn('domStorageEnabledAndroid is deprecated. Use domStorageEnabled instead');
domStorageEnabled = this.props.domStorageEnabledAndroid;
}
var webView =
<RCTWebView
ref={RCT_WEBVIEW_REF}
@ -122,8 +132,8 @@ var WebView = React.createClass({
html={this.props.html}
injectedJavaScript={this.props.injectedJavaScript}
userAgent={this.props.userAgent}
javaScriptEnabledAndroid={this.props.javaScriptEnabledAndroid}
domStorageEnabledAndroid={this.props.domStorageEnabledAndroid}
javaScriptEnabled={javaScriptEnabled}
domStorageEnabled={domStorageEnabled}
contentInset={this.props.contentInset}
automaticallyAdjustContentInsets={this.props.automaticallyAdjustContentInsets}
onLoadingStart={this.onLoadingStart}

View File

@ -114,13 +114,13 @@ var WebView = React.createClass({
* Used on Android only, JS is enabled by default for WebView on iOS
* @platform android
*/
javaScriptEnabledAndroid: PropTypes.bool,
javaScriptEnabled: PropTypes.bool,
/**
* Used on Android only, controls whether DOM Storage is enabled or not
* @platform android
*/
domStorageEnabledAndroid: PropTypes.bool,
domStorageEnabled: PropTypes.bool,
/**
* Sets the JS to be injected when the webpage loads.
@ -201,6 +201,16 @@ var WebView = React.createClass({
RCTWebViewManager.startLoadWithResult(!!shouldStart, event.nativeEvent.lockIdentifier);
});
var {javaScriptEnabled, domStorageEnabled} = this.props;
if (this.props.javaScriptEnabledAndroid) {
console.warn('javaScriptEnabledAndroid is deprecated. Use javaScriptEnabled instead');
javaScriptEnabled = this.props.javaScriptEnabledAndroid;
}
if (this.props.domStorageEnabledAndroid) {
console.warn('domStorageEnabledAndroid is deprecated. Use domStorageEnabled instead');
domStorageEnabled = this.props.domStorageEnabledAndroid;
}
var webView =
<RCTWebView
ref={RCT_WEBVIEW_REF}

View File

@ -251,12 +251,12 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
return webView;
}
@ReactProp(name = "javaScriptEnabledAndroid")
@ReactProp(name = "javaScriptEnabled")
public void setJavaScriptEnabled(WebView view, boolean enabled) {
view.getSettings().setJavaScriptEnabled(enabled);
}
@ReactProp(name = "domStorageEnabledAndroid")
@ReactProp(name = "domStorageEnabled")
public void setDomStorageEnabled(WebView view, boolean enabled) {
view.getSettings().setDomStorageEnabled(enabled);
}