src/Palete/Javascript.vala
authorAlan Knowles <alan@roojs.com>
Wed, 18 Mar 2015 10:00:39 +0000 (18:00 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 18 Mar 2015 10:00:39 +0000 (18:00 +0800)
src/Palete/Javascript.vala

index 2cb9a94..9cff5d7 100644 (file)
@@ -148,14 +148,20 @@ namespace Palete {
                                return;
                        }
                        
-                       var val =  othis.get_property (ctx, jmethod, out ex); 
-                       if (!val.is_function(ctx)) {
+                       var val =  othis.get_property (ctx, jmethod, out ex);
+                       
+                       if (!val.is_object(ctx)) {
+                               throw new JavascriptError.MISSING_METHOD ("Plugin: not a property not found  %s", method);
+                       }
+                       var oval = val.to_object();
+                       
+                       if (!oval.is_function(ctx)) {
                                throw new JavascriptError.MISSING_METHOD ("Plugin: not a method  %s", method);
                        }
                        JSCore.Value[] args = {};
                        args += json_args;
                         
-                       var res = val.call_as_function(ctx, othis, args, out ex);
+                       var res = oval.call_as_function(ctx, othis, args, out ex);