Browse Source

chore(iOS): Reverted forMainFrameOnly policy of the messaging script, leaving a TODO notice. Added FIXME notice for injected script behaviours.

Jamie Birch 4 years ago
parent
commit
813c230a44
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      ios/RNCWebView.m

+ 5
- 3
ios/RNCWebView.m View File

@@ -1009,9 +1009,10 @@ static NSDictionary* customCertificatesForHost;
1009 1009
                     "};", MessageHandlerName, MessageHandlerName
1010 1010
                     ]
1011 1011
    injectionTime:WKUserScriptInjectionTimeAtDocumentStart
1012
-   /* This was previously YES, but I'm following react-native-wkwebview's approach on this;
1013
-    * It's very useful to be able to inject postMessage into iframes. */
1014
-   forMainFrameOnly:_injectedJavaScriptBeforeContentLoadedForMainFrameOnly
1012
+   /* TODO: For a separate (minor) PR: use logic like this (as react-native-wkwebview does) so that messaging can be used in all frames if desired.
1013
+    *       I am keeping it as YES for consistency with previous behaviour. */
1014
+   // forMainFrameOnly:_messagingEnabledForMainFrameOnly
1015
+   forMainFrameOnly:YES
1015 1016
    ] :
1016 1017
   nil;
1017 1018
   
@@ -1115,6 +1116,7 @@ static NSDictionary* customCertificatesForHost;
1115 1116
                                                                        name:MessageHandlerName];
1116 1117
       [_webView.configuration.userContentController addUserScript:self.postMessageScript];
1117 1118
     }
1119
+    // FIXME: For a separate (minor) PR: these two shouldn't be gated by messagingEnabled; just keeping consistency with previous behaviour.
1118 1120
     if (self.atStartScript) {
1119 1121
       [_webView.configuration.userContentController addUserScript:self.atStartScript];
1120 1122
     }