New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exposing a Dart function to JS behaves differently in compiled vs non-compiled mode #17752
Comments
This is a bug in the Dartium implementation of how we proxy functions. cc @justinfagnani. |
This comment was originally written by chirayuk@gmail.com I just ran across this today. The workaround (which wasn't obvious to me) is to write, context['foo'] = new JsFunction.withThis((_, arg1, arg2, arg3, …) => myDartFn(arg1, arg2, arg2, …)); that works in both compiled and non-compiled modes. Since there is no JsFunction constructor without "withThis", one has to repeat the argument list manually for each function that's exposed (i.e. you can't get away with a helper to do the wrapping.) |
Set owner to @justinfagnani. |
This comment was originally written by chirayu@google.com |
This comment was originally written by chirayu@chirayuk.com I've used a somewhat generic work around for AngularDart → chirayuk/angular.dart@6797274 This isn't a hot codepath (used for E2E testing and debugging) so an actual fix isn't a priority. For those curious, here's the gist of the workaround: // Work around http://dartbug.com/17752 // Helper function to JSify a Dart object. While this is required to JSify // Proxies a Dart function that accepts up to 10 parameters. __invokeFromJs(fn, o1, o2, o3, o4, o5, o6, o7, o8, o9, o10) { const Object __varargSentinel = const Object(); |
I run into the exact same issue when trying to interface with ag_grid. Is there a solution? If you have control of the resulting javascript I've found that ._jsObject DOES behave the way you'd like. In my case I don't really want to modify the core library to make it work with dart, but I might be forced to do so. |
I ended up writing a quick and dirty JS wrapper that intercepts the objects before they reach the javascript library and de-dartifying the object. That's pretty ugly though, it would be nice to see a proper fix for this. |
What steps will reproduce the problem?
What is the expected output? What do you see instead?
In non-compiled mode this returns true.
In compiled mode (to js) this returns false.
I'd expect it to behave the same way regardless.
What version of the product are you using? On what operating system?
1_3_0_dev_6_0
The text was updated successfully, but these errors were encountered: