TypeError when compiled to JS
Closed this issue · 5 comments
hi,
the library works fine in Dartium, but it doesn't work when compiled using dart2js unfortunately.
the error occurs when calling decodeBytes();
you can find my code here: https://github.com/TomTasche/OpenDocument.dart/blob/76bfe183247ac76091b4cd77485caf986e1e9d1f/web/opendocument.dart#L24
is there anything we can do to make it work in JS too?
That's odd, I just tried dart2js successfully. Perhaps I didn't hit that code path. I'll look into it.
great to hear you successfully used your library with dart2js already! thanks for your help.
Looks like the problem is FileReader.result isn't returning a byte buffer
that I can read post dart2js (it doesn't even implement the length method).
I'll look into it to see if there's some way I can extract the data from
it.
On Tue, Feb 4, 2014 at 12:52 PM, Thomas Taschauer
notifications@github.comwrote:
great to hear you successfully used your library with dart2js already!
thanks for your help.Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-34105688
.
I just committed the fix. I'm in the middle of some other stuff so I won't be pushing the pub version yet, but if you don't want to use the git version, a quick fix on your side would be:
import 'dart:typed_data';
...
void onZipLoaded(ProgressEvent event) {
FileReader reader = event.currentTarget;
var bytes = new Uint8List.view(reader.result); //<-- typecast the ByteBuffer as a Uint8List
Archive archive = new ZipDecoder().decodeBytes(bytes);
...
}
awesome dude! thanks a lot!