mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 19:44:13 +00:00
Rename prop "injectedJavascriptIOS" to "injectedJavaScript
Summary: Android WebView now supports the prop "injectedJavaScript", too. It's time to rename "injectedJavascriptIOS" to "injectedJavaScript" for API consistency between IOS and Android.
This commit is contained in:
parent
1b7699f671
commit
bb141e3a3c
@ -43,6 +43,12 @@ var WebView = React.createClass({
|
|||||||
startInLoadingState: PropTypes.bool, // force WebView to show loadingView on first load
|
startInLoadingState: PropTypes.bool, // force WebView to show loadingView on first load
|
||||||
style: View.propTypes.style,
|
style: View.propTypes.style,
|
||||||
javaScriptEnabledAndroid: PropTypes.bool,
|
javaScriptEnabledAndroid: PropTypes.bool,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the JS to be injected when the webpage loads.
|
||||||
|
*/
|
||||||
|
injectedJavaScript: PropTypes.string,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the user-agent for this WebView. The user-agent can also be set in native through
|
* Sets the user-agent for this WebView. The user-agent can also be set in native through
|
||||||
* WebViewConfig, but this can and will overwrite that config.
|
* WebViewConfig, but this can and will overwrite that config.
|
||||||
@ -96,6 +102,7 @@ var WebView = React.createClass({
|
|||||||
key="webViewKey"
|
key="webViewKey"
|
||||||
style={webViewStyles}
|
style={webViewStyles}
|
||||||
url={this.props.url}
|
url={this.props.url}
|
||||||
|
injectedJavaScript={this.props.injectedJavaScript}
|
||||||
userAgent={this.props.userAgent}
|
userAgent={this.props.userAgent}
|
||||||
javaScriptEnabledAndroid={this.props.javaScriptEnabledAndroid}
|
javaScriptEnabledAndroid={this.props.javaScriptEnabledAndroid}
|
||||||
contentInset={this.props.contentInset}
|
contentInset={this.props.contentInset}
|
||||||
@ -176,8 +183,9 @@ var WebView = React.createClass({
|
|||||||
|
|
||||||
var RCTWebView = createReactNativeComponentClass({
|
var RCTWebView = createReactNativeComponentClass({
|
||||||
validAttributes: merge(ReactNativeViewAttributes.UIView, {
|
validAttributes: merge(ReactNativeViewAttributes.UIView, {
|
||||||
url: true,
|
injectedJavaScript: true,
|
||||||
javaScriptEnabledAndroid: true,
|
javaScriptEnabledAndroid: true,
|
||||||
|
url: true,
|
||||||
userAgent: true,
|
userAgent: true,
|
||||||
}),
|
}),
|
||||||
uiViewClassName: 'RCTWebView',
|
uiViewClassName: 'RCTWebView',
|
||||||
|
@ -98,9 +98,9 @@ var WebView = React.createClass({
|
|||||||
*/
|
*/
|
||||||
javaScriptEnabledAndroid: PropTypes.bool,
|
javaScriptEnabledAndroid: PropTypes.bool,
|
||||||
/**
|
/**
|
||||||
* Used for iOS only, sets the JS to be injected when the webpage loads.
|
* Sets the JS to be injected when the webpage loads.
|
||||||
*/
|
*/
|
||||||
injectedJavascriptIOS: PropTypes.string,
|
injectedJavaScript: PropTypes.string,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for iOS only, sets whether the webpage scales to fit the view and the
|
* Used for iOS only, sets whether the webpage scales to fit the view and the
|
||||||
@ -159,7 +159,7 @@ var WebView = React.createClass({
|
|||||||
style={webViewStyles}
|
style={webViewStyles}
|
||||||
url={this.props.url}
|
url={this.props.url}
|
||||||
html={this.props.html}
|
html={this.props.html}
|
||||||
injectedJavascriptIOS={this.props.injectedJavascriptIOS}
|
injectedJavaScript={this.props.injectedJavaScript}
|
||||||
bounces={this.props.bounces}
|
bounces={this.props.bounces}
|
||||||
scrollEnabled={this.props.scrollEnabled}
|
scrollEnabled={this.props.scrollEnabled}
|
||||||
contentInset={this.props.contentInset}
|
contentInset={this.props.contentInset}
|
||||||
@ -179,15 +179,15 @@ var WebView = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
goForward: function() {
|
goForward: function() {
|
||||||
RCTWebViewManager.goForward(this.getWebWiewHandle());
|
RCTWebViewManager.goForward(this.getWebViewHandle());
|
||||||
},
|
},
|
||||||
|
|
||||||
goBack: function() {
|
goBack: function() {
|
||||||
RCTWebViewManager.goBack(this.getWebWiewHandle());
|
RCTWebViewManager.goBack(this.getWebViewHandle());
|
||||||
},
|
},
|
||||||
|
|
||||||
reload: function() {
|
reload: function() {
|
||||||
RCTWebViewManager.reload(this.getWebWiewHandle());
|
RCTWebViewManager.reload(this.getWebViewHandle());
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,7 +200,7 @@ var WebView = React.createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getWebWiewHandle: function(): any {
|
getWebViewHandle: function(): any {
|
||||||
return React.findNodeHandle(this.refs[RCT_WEBVIEW_REF]);
|
return React.findNodeHandle(this.refs[RCT_WEBVIEW_REF]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ extern NSString *const RCTJSNavigationScheme;
|
|||||||
@property (nonatomic, strong) NSURL *URL;
|
@property (nonatomic, strong) NSURL *URL;
|
||||||
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
||||||
@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
|
@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
|
||||||
@property (nonatomic, copy) NSString *injectedJavascriptIOS;
|
@property (nonatomic, copy) NSString *injectedJavaScript;
|
||||||
|
|
||||||
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
|
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher NS_DESIGNATED_INITIALIZER;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ NSString *const RCTJSNavigationScheme = @"react-js-navigation";
|
|||||||
{
|
{
|
||||||
RCTEventDispatcher *_eventDispatcher;
|
RCTEventDispatcher *_eventDispatcher;
|
||||||
UIWebView *_webView;
|
UIWebView *_webView;
|
||||||
NSString *_injectedJavascriptIOS;
|
NSString *_injectedJavaScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
|
- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
|
||||||
@ -126,19 +126,6 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
|
|||||||
return _webView.backgroundColor;
|
return _webView.backgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setinjectedJavascriptIOS:(NSString *)jsStr
|
|
||||||
{
|
|
||||||
if (_injectedJavascriptIOS == jsStr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([_injectedJavascriptIOS isEqualToString:jsStr]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_injectedJavascriptIOS = [jsStr copy];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSMutableDictionary *)baseEvent
|
- (NSMutableDictionary *)baseEvent
|
||||||
{
|
{
|
||||||
NSURL *url = _webView.request.URL;
|
NSURL *url = _webView.request.URL;
|
||||||
@ -197,8 +184,8 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
|
|||||||
|
|
||||||
- (void)webViewDidFinishLoad:(UIWebView *)webView
|
- (void)webViewDidFinishLoad:(UIWebView *)webView
|
||||||
{
|
{
|
||||||
if (_injectedJavascriptIOS != nil) {
|
if (_injectedJavaScript != nil) {
|
||||||
[webView stringByEvaluatingJavaScriptFromString:_injectedJavascriptIOS];
|
[webView stringByEvaluatingJavaScriptFromString:_injectedJavaScript];
|
||||||
}
|
}
|
||||||
|
|
||||||
// we only need the final 'finishLoad' call so only fire the event when we're actually done loading.
|
// we only need the final 'finishLoad' call so only fire the event when we're actually done loading.
|
||||||
|
@ -28,7 +28,7 @@ RCT_REMAP_VIEW_PROPERTY(html, HTML, NSString);
|
|||||||
RCT_REMAP_VIEW_PROPERTY(bounces, _webView.scrollView.bounces, BOOL);
|
RCT_REMAP_VIEW_PROPERTY(bounces, _webView.scrollView.bounces, BOOL);
|
||||||
RCT_REMAP_VIEW_PROPERTY(scrollEnabled, _webView.scrollView.scrollEnabled, BOOL);
|
RCT_REMAP_VIEW_PROPERTY(scrollEnabled, _webView.scrollView.scrollEnabled, BOOL);
|
||||||
RCT_REMAP_VIEW_PROPERTY(scalesPageToFit, _webView.scalesPageToFit, BOOL);
|
RCT_REMAP_VIEW_PROPERTY(scalesPageToFit, _webView.scalesPageToFit, BOOL);
|
||||||
RCT_EXPORT_VIEW_PROPERTY(injectedJavascriptIOS, NSString);
|
RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString);
|
||||||
RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets);
|
RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets);
|
||||||
RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL);
|
RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user