-
Notifications
You must be signed in to change notification settings - Fork 5
add some html element members #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add some html element members #84
Conversation
def offsetHeight(implicit F: Dom[F]): F[Double] = F.delay(element.offsetHeight) | ||
|
||
def offsetWidth(implicit F: Dom[F]): F[Double] = F.delay(element.offsetWidth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't think these are ever fractional. So we should either use Int
or Long
depending on the possible range of values.
Note: This property will round the value to an integer.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what scala-js-dom given us currently. Do you want to coerce to Int here or fix upstream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. So scala-js-dom is a bit more constrained than us: because it's facades, it's only allowed to use native JS types (so, no Long
). A lot of time it uses Double
because that is the canonical representation of a JS number.
Fortunately, we do not have that constraint. So we can determine for ourselves the appropriate, idiomatic wrapper type, and then coerce to that.
def focus(implicit F: Dom[F]): F[Unit] = F.delay(element.focus()) | ||
|
||
// facade for overload missing from org.scalajs.dom | ||
def focus(options: FocusOptions)(implicit F: Dom[F]): F[Unit] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can bump to latest scala-js-dom and use the FocusOptions
facade instead of a case class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, very useful additions!
No description provided.