File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,6 +59,10 @@ open class JSFloat: JSValueType {
5959}
6060
6161open class WKJavaScriptController : NSObject {
62+ // If true, do not allow NSNull(If pass undefined in JavaScript) for method arguments.
63+ // That is, if get NSNull as arguments, do not call method.
64+ open var shouldSafeMethodCall = true
65+
6266 fileprivate let name : String
6367 fileprivate weak var target : AnyObject ?
6468 fileprivate let bridgeProtocol : Protocol
@@ -256,6 +260,14 @@ extension WKJavaScriptController: WKScriptMessageHandler {
256260 return
257261 }
258262
263+ if shouldSafeMethodCall {
264+ for arg in args {
265+ if arg is NSNull {
266+ return
267+ }
268+ }
269+ }
270+
259271 let method = class_getInstanceMethod ( target. classForCoder, bridge. nativeSelector)
260272 if method == nil {
261273 log ( " An unimplemented method has been called. (selector: \( bridge. nativeSelector) ) " )
You can’t perform that action at this time.
0 commit comments