@@ -281,21 +281,6 @@ extension WKJavaScriptController: WKScriptMessageHandler {
281281 return
282282 }
283283
284- if shouldSafeMethodCall {
285- for arg in args {
286- if arg is NSNull {
287- let userInfo = [
288- " nativeSelector " : bridge. nativeSelector,
289- " jsSelector " : bridge. jsSelector,
290- " args " : args,
291- " reason " : " Arguments has NSNull(=undefined). " ,
292- ] as [ String : Any ]
293- NotificationCenter . default. post ( name: WKJavaScriptControllerIgnoredMethodInvocationNotification, object: nil , userInfo: userInfo)
294- return
295- }
296- }
297- }
298-
299284 let method = class_getInstanceMethod ( target. classForCoder, bridge. nativeSelector)
300285 if method == nil {
301286 log ( " An unimplemented method has been called. (selector: \( bridge. nativeSelector) ) " )
@@ -334,9 +319,24 @@ extension WKJavaScriptController: WKScriptMessageHandler {
334319 " nativeSelector " : bridge. nativeSelector,
335320 " jsSelector " : bridge. jsSelector,
336321 " args " : args,
337- ] as [ String : Any ]
322+ ] as [ String : Any ]
338323 NotificationCenter . default. post ( name: WKJavaScriptControllerWillMethodInvocationNotification, object: nil , userInfo: userInfo)
339324
325+ if shouldSafeMethodCall {
326+ for arg in args {
327+ if arg is NSNull {
328+ let userInfo = [
329+ " nativeSelector " : bridge. nativeSelector,
330+ " jsSelector " : bridge. jsSelector,
331+ " args " : args,
332+ " reason " : " Arguments has NSNull(=undefined). " ,
333+ ] as [ String : Any ]
334+ NotificationCenter . default. post ( name: WKJavaScriptControllerIgnoredMethodInvocationNotification, object: nil , userInfo: userInfo)
335+ return
336+ }
337+ }
338+ }
339+
340340 switch bridge. argumentLength {
341341 case 0 :
342342 let method = unsafeBitCast ( imp, to: Invocation0 . self)
0 commit comments