ghcjs / ghcjs-dom

Make Document Object Model (DOM) apps that run in any browser and natively using WebKitGtk
74 stars 41 forks source link

ClientRect -> DOMRect seems to make Chrome support impossible #69

Closed cdsmith closed 7 years ago

cdsmith commented 7 years ago

https://github.com/ghcjs/ghcjs-dom/commit/3c495cd71b2bdcc2013d305d2fab944fd9b5650a seems to have removed GHCJS.DOM.ClientRect in favor of DOMRect. However, DOMRect no longer contains getLeft and getTop. They are, instead, replaced by getX and getY, which seem to be Firefox-specific (see compatibility chart at https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect)

I'm not sure how to best handle this.

cdsmith commented 7 years ago

It looks like the correct members do exist in DOMRectReadOnly. So perhaps the bug is that Element.getBoundingClientRect returns a DOMRect, where it should instead return a DOMRectReadOnly.

hamishmack commented 7 years ago

Oh I came across this the other day too. It seems DOMRect is a DOMRectReadOnly (in the OO sense). That means that there is an instance IsDOMRectReadOnly DOMRect in GHCJS.DOM.Types. So we can use getLeftand getTop from GHCJS.DOM.DOMRectReadOnly with the DOMRect returned by getBoundingClientRect.

cdsmith commented 7 years ago

Cool, thanks!

I still am glad to be using the hackage version of ghcjs-dom, though. I'll update that once 0.9 is on Hackage.