These are chat archives for japgolly/scalacss

20th
Feb 2016
gbeaty
@gbeaty
Feb 20 2016 17:14

I'm getting a browser exception when I try to wrap multiple Bootstrap classes with Scalatags, e.g.

style(addClassNames("btn btn-danger"))

or

style(addClassNames("btn", "btn-danger"))
Uncaught InvalidCharacterError: Failed to execute 'add' on 'DOMTokenList': The token provided ('btn btn-danger') contains HTML space characters, which are not valid in tokens.

I tried fixing it in ScalatagsjsDom.scala:

implicit final def styleaToJsDomTag(s: StyleA): Modifier = new Modifier {
    def applyTo(t: dom.Element) = s.addClassNames.foreach(cn => t.classList.add(cn.value))
  }

... but this seemed to cause other problems, despite passing tests.

gbeaty
@gbeaty
Feb 20 2016 17:20
Any ideas?
gbeaty
@gbeaty
Feb 20 2016 18:05
This fixed it:
implicit final def styleaToJsDomTag(s: StyleA): Modifier = new Modifier {
    def applyTo(t: dom.Element) = s.htmlClass.split(' ').foreach(cn => t.classList.add(cn))
  }