+
Skip to content

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

Conversation

buntec
Copy link
Collaborator

@buntec buntec commented May 11, 2023

No description provided.

Comment on lines 134 to 136
def offsetHeight(implicit F: Dom[F]): F[Double] = F.delay(element.offsetHeight)

def offsetWidth(implicit F: Dom[F]): F[Double] = F.delay(element.offsetWidth)
Copy link
Owner

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

Copy link
Collaborator Author

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?

Copy link
Owner

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] =
Copy link
Owner

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.

Copy link
Owner

@armanbilge armanbilge left a 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!

@armanbilge armanbilge merged commit c9b96c2 into armanbilge:main May 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载