feat(iOS): add-javaScriptEnabled prop (#592)
* add-javaScriptEnabled-in-IOS * Update WebViewTypes.ts
This commit is contained in:
parent
5dbfe553ee
commit
a28096bfe7
|
@ -45,6 +45,7 @@
|
||||||
@property (nonatomic, copy) NSString *userAgent;
|
@property (nonatomic, copy) NSString *userAgent;
|
||||||
@property (nonatomic, copy) NSString *applicationNameForUserAgent;
|
@property (nonatomic, copy) NSString *applicationNameForUserAgent;
|
||||||
@property (nonatomic, assign) BOOL cacheEnabled;
|
@property (nonatomic, assign) BOOL cacheEnabled;
|
||||||
|
@property (nonatomic, assign) BOOL javaScriptEnabled;
|
||||||
@property (nonatomic, assign) BOOL allowsLinkPreview;
|
@property (nonatomic, assign) BOOL allowsLinkPreview;
|
||||||
@property (nonatomic, assign) BOOL showsHorizontalScrollIndicator;
|
@property (nonatomic, assign) BOOL showsHorizontalScrollIndicator;
|
||||||
@property (nonatomic, assign) BOOL showsVerticalScrollIndicator;
|
@property (nonatomic, assign) BOOL showsVerticalScrollIndicator;
|
||||||
|
|
|
@ -115,6 +115,11 @@ static NSURLCredential* clientAuthenticationCredential;
|
||||||
{
|
{
|
||||||
if (self.window != nil && _webView == nil) {
|
if (self.window != nil && _webView == nil) {
|
||||||
WKWebViewConfiguration *wkWebViewConfig = [WKWebViewConfiguration new];
|
WKWebViewConfiguration *wkWebViewConfig = [WKWebViewConfiguration new];
|
||||||
|
WKPreferences *prefs = [[WKPreferences alloc]init];
|
||||||
|
if (!_javaScriptEnabled) {
|
||||||
|
prefs.javaScriptEnabled = NO;
|
||||||
|
wkWebViewConfig.preferences = prefs;
|
||||||
|
}
|
||||||
if (_incognito) {
|
if (_incognito) {
|
||||||
wkWebViewConfig.websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
|
wkWebViewConfig.websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
|
||||||
} else if (_cacheEnabled) {
|
} else if (_cacheEnabled) {
|
||||||
|
|
|
@ -63,6 +63,7 @@ const RNCWKWebView: typeof NativeWebViewIOS = requireNativeComponent(
|
||||||
class WebView extends React.Component<IOSWebViewProps, State> {
|
class WebView extends React.Component<IOSWebViewProps, State> {
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
useWebKit: true,
|
useWebKit: true,
|
||||||
|
javaScriptEnabled: true,
|
||||||
cacheEnabled: true,
|
cacheEnabled: true,
|
||||||
originWhitelist: defaultOriginWhitelist,
|
originWhitelist: defaultOriginWhitelist,
|
||||||
useSharedProcessPool: true,
|
useSharedProcessPool: true,
|
||||||
|
|
|
@ -498,13 +498,6 @@ export interface AndroidWebViewProps extends WebViewSharedProps {
|
||||||
*/
|
*/
|
||||||
urlPrefixesForDefaultIntent?: ReadonlyArray<string>;
|
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
|
* 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`.
|
* 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;
|
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.
|
* Function that returns a view to show if there's an error.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue