Skip to content
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

JsDom Use Case has ambiguous implicit errors? #23

Closed
benjaminjackman opened this issue Jun 22, 2014 · 4 comments
Closed

JsDom Use Case has ambiguous implicit errors? #23

benjaminjackman opened this issue Jun 22, 2014 · 4 comments

Comments

@benjaminjackman
Copy link

https://github.com/lihaoyi/scalatags#use-cases

When I try this example, I am getting ambiguous implicit errors

The imports for the example aren't listed, so I am assuming that its full form is:

      import scalatags.JsDom._
      import scalatags.JsDom.all._


      val labelElem = label("Default").render

      val inputElem = input(
        `type`:="text",
        onfocus := { () => labelElem.textContent = ""}
      ).render

      val box = div(
        inputElem,
        labelElem
      ).render

      println(labelElem.textContent) // "Default"
      inputElem.onfocus(null)
      println(labelElem.textContent) // ""

Which gives me the following error:

[error] /home/bjackman/cgta/orange/viz-sjs/src/main/scala/cgta/viz/pepper/PepperGrid.scala:33: type mismatch;
[error]  found   : org.scalajs.dom.HTMLInputElement
[error]  required: scalatags.JsDom.Node
[error]     (which expands to)  scalatags.generic.Node[org.scalajs.dom.Element]
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method bindElement in trait LowPriorityImplicits of type (e: org.scalajs.dom.Element)scalatags.generic.Node[org.scalajs.dom.Element]
[error]  and method NumericNode in object JsDom of type [T](u: T)(implicit evidence$1: Numeric[T])scalatags.JsDom.StringNode
[error]  are possible conversion functions from org.scalajs.dom.HTMLInputElement to scalatags.JsDom.Node
[error]         inputElem,
[error]         ^
[error] /home/bjackman/cgta/orange/viz-sjs/src/main/scala/cgta/viz/pepper/PepperGrid.scala:34: type mismatch;
[error]  found   : org.scalajs.dom.HTMLLabelElement
[error]  required: scalatags.JsDom.Node
[error]     (which expands to)  scalatags.generic.Node[org.scalajs.dom.Element]
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method bindElement in trait LowPriorityImplicits of type (e: org.scalajs.dom.Element)scalatags.generic.Node[org.scalajs.dom.Element]
[error]  and method NumericNode in object JsDom of type [T](u: T)(implicit evidence$1: Numeric[T])scalatags.JsDom.StringNode
[error]  are possible conversion functions from org.scalajs.dom.HTMLLabelElement to scalatags.JsDom.Node
[error]         labelElem
[error]         ^
[error] two errors found
@benjaminjackman
Copy link
Author

Workaround i used was this:

      import scalatags.JsDom.{NumericNode => _, _}
      import scalatags.JsDom.all._

@lihaoyi
Copy link
Member

lihaoyi commented Jun 22, 2014

Yeah, it's a bug in the type inference of 2.10.x. I'll see if i can flatten
out the numeric implicit into implicits for the individual numbers to
workaround the problem

On Sat, Jun 21, 2014 at 7:07 PM, Ben Jackman notifications@github.com
wrote:

Workaround i used was this:

  import scalatags.JsDom.{NumericNode => _, _}
  import scalatags.JsDom.all._


Reply to this email directly or view it on GitHub
#23 (comment).

@lihaoyi
Copy link
Member

lihaoyi commented Jun 22, 2014

I just published 0.3.2, which along with some internal cleanup (picking better names, standardizing order of [Builder, +Output] fixes this problems by splitting the NumericNode into individual implicits for each primitive. Try it out =)

@lihaoyi lihaoyi closed this as completed Jun 22, 2014
@benjaminjackman
Copy link
Author

Ok thank you sir! That worked great.

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

No branches or pull requests

2 participants