Closed mm1992 closed 7 years ago
Should we instead use getStyle of ElementCSSInlineStyle?
Yes, it looks like it has moved to GHCJS.DOM.ElementCSSInlineStyle.
Do you know the rationale behind this change?
It was made in the upstream WebKit IDL files, I am not sure why.
Thank you, Hamish. If this change is intentional, then we'll just stick to the ElementCSSInlineStyle fix. Cheers!
From reading this it seems that there could be elements of just type Element
that are not HTMLElement
or SVGElement
(and so would not have a style
). By having a separate interface we are forced to cast Element
to one of HTMLElement
or SVGElement
to indicate that it is safe to call getStyle
.
You can also do uncheckedCastTo ElementCSSInlineStyle
to convert from Element
to ElementCSSInlineStyle
(if you know it will be one of HTMLELement
or SVGElement
, but are not sure which). The checked version castTo ElementCSSInlineStyle
will not work because there is no way to do x instanceof ElementCSSInlineStyle
in JavaScript (because ElementCSSInlineStyle
does not exist).
Implicit type conversions seem to do the trick for my code. Just switching to ElementCSSInlineStyle (getStyle)
was enough so far. Thanks again.
The
GHCJS.DOM.Element
module used to havegetStyle
function It could be used as in the following link: https://github.com/LambdaHack/LambdaHack/blob/master/Game/LambdaHack/Client/UI/Frontend/Dom.hs#L85 (divStyle <- getStyle divBlock
).However, in the latest version of ghcjs-dom
getStyle
is absent.Should we instead use
getStyle
ofElementCSSInlineStyle
? Do you know the rationale behind this change?Thank you in advance for any advice!