From 6edcebef9c2a6f271ec7aaca97addcaf7545e48c Mon Sep 17 00:00:00 2001 From: odino Date: Tue, 5 Jan 2016 10:31:42 -0800 Subject: [PATCH] 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 --- Examples/UIExplorer/WebViewExample.js | 4 ++-- .../Components/WebView/WebView.android.js | 18 ++++++++++++++---- Libraries/Components/WebView/WebView.ios.js | 14 ++++++++++++-- .../views/webview/ReactWebViewManager.java | 4 ++-- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Examples/UIExplorer/WebViewExample.js b/Examples/UIExplorer/WebViewExample.js index ce489effe..96f60b131 100644 --- a/Examples/UIExplorer/WebViewExample.js +++ b/Examples/UIExplorer/WebViewExample.js @@ -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} diff --git a/Libraries/Components/WebView/WebView.android.js b/Libraries/Components/WebView/WebView.android.js index 7b227aef3..19e1a4f1a 100644 --- a/Libraries/Components/WebView/WebView.android.js +++ b/Libraries/Components/WebView/WebView.android.js @@ -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 = { 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); }