Search code examples
scaladomscala.jsscalatags

IntelliJ shows error using scalatags with boolean attributes


Does anyone now why IntelliJ is showing an error here even though sbt compiles and everything works correctly:

enter image description here

*Edit: "stopEnabled" is a Boolean.

As I understand, to not show an error here, I would have to write someting like this:

button(if(!stopEnabled) disabled else JsDom.Modifier.*nothing*)

Is there any way of solving this nicely?


Solution

  • disabled is a nuisance -- IMO, they spec'ed it wrong from the beginning, and have never made it better.

    Offhand, I would guess that Scalatags' frag() constructor is probably the easiest solution: that takes its parameters and wraps them as a single frag. I believe that works even if there are no parameters. So I think you could do:

    div(
      if (stopEnabled)
        frag()
      else
        disabled := "disabled"
    )