Browse Source

fix(iOS): injectedJavaScriptBeforeContentLoaded now runs when messaging is not enabled (#1286)

Salvatore Randazzo 4 years ago
parent
commit
571fb8df79
No account linked to committer's email address
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      ios/RNCWebView.m

+ 4
- 4
ios/RNCWebView.m View File

@@ -1245,14 +1245,14 @@ static NSDictionary* customCertificatesForHost;
1245 1245
                                                                        name:MessageHandlerName];
1246 1246
       [wkWebViewConfig.userContentController addUserScript:self.postMessageScript];
1247 1247
     }
1248
-    // FIXME: For a separate (minor) PR: these two shouldn't be gated by messagingEnabled; just keeping consistency with previous behaviour.
1249
-    if (self.atStartScript) {
1250
-      [wkWebViewConfig.userContentController addUserScript:self.atStartScript];
1251
-    }
1252 1248
     if (self.atEndScript) {
1253 1249
       [wkWebViewConfig.userContentController addUserScript:self.atEndScript];
1254 1250
     }
1255 1251
   }
1252
+  // Whether or not messaging is enabled, add the startup script if it exists.
1253
+  if (self.atStartScript) {
1254
+    [wkWebViewConfig.userContentController addUserScript:self.atStartScript];
1255
+  }
1256 1256
 }
1257 1257
 
1258 1258
 - (NSURLRequest *)requestForSource:(id)json {