Skip to content

Commit ab414d7

Browse files
committed
Make dyamicMember return a JSFunctionRef in the disfavoredOverload
1 parent 9b47115 commit ab414d7

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

Sources/JavaScriptKit/JSObject.swift

+4-9
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,14 @@ public class JSObjectRef: Equatable {
88
}
99

1010
@_disfavoredOverload
11-
public subscript(_ name: String) -> ((JSValueEncodable...) -> JSValue)? {
11+
public subscript(_ name: String) -> JSFunctionRef? {
1212
guard let function = self[name].function else { return nil }
13-
return { (arguments: JSValueEncodable...) in
14-
function(this: self, args: arguments)
15-
}
13+
return function
1614
}
1715

1816
@_disfavoredOverload
19-
public subscript(dynamicMember name: String) -> ((JSValueEncodable...) -> JSValue)? {
20-
guard let function = self[name].function else { return nil }
21-
return { (arguments: JSValueEncodable...) in
22-
function(this: self, args: arguments)
23-
}
17+
public subscript(dynamicMember name: String) -> JSFunctionRef? {
18+
self[name]
2419
}
2520

2621
public subscript(dynamicMember name: String) -> JSValue {

Sources/JavaScriptKit/JSValueConvertible.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,9 @@ extension Dictionary: JSValueDecodable where Value: JSValueDecodable, Key == Str
155155

156156
public init(jsValue: JSValue) {
157157
let objectRef: JSObjectRef = jsValue.object!
158-
159158
let keys: [String] = JSObject.keys!(objectRef.jsValue()).fromJSValue()
160159
self = Dictionary(uniqueKeysWithValues: keys.map {
161-
($0, objectRef[dynamicMember: $0].fromJSValue())
160+
($0, objectRef[$0].fromJSValue())
162161
})
163162
}
164163
}

0 commit comments

Comments
 (0)