package scalacss

import org.scalajs.dom
import org.scalajs.dom.raw.HTMLStyleElement
import scalatags.JsDom._
import all._

trait ScalatagsJsDomImplicits {

  implicit final def styleaToJsDomTag(s: StyleA): Modifier = new Modifier {
    def applyTo(t: dom.Element) = t.classList.add(s.htmlClass)
  }

  implicit final def styleJsDomTagRenderer(implicit s: Renderer[String]): Renderer[TypedTag[HTMLStyleElement]] =
    new ScalatagsJsDomRenderer(s)
}

class ScalatagsJsDomRenderer(s: Renderer[String]) extends Renderer[TypedTag[HTMLStyleElement]] {
  override def apply(css: Css) =
    tags2.style(`type` := "text/css", s(css))
}

package scalacss

import org.scalajs.dom
import org.scalajs.dom.raw.HTMLStyleElement
import scalatags.JsDom._
import all._

trait ScalatagsJsDomImplicits {

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

  implicit final def styleJsDomTagRenderer(implicit s: Renderer[String]): Renderer[TypedTag[HTMLStyleElement]] =
    new ScalatagsJsDomRenderer(s)
}

class ScalatagsJsDomRenderer(s: Renderer[String]) extends Renderer[TypedTag[HTMLStyleElement]] {
  override def apply(css: Css) =
    tags2.style(`type` := "text/css", s(css))
}

Add each class name to the DOM individually, to prevent InvalidCharacterErrors.
Add each class name to the DOM individually, to prevent InvalidCharacterErrors.
