ghcjs / ghcjs-base

base library for GHCJS for JavaScript interaction and marshalling, used by higher level libraries like JSC
MIT License
45 stars 67 forks source link

JavaScript.Web.MessageEvent.getData broken #60

Closed stepcut closed 7 years ago

stepcut commented 8 years ago

getData seems to have 2 == BlobData and 3 == ArrayBuffer:

getData :: MessageEvent -> MessageEventData
getData me = case js_getData me of
               (# 1#, r #) -> StringData      (JSString r)
               (# 2#, r #) -> BlobData        (SomeBlob r)
               (# 3#, r #) -> ArrayBufferData (SomeArrayBuffer r)
{-# INLINE getData #-}

but the js_getData FFI import seems to have 2 == ArrayBuffer and 3 == BlobData

foreign import javascript unsafe
  "$r2 = $1.data;\
  \$r1 = typeof $r2 === 'string' ? 1 : ($r2 instanceof ArrayBuffer ? 2 : 3)"
  js_getData :: MessageEvent -> (# Int#, JSVal #)

https://github.com/ghcjs/ghcjs-base/blob/master/JavaScript/Web/MessageEvent.hs

DougBurke commented 8 years ago

Is this fixed by #54?

stepcut commented 8 years ago

I can't easily test it -- but it sure looks like it should.

tittoassini commented 8 years ago

I have wasted hours because of this bug, why hasn't the fix been merged in?

bergey commented 8 years ago

@stepcut @DougBurke @tittoassini Can one of you confirm that this is fixed in a recent build (since #54 was merged)?

tittoassini commented 7 years ago

yes, it is fixed