浏览代码

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

Jamie Birch 5 年前
父节点
当前提交
813c230a44
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5
    3
      ios/RNCWebView.m

+ 5
- 3
ios/RNCWebView.m 查看文件

1009
                     "};", MessageHandlerName, MessageHandlerName
1009
                     "};", MessageHandlerName, MessageHandlerName
1010
                     ]
1010
                     ]
1011
    injectionTime:WKUserScriptInjectionTimeAtDocumentStart
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
   nil;
1017
   nil;
1017
   
1018
   
1115
                                                                        name:MessageHandlerName];
1116
                                                                        name:MessageHandlerName];
1116
       [_webView.configuration.userContentController addUserScript:self.postMessageScript];
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
     if (self.atStartScript) {
1120
     if (self.atStartScript) {
1119
       [_webView.configuration.userContentController addUserScript:self.atStartScript];
1121
       [_webView.configuration.userContentController addUserScript:self.atStartScript];
1120
     }
1122
     }