feat(iOS): add-javaScriptEnabled prop (#592)

* add-javaScriptEnabled-in-IOS

* Update WebViewTypes.ts
This commit is contained in:
aksmfosef11 2019-08-30 00:09:42 +09:00 committed by Thibault Malbranche
parent 5dbfe553ee
commit a28096bfe7
4 changed files with 14 additions and 7 deletions

View File

@ -45,6 +45,7 @@
@property (nonatomic, copy) NSString *userAgent;
@property (nonatomic, copy) NSString *applicationNameForUserAgent;
@property (nonatomic, assign) BOOL cacheEnabled;
@property (nonatomic, assign) BOOL javaScriptEnabled;
@property (nonatomic, assign) BOOL allowsLinkPreview;
@property (nonatomic, assign) BOOL showsHorizontalScrollIndicator;
@property (nonatomic, assign) BOOL showsVerticalScrollIndicator;

View File

@ -115,6 +115,11 @@ static NSURLCredential* clientAuthenticationCredential;
{
if (self.window != nil && _webView == nil) {
WKWebViewConfiguration *wkWebViewConfig = [WKWebViewConfiguration new];
WKPreferences *prefs = [[WKPreferences alloc]init];
if (!_javaScriptEnabled) {
prefs.javaScriptEnabled = NO;
wkWebViewConfig.preferences = prefs;
}
if (_incognito) {
wkWebViewConfig.websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
} else if (_cacheEnabled) {

View File

@ -63,6 +63,7 @@ const RNCWKWebView: typeof NativeWebViewIOS = requireNativeComponent(
class WebView extends React.Component<IOSWebViewProps, State> {
static defaultProps = {
useWebKit: true,
javaScriptEnabled: true,
cacheEnabled: true,
originWhitelist: defaultOriginWhitelist,
useSharedProcessPool: true,

View File

@ -498,13 +498,6 @@ export interface AndroidWebViewProps extends WebViewSharedProps {
*/
urlPrefixesForDefaultIntent?: ReadonlyArray<string>;
/**
* Boolean value to enable JavaScript in the `WebView`. Used on Android only
* as JavaScript is enabled by default on iOS. The default value is `true`.
* @platform android
*/
javaScriptEnabled?: boolean;
/**
* Boolean value to disable Hardware Acceleration in the `WebView`. Used on Android only
* as Hardware Acceleration is a feature only for Android. The default value is `false`.
@ -563,6 +556,13 @@ export interface WebViewSharedProps extends ViewProps {
*/
source?: WebViewSource;
/**
* Boolean value to enable JavaScript in the `WebView`. Used on Android only
* as JavaScript is enabled by default on iOS. The default value is `true`.
* @platform android
*/
javaScriptEnabled?: boolean;
/**
* Function that returns a view to show if there's an error.
*/