Tuesday, November 26, 2019

JsFunction length is zero

Hi,

Looks like that some javascript libraries are checking on the argument length of the callbacks that are passed to them.

So for example D3 bisector can take a function with one or two arguments. If it is one then it is an accessor if it is two then it is a comparator.

I searched on github issues. Should I report it?

The following snippet demonstrates the problem. The Function.length should be 1 and not 0.

    @JsFunction      public static interface SomeFunction {          public double call(double x);      }  
    /**      * This is the entry point method.      */     @Override     public void onModuleLoad() {         final SomeFunction y = new SomeFunction() {             @Override             public double call(double x) {                 return 2 * x;             }         };         DomGlobal.console.log(y);         return;    }


--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAKbOjEzhR%3DGgF8S7SMmpq9WzjmqViKjZtcWLCKMp%3DaK0uZmHLQ%40mail.gmail.com.

No comments:

Post a Comment