mirror of
https://github.com/status-im/react-native.git
synced 2025-02-10 08:26:23 +00:00
Allowing turning on / off DOM storage on android webviews
Summary: Was developing on a WebView and couldnt get it to run. Turns out its JS code mostly depends on `localStorage` and I realized it wasnt turned on in RN. This PR adds a prop, similar to `javascriptEnabledAndroid` to be able to turn DOM storage on / off. TBH I dont really know how it works on IOS, so I created an android specific thingy. I assume DOM storage is enabled by default on IOS. Closes https://github.com/facebook/react-native/pull/5065 Reviewed By: svcscm Differential Revision: D2797735 Pulled By: androidtrunkagent fb-gh-sync-id: cd60cfa4d24d80fb82e4f54f387a4517a99e75ab
This commit is contained in:
parent
55fe7ac9ae
commit
6793128435
@ -95,6 +95,7 @@ var WebViewExample = React.createClass({
|
|||||||
style={styles.webView}
|
style={styles.webView}
|
||||||
url={this.state.url}
|
url={this.state.url}
|
||||||
javaScriptEnabledAndroid={true}
|
javaScriptEnabledAndroid={true}
|
||||||
|
domStorageEnabledAndroid={true}
|
||||||
onNavigationStateChange={this.onNavigationStateChange}
|
onNavigationStateChange={this.onNavigationStateChange}
|
||||||
onShouldStartLoadWithRequest={this.onShouldStartLoadWithRequest}
|
onShouldStartLoadWithRequest={this.onShouldStartLoadWithRequest}
|
||||||
startInLoadingState={true}
|
startInLoadingState={true}
|
||||||
|
@ -54,6 +54,12 @@ var WebView = React.createClass({
|
|||||||
*/
|
*/
|
||||||
javaScriptEnabledAndroid: PropTypes.bool,
|
javaScriptEnabledAndroid: PropTypes.bool,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used on Android only, controls whether DOM Storage is enabled or not
|
||||||
|
* @platform android
|
||||||
|
*/
|
||||||
|
domStorageEnabledAndroid: PropTypes.bool,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the JS to be injected when the webpage loads.
|
* Sets the JS to be injected when the webpage loads.
|
||||||
*/
|
*/
|
||||||
@ -117,6 +123,7 @@ var WebView = React.createClass({
|
|||||||
injectedJavaScript={this.props.injectedJavaScript}
|
injectedJavaScript={this.props.injectedJavaScript}
|
||||||
userAgent={this.props.userAgent}
|
userAgent={this.props.userAgent}
|
||||||
javaScriptEnabledAndroid={this.props.javaScriptEnabledAndroid}
|
javaScriptEnabledAndroid={this.props.javaScriptEnabledAndroid}
|
||||||
|
domStorageEnabledAndroid={this.props.domStorageEnabledAndroid}
|
||||||
contentInset={this.props.contentInset}
|
contentInset={this.props.contentInset}
|
||||||
automaticallyAdjustContentInsets={this.props.automaticallyAdjustContentInsets}
|
automaticallyAdjustContentInsets={this.props.automaticallyAdjustContentInsets}
|
||||||
onLoadingStart={this.onLoadingStart}
|
onLoadingStart={this.onLoadingStart}
|
||||||
|
@ -116,6 +116,12 @@ var WebView = React.createClass({
|
|||||||
*/
|
*/
|
||||||
javaScriptEnabledAndroid: PropTypes.bool,
|
javaScriptEnabledAndroid: PropTypes.bool,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used on Android only, controls whether DOM Storage is enabled or not
|
||||||
|
* @platform android
|
||||||
|
*/
|
||||||
|
domStorageEnabledAndroid: PropTypes.bool,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the JS to be injected when the webpage loads.
|
* Sets the JS to be injected when the webpage loads.
|
||||||
*/
|
*/
|
||||||
|
@ -256,6 +256,11 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
|
|||||||
view.getSettings().setJavaScriptEnabled(enabled);
|
view.getSettings().setJavaScriptEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ReactProp(name = "domStorageEnabledAndroid")
|
||||||
|
public void setDomStorageEnabled(WebView view, boolean enabled) {
|
||||||
|
view.getSettings().setDomStorageEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
@ReactProp(name = "userAgent")
|
@ReactProp(name = "userAgent")
|
||||||
public void setUserAgent(WebView view, @Nullable String userAgent) {
|
public void setUserAgent(WebView view, @Nullable String userAgent) {
|
||||||
if (userAgent != null) {
|
if (userAgent != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user