scalafiddle / scalafiddle-core

Source code for the scalafiddle.io compilation service
https://scalafiddle.io
Apache License 2.0
101 stars 37 forks source link

Function styleSheetText of scalatags.stylesheet.StyleSheet class is not functioning well. #33

Open Cloudius opened 6 years ago

Cloudius commented 6 years ago

When calling styleSheetText, e.g. to generated a <style> element, this function gives an empty String while when applied in a non ScalaFiddle environment this function works. In a server-based (JVM) and a standalone Scala.js client application the style text is right generated.

An example is found here -template adjusted- with a working work around (hand-made css). By commenting out the overridden styleSheetText function the desired situation is achieved. However in ScalaFiddle there is no style text put between the tags.

Findings:

  1. In ScalaFiddle the function styleSheetText returns an empty String.
  2. Well generated style code will be generated all other environments.
  3. In all cases the class attributes are generated well
  4. The internal allClasses member of the scalatags.stylesheet.StyleSheet returns a empty List in the ScalaFiddle case, while in other case a non-empty List will be returned.
  5. This indicates that the internal allClasses0 must be (re-)set to Some(() => sourceClasses.value(this))

I hope the problem will be recognized, so an solution should be possible soon.

ochrons commented 6 years ago

The macro that generates the list of classes doesn't seem to work properly in ScalaFiddle (hard to say why). A quick workaround is to manually list your CSS classes like this,

    override def styleSheetText = 
      List(cell, strong, table).map(_.structure.stringify(Nil)).mkString("\n")