Open Pat-Laub opened 10 years ago
Passing the .jsProxy member sometimes seems to work but seems hacky/wrong.
It is hacky, but it's the state of the art for the chrome library right now. It's what we do under the covers in the generated code. The dart:js library doesn't automatically unpack objects when calling from dart --> JS - for example, calling something like a toJS()
method. If I recall, the old package:js did have something like this.
For now, passing on the jsProxy is your best bet. You can do a (dirEntry as dynamic).jsProxy to avoid the compiler warning. We're looking at a better way to bind the DOM filesystem objects returned by the chrome APIs in order to avoid these corner cases showing up to users. No ETA though :(
I'd expected a Dart chrome.Entry object to pass to JavaScript (as a function argument) with the equivalent Javascript type (chrome.fileSystem.Entry). Instead it appears as a DartObject. Passing the .jsProxy member sometimes seems to work but seems hacky/wrong.
For example: running this dart code
which passes a DirectoryEntry to this javascript
...
will give
Uncaught Error: NoSuchMethodError: Cannot call "getFile" on "#" (Object # has no method 'getFile')
If the dart line were changed to
then the code runs successfully but the compiler spits out
Warning: No member named 'jsProxy' in class 'DirectoryEntry'.