@@ -225,33 +225,30 @@ public static JsValue RunScript(this EngineInstance engine, String source, INode
225225
226226 public static JsValue Call ( this EngineInstance instance , MethodInfo method , JsValue thisObject , JsValue [ ] arguments )
227227 {
228- if ( method != null && thisObject . Type == Types . Object )
228+ if ( method != null && thisObject . Type == Types . Object && thisObject . AsObject ( ) is DomNodeInstance node )
229229 {
230- if ( thisObject . AsObject ( ) is DomNodeInstance node )
230+ try
231231 {
232- try
232+ if ( method . IsStatic )
233233 {
234- if ( method . IsStatic )
234+ var newArgs = new List < JsValue >
235235 {
236- var newArgs = new List < JsValue >
237- {
238- thisObject ,
239- } ;
240- newArgs . AddRange ( arguments ) ;
241- var parameters = instance . BuildArgs ( method , newArgs . ToArray ( ) ) ;
242- return method . Invoke ( null , parameters ) . ToJsValue ( instance ) ;
243- }
244- else
245- {
246- var parameters = instance . BuildArgs ( method , arguments ) ;
247- return method . Invoke ( node . Value , parameters ) . ToJsValue ( instance ) ;
248- }
236+ thisObject ,
237+ } ;
238+ newArgs . AddRange ( arguments ) ;
239+ var parameters = instance . BuildArgs ( method , newArgs . ToArray ( ) ) ;
240+ return method . Invoke ( null , parameters ) . ToJsValue ( instance ) ;
249241 }
250- catch ( TargetInvocationException )
242+ else
251243 {
252- throw new JavaScriptException ( instance . Jint . Error ) ;
244+ var parameters = instance . BuildArgs ( method , arguments ) ;
245+ return method . Invoke ( node . Value , parameters ) . ToJsValue ( instance ) ;
253246 }
254247 }
248+ catch ( TargetInvocationException )
249+ {
250+ throw new JavaScriptException ( instance . Jint . Error ) ;
251+ }
255252 }
256253
257254 return JsValue . Undefined ;
0 commit comments