From 0cfff0c972d7e198210379eeac1a18ef6cd2d6bf Mon Sep 17 00:00:00 2001 From: Lorenzo Gabriele Date: Thu, 2 Dec 2021 15:37:18 +0100 Subject: [PATCH] Support Scala 3 (#226) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Changes * Add Mima to check how much we break binary compatibility. * Update Mill to version `0.9.10` and fix build deprecations * Add `scalaMajorVersion` in buildInfoMembers since Scala 3 represents types wrapped inside `()` in error messages. * Explicitly apply implicit function `ev: A => Frag` in various implicit classes (like `SeqFrag`) since Scala 3 doesn't apply implicitly. * Remove `protected[this] val RawFrag: Companion[RawFrag]` and `protected[this] val StringFrag: Companion[StringFrag]` since they break variance and Scala 3 is much less permissive with variance. Overriding them with strictier types in subclasses result in compiler errors. Since this was the only use case of `Companion` I removed it as well. Also I failed to represent `Companion` in Scala 3 since it uses [different signatures for `unapply`](https://dotty.epfl.ch/docs/reference/changed-features/pattern-matching.html) * Add explicit types to all `implicit` fields as required by Scala 3. * Replace `def +(other: Any): String` in class `String` with String interpolator since it is not supported in Scala 3 * Make all abstract members in `Tags.scala`, `Tags2.scala` and `SvgTags.scala` `def`s instead of `val`s since Scala 3 doesn't support overriding an abstract `val` member with a `lazy val` as Scalatags does. * Move the `SourceClasses` class and its companion object to the version specific code. Since it is the only code using macros. * Updated tests to not use the `* -` utest syntax. Also not supported in Scala 3. * Move objects used in tests to be stable and not defined in the utest macro. Without this change the Scala 3 version doesn't compile. ## Commits * Update build system for Scala 3 * Initial Scala 3 (dotty) port * Only use str-to-str concatenation There is a bug in the dotty compiler? lampepfl/dotty#13518 scalatags.js[3.0.1,1.7.0].compile java.lang.AssertionError: assertion failed scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11) dotty.tools.backend.sjs.JSCodeGen.genStringConcat(JSCodeGen.scala:2487) dotty.tools.backend.sjs.JSCodeGen.genPrimitiveOp(JSCodeGen.scala:2098) * Bump to Scala 3.0.0 * wip * Use string interpolation instead of `+` * Gitignore /.bsp from Mill BSP * Remove space in quoted start * Reduce duplicated code and fix some compilation error * Remove some lazy vals and revert renames * Most code compiles * All code compiling now * Fix macro to use declaredFields * Remove pprint * Remove empty companion objects * Remove old comment * Avoid to define lazy val Frags * Revert some changes not necessary for Scala 3 * Revert formatting change * Remove unused import * Revert spurious change * Remove spurious import * Refactor filter for ScalaJS versions Co-authored-by: Sakib Hadžiavdić Co-authored-by: Edward Wang Co-authored-by: Sakib Hadžiavdić --- .github/workflows/actions.yml | 13 +- .gitignore | 1 + .mill-version | 2 +- build.sc | 49 ++++-- mill | 2 +- scalatags/js/src/scalatags/JsDom.scala | 18 +- .../js/src/scalatags/jsdom/SvgTags.scala | 2 +- scalatags/js/src/scalatags/jsdom/Tags.scala | 142 ++++++++-------- .../test/src/scalatags/jsdom/DomTests.scala | 9 +- .../scalatags/stylesheet/SourceClasses.scala | 30 ++++ .../scalatags/stylesheet/SourceClasses.scala | 19 +++ scalatags/src/scalatags/DataTypes.scala | 33 ++-- scalatags/src/scalatags/Text.scala | 19 ++- scalatags/src/scalatags/VirtualDom.scala | 16 +- scalatags/src/scalatags/generic/Bundle.scala | 52 +++--- scalatags/src/scalatags/generic/Core.scala | 2 +- scalatags/src/scalatags/generic/Styles.scala | 2 +- scalatags/src/scalatags/generic/SvgTags.scala | 150 ++++++++--------- scalatags/src/scalatags/generic/Tags.scala | 156 +++++++++--------- scalatags/src/scalatags/generic/Tags2.scala | 64 +++---- scalatags/src/scalatags/generic/Util.scala | 11 +- scalatags/src/scalatags/package.scala | 5 - .../src/scalatags/stylesheet/StyleSheet.scala | 33 +--- scalatags/src/scalatags/vdom/SvgTags.scala | 2 +- .../src/scalatags/generic/BasicTests.scala | 13 +- .../src/scalatags/text/BundlingTests.scala | 8 +- 26 files changed, 448 insertions(+), 405 deletions(-) create mode 100644 scalatags/src-2/scalatags/stylesheet/SourceClasses.scala create mode 100644 scalatags/src-3/scalatags/stylesheet/SourceClasses.scala diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 3755fef3..60c40ea3 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -20,7 +20,18 @@ jobs: sudo apt-get install -y nodejs npm install - name: Run tests - run: ./mill -i all __.publishArtifacts __.test + run: ./mill -i --disable-ticker all __.publishArtifacts __.test + check-binary-compatibility: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-java@v1 + with: + java-version: 8 + - name: Check Binary Compatibility + run: ./mill -i --disable-ticker __.mimaReportBinaryIssues publish-sonatype: if: github.repository == 'com-lihaoyi/scalatags' && contains(github.ref, 'refs/tags/') diff --git a/.gitignore b/.gitignore index 873ed491..719e37d3 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ readme/target/* *.iml out /node_modules +/.bsp diff --git a/.mill-version b/.mill-version index 669bf0e3..56f31511 100644 --- a/.mill-version +++ b/.mill-version @@ -1 +1 @@ -0.9.5-52-ef6d5d +0.9.10 diff --git a/build.sc b/build.sc index b779cf7c..61596501 100644 --- a/build.sc +++ b/build.sc @@ -1,15 +1,21 @@ import mill._, scalalib._, scalajslib._, scalanativelib._, publish._ +import $ivy.`com.lihaoyi::mill-contrib-buildinfo:$MILL_VERSION` +import mill.contrib.buildinfo._ import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version_mill0.9:0.1.1` import de.tobiasroeser.mill.vcs.version.VcsVersion +import $ivy.`com.github.lolgab::mill-mima_mill0.9:0.0.6` +import com.github.lolgab.mill.mima._ +import mill.scalalib.api.Util.isScala3 val dottyVersions = sys.props.get("dottyVersion").toList -val scalaVersions = "2.12.13" :: "2.13.4" :: "2.11.12" :: dottyVersions +val scalaVersions = "2.12.13" :: "2.13.4" :: "2.11.12" :: "3.0.2" :: dottyVersions val scala2Versions = scalaVersions.filter(_.startsWith("2.")) val scalaJSVersions = for { - scalaV <- scala2Versions + scalaV <- scalaVersions scalaJSV <- Seq("0.6.33", "1.5.1") + if !(scalaV.startsWith("3.") && scalaJSV.startsWith("0.")) } yield (scalaV, scalaJSV) val scalaNativeVersions = for { @@ -17,19 +23,21 @@ val scalaNativeVersions = for { scalaNativeV <- Seq("0.4.0") } yield (scalaV, scalaNativeV) -trait ScalatagsPublishModule extends PublishModule { +trait ScalatagsPublishModule extends PublishModule with Mima { def artifactName = "scalatags" def publishVersion = VcsVersion.vcsState().format() + def mimaPreviousVersions = Seq("0.10.0") + def pomSettings = PomSettings( description = artifactName(), organization = "com.lihaoyi", url = "https://github.com/lihaoyi/scalatags", licenses = Seq(License.MIT), - scm = SCM( - "git://github.com/lihaoyi/scalatags.git", - "scm:git://github.com/lihaoyi/scalatags.git" + versionControl = VersionControl( + browsableRepository = Some("git://github.com/lihaoyi/scalatags.git"), + connection = Some("scm:git://github.com/lihaoyi/scalatags.git") ), developers = Seq( Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi") @@ -40,12 +48,17 @@ trait ScalatagsPublishModule extends PublishModule { trait Common extends CrossScalaModule { def millSourcePath = super.millSourcePath / offset def ivyDeps = Agg( - ivy"com.lihaoyi::sourcecode::0.2.3", - ivy"com.lihaoyi::geny::0.6.7", - ) - def compileIvyDeps = Agg( - ivy"org.scala-lang:scala-reflect:${scalaVersion()}", + ivy"com.lihaoyi::sourcecode::0.2.7", + ivy"com.lihaoyi::geny::0.6.10", ) + def compileIvyDeps = T { super.compileIvyDeps() ++ + ( + if (isScala3(crossScalaVersion)) Agg() + else Agg( + ivy"org.scala-lang:scala-reflect:${scalaVersion()}" + ) + ) + } def offset: os.RelPath = os.rel def sources = T.sources( super.sources() @@ -58,19 +71,17 @@ trait Common extends CrossScalaModule { ) } -trait CommonTestModule extends ScalaModule with TestModule { +trait CommonTestModule extends ScalaModule with TestModule.Utest with BuildInfo { def millSourcePath = super.millSourcePath / os.up def crossScalaVersion: String - val scalaXmlVersion = if(crossScalaVersion.startsWith("2.11.")) "1.3.0" else "2.0.0-M3" + val scalaXmlVersion = if(crossScalaVersion.startsWith("2.11.")) "1.3.0" else "2.0.1" def ivyDeps = Agg( - ivy"com.lihaoyi::utest::0.7.7", + ivy"com.lihaoyi::utest::0.7.10", ivy"org.scala-lang.modules::scala-xml:$scalaXmlVersion" ) def offset: os.RelPath = os.rel - def testFrameworks = Seq("utest.runner.Framework") def sources = T.sources( super.sources() - .++(CrossModuleBase.scalaVersionPaths(crossScalaVersion, s => millSourcePath / s"src-$s" )) .flatMap(source => Seq( PathRef(source.path / os.up / "test" / source.path.last), @@ -79,6 +90,10 @@ trait CommonTestModule extends ScalaModule with TestModule { ) .distinct ) + override def buildInfoPackageName = Some("scalatags") + override def buildInfoMembers = Map( + "scalaMajorVersion" -> crossScalaVersion.split('.').head + ) } @@ -106,7 +121,7 @@ object scalatags extends Module { def crossScalaVersion = JSScalatagsModule.this.crossScalaVersion val jsDomNodeJs = if(crossJSVersion.startsWith("0.6.")) Agg() - else Agg(ivy"org.scala-js::scalajs-env-jsdom-nodejs:1.1.0") + else Agg(ivy"org.scala-js::scalajs-env-jsdom-nodejs:1.1.0").map(_.withDottyCompat(crossScalaVersion)) def ivyDeps = super.ivyDeps() ++ jsDomNodeJs def jsEnvConfig = mill.scalajslib.api.JsEnvConfig.JsDom() } diff --git a/mill b/mill index cc56cc8b..cf9b7380 100755 --- a/mill +++ b/mill @@ -3,7 +3,7 @@ # This is a wrapper script, that automatically download mill from GitHub release pages # You can give the required mill version with MILL_VERSION env variable # If no version is given, it falls back to the value of DEFAULT_MILL_VERSION -DEFAULT_MILL_VERSION=0.9.5-52-ef6d5d +DEFAULT_MILL_VERSION=0.9.10 set -e diff --git a/scalatags/js/src/scalatags/JsDom.scala b/scalatags/js/src/scalatags/JsDom.scala index 528b18db..62bad7ca 100644 --- a/scalatags/js/src/scalatags/JsDom.scala +++ b/scalatags/js/src/scalatags/JsDom.scala @@ -109,31 +109,29 @@ object JsDom implicit class SeqFrag[A](xs: Seq[A])(implicit ev: A => Frag) extends Frag{ Objects.requireNonNull(xs) - def applyTo(t: dom.Element): Unit = xs.foreach(_.applyTo(t)) + def applyTo(t: dom.Element): Unit = xs.foreach(elem => ev(elem).applyTo(t)) def render: dom.Node = { val frag = org.scalajs.dom.document.createDocumentFragment() - xs.map(_.render).foreach(frag.appendChild) + xs.map(elem => ev(elem).render).foreach(frag.appendChild) frag } } implicit class GeneratorFrag[A](xs: geny.Generator[A])(implicit ev: A => Frag) extends Frag{ Objects.requireNonNull(xs) - def applyTo(t: dom.Element): Unit = xs.foreach(_.applyTo(t)) + def applyTo(t: dom.Element): Unit = xs.foreach(elem => ev(elem).applyTo(t)) def render: dom.Node = { val frag = org.scalajs.dom.document.createDocumentFragment() - xs.map(_.render).foreach(frag.appendChild) + xs.map(elem => ev(elem).render).foreach(frag.appendChild) frag } } } - object StringFrag extends Companion[StringFrag] - case class StringFrag(v: String) extends jsdom.Frag{ + case class StringFrag(v: String) extends jsdom.Frag { Objects.requireNonNull(v) def render: dom.Text = dom.document.createTextNode(v) } - object RawFrag extends Companion[RawFrag] case class RawFrag(v: String) extends jsdom.Frag{ Objects.requireNonNull(v) def render: dom.Node = { @@ -178,7 +176,7 @@ object JsDom def apply(s: Style, v: T) = StylePair(s, v, ev) } class GenericPixelStylePx[T](ev: StyleValue[String]) extends PixelStyleValue[T]{ - def apply(s: Style, v: T) = StylePair(s, v + "px", ev) + def apply(s: Style, v: T) = StylePair(s, s"${v}px", ev) } case class TypedTag[+Output <: dom.Element](tag: String = "", modifiers: List[Seq[Modifier]], @@ -213,9 +211,9 @@ trait LowPriorityImplicits{ t.asInstanceOf[js.Dynamic].updateDynamic(a.name)(v) } } - implicit def bindJsAnyLike[T](implicit ev: T => js.Any) = new generic.AttrValue[dom.Element, T]{ + implicit def bindJsAnyLike[T](implicit ev: T => js.Any): generic.AttrValue[dom.Element, T] = new generic.AttrValue[dom.Element, T]{ def apply(t: dom.Element, a: generic.Attr, v: T): Unit = { - t.asInstanceOf[js.Dynamic].updateDynamic(a.name)(v) + t.asInstanceOf[js.Dynamic].updateDynamic(a.name)(ev(v)) } } implicit class bindNode[T <: dom.Node](e: T) extends generic.Frag[dom.Element, T] { diff --git a/scalatags/js/src/scalatags/jsdom/SvgTags.scala b/scalatags/js/src/scalatags/jsdom/SvgTags.scala index 8246c19b..1b1cc4a7 100644 --- a/scalatags/js/src/scalatags/jsdom/SvgTags.scala +++ b/scalatags/js/src/scalatags/jsdom/SvgTags.scala @@ -3,7 +3,7 @@ package jsdom import org.scalajs.dom import scalatags.generic.{Namespace, Util} trait SvgTags extends generic.SvgTags[dom.Element, dom.Element, dom.Node] with TagFactory{ - implicit lazy val svgNamespaceConfig = Namespace.svgNamespaceConfig + implicit lazy val svgNamespaceConfig: Namespace = Namespace.svgNamespaceConfig lazy val altGlyph = typedTag[dom.svg.Element]("altGlyph") lazy val altGlyphDef = typedTag[dom.svg.Element]("altGlyphDef") lazy val altGlyphItem = typedTag[dom.svg.Element]("altGlyphItem") diff --git a/scalatags/js/src/scalatags/jsdom/Tags.scala b/scalatags/js/src/scalatags/jsdom/Tags.scala index e4b01e12..4f527f33 100644 --- a/scalatags/js/src/scalatags/jsdom/Tags.scala +++ b/scalatags/js/src/scalatags/jsdom/Tags.scala @@ -5,91 +5,91 @@ import org.scalajs.dom import scalatags.generic.Util trait Tags extends generic.Tags[dom.Element, dom.Element, dom.Node] with TagFactory{ // Root Element - lazy val html = typedTag[dom.html.Html]("html") + lazy val html: ConcreteHtmlTag[dom.html.Html] = typedTag[dom.html.Html]("html") // Document Metadata - lazy val head = typedTag[dom.html.Head]("head") - lazy val base = typedTag[dom.html.Base]("base", void = true) - lazy val link = typedTag[dom.html.Link]("link", void = true) - lazy val meta = typedTag[dom.html.Meta]("meta", void = true) + lazy val head: ConcreteHtmlTag[dom.html.Head] = typedTag[dom.html.Head]("head") + lazy val base: ConcreteHtmlTag[dom.html.Base] = typedTag[dom.html.Base]("base", void = true) + lazy val link: ConcreteHtmlTag[dom.html.Link] = typedTag[dom.html.Link]("link", void = true) + lazy val meta: ConcreteHtmlTag[dom.html.Meta] = typedTag[dom.html.Meta]("meta", void = true) // Scripting - lazy val script = typedTag[dom.html.Script]("script") + lazy val script: ConcreteHtmlTag[dom.html.Script] = typedTag[dom.html.Script]("script") // Sections - lazy val body = typedTag[dom.html.Body]("body") + lazy val body: ConcreteHtmlTag[dom.html.Body] = typedTag[dom.html.Body]("body") lazy val h1 = typedTag[dom.html.Heading]("h1") lazy val h2 = typedTag[dom.html.Heading]("h2") lazy val h3 = typedTag[dom.html.Heading]("h3") lazy val h4 = typedTag[dom.html.Heading]("h4") lazy val h5 = typedTag[dom.html.Heading]("h5") lazy val h6 = typedTag[dom.html.Heading]("h6") - lazy val header = typedTag[dom.html.Element]("header") - lazy val footer = typedTag[dom.html.Element]("footer") + lazy val header: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("header") + lazy val footer: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("footer") // Grouping content - lazy val p = typedTag[dom.html.Paragraph]("p") - lazy val hr = typedTag[dom.html.HR]("hr", void = true) - lazy val pre = typedTag[dom.html.Pre]("pre") - lazy val blockquote = typedTag[dom.html.Quote]("blockquote") - lazy val ol = typedTag[dom.html.OList]("ol") - lazy val ul = typedTag[dom.html.UList]("ul") - lazy val li = typedTag[dom.html.LI]("li") - lazy val dl = typedTag[dom.html.DList]("dl") - lazy val dt = typedTag[dom.html.Element]("dt") - lazy val dd = typedTag[dom.html.Element]("dd") - lazy val figure = typedTag[dom.html.Element]("figure") - lazy val figcaption = typedTag[dom.html.Element]("figcaption") - lazy val div = typedTag[dom.html.Div]("div") + lazy val p: ConcreteHtmlTag[dom.html.Paragraph] = typedTag[dom.html.Paragraph]("p") + lazy val hr: ConcreteHtmlTag[dom.html.HR] = typedTag[dom.html.HR]("hr", void = true) + lazy val pre: ConcreteHtmlTag[dom.html.Pre] = typedTag[dom.html.Pre]("pre") + lazy val blockquote: ConcreteHtmlTag[dom.html.Quote] = typedTag[dom.html.Quote]("blockquote") + lazy val ol: ConcreteHtmlTag[dom.html.OList] = typedTag[dom.html.OList]("ol") + lazy val ul: ConcreteHtmlTag[dom.html.UList] = typedTag[dom.html.UList]("ul") + lazy val li: ConcreteHtmlTag[dom.html.LI] = typedTag[dom.html.LI]("li") + lazy val dl: ConcreteHtmlTag[dom.html.DList] = typedTag[dom.html.DList]("dl") + lazy val dt: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("dt") + lazy val dd: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("dd") + lazy val figure: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("figure") + lazy val figcaption: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("figcaption") + lazy val div: ConcreteHtmlTag[dom.html.Div] = typedTag[dom.html.Div]("div") // Text-level semantics - lazy val a = typedTag[dom.html.Anchor]("a") - lazy val em = typedTag[dom.html.Element]("em") - lazy val strong = typedTag[dom.html.Element]("strong") - lazy val small = typedTag[dom.html.Element]("small") - lazy val s = typedTag[dom.html.Element]("s") - lazy val cite = typedTag[dom.html.Element]("cite") - lazy val code = typedTag[dom.html.Element]("code") - lazy val sub = typedTag[dom.html.Element]("sub") - lazy val sup = typedTag[dom.html.Element]("sup") - lazy val i = typedTag[dom.html.Element]("i") - lazy val b = typedTag[dom.html.Element]("b") - lazy val u = typedTag[dom.html.Element]("u") - lazy val span = typedTag[dom.html.Span]("span") - lazy val br = typedTag[dom.html.BR]("br", void = true) - lazy val wbr = typedTag[dom.html.Element]("wbr", void = true) + lazy val a: ConcreteHtmlTag[dom.html.Anchor] = typedTag[dom.html.Anchor]("a") + lazy val em: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("em") + lazy val strong: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("strong") + lazy val small: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("small") + lazy val s: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("s") + lazy val cite: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("cite") + lazy val code: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("code") + lazy val sub: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("sub") + lazy val sup: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("sup") + lazy val i: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("i") + lazy val b: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("b") + lazy val u: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("u") + lazy val span: ConcreteHtmlTag[dom.html.Span] = typedTag[dom.html.Span]("span") + lazy val br: ConcreteHtmlTag[dom.html.BR] = typedTag[dom.html.BR]("br", void = true) + lazy val wbr: ConcreteHtmlTag[dom.html.Element] = typedTag[dom.html.Element]("wbr", void = true) // Edits - lazy val ins = typedTag[dom.html.Mod]("ins") - lazy val del = typedTag[dom.html.Mod]("del") + lazy val ins: ConcreteHtmlTag[dom.html.Mod] = typedTag[dom.html.Mod]("ins") + lazy val del: ConcreteHtmlTag[dom.html.Mod] = typedTag[dom.html.Mod]("del") // Embedded content - lazy val img = typedTag[dom.html.Image]("img", void = true) - lazy val iframe = typedTag[dom.html.IFrame]("iframe") - lazy val embed = typedTag[dom.html.Embed]("embed", void = true) + lazy val img: ConcreteHtmlTag[dom.html.Image] = typedTag[dom.html.Image]("img", void = true) + lazy val iframe: ConcreteHtmlTag[dom.html.IFrame] = typedTag[dom.html.IFrame]("iframe") + lazy val embed: ConcreteHtmlTag[dom.html.Embed] = typedTag[dom.html.Embed]("embed", void = true) lazy val `object` = typedTag[dom.html.Object]("object") - lazy val param = typedTag[dom.html.Param]("param", void = true) - lazy val video = typedTag[dom.html.Video]("video") - lazy val audio = typedTag[dom.html.Audio]("audio") - lazy val source = typedTag[dom.html.Source]("source", void = true) - lazy val track = typedTag[dom.html.Track]("track", void = true) - lazy val canvas = typedTag[dom.html.Canvas]("canvas") - lazy val map = typedTag[dom.html.Map]("map") - lazy val area = typedTag[dom.html.Area]("area", void = true) + lazy val param: ConcreteHtmlTag[dom.html.Param] = typedTag[dom.html.Param]("param", void = true) + lazy val video: ConcreteHtmlTag[dom.html.Video] = typedTag[dom.html.Video]("video") + lazy val audio: ConcreteHtmlTag[dom.html.Audio] = typedTag[dom.html.Audio]("audio") + lazy val source: ConcreteHtmlTag[dom.html.Source] = typedTag[dom.html.Source]("source", void = true) + lazy val track: ConcreteHtmlTag[dom.html.Track] = typedTag[dom.html.Track]("track", void = true) + lazy val canvas: ConcreteHtmlTag[dom.html.Canvas] = typedTag[dom.html.Canvas]("canvas") + lazy val map: ConcreteHtmlTag[dom.html.Map] = typedTag[dom.html.Map]("map") + lazy val area: ConcreteHtmlTag[dom.html.Area] = typedTag[dom.html.Area]("area", void = true) // Tabular data - lazy val table = typedTag[dom.html.Table]("table") - lazy val caption = typedTag[dom.html.TableCaption]("caption") - lazy val colgroup = typedTag[dom.html.TableCol]("colgroup") - lazy val col = typedTag[dom.html.TableCol]("col", void = true) - lazy val tbody = typedTag[dom.html.TableSection]("tbody") - lazy val thead = typedTag[dom.html.TableSection]("thead") - lazy val tfoot = typedTag[dom.html.TableSection]("tfoot") - lazy val tr = typedTag[dom.html.TableRow]("tr") - lazy val td = typedTag[dom.html.TableCell]("td") - lazy val th = typedTag[dom.html.TableCell]("th") + lazy val table: ConcreteHtmlTag[dom.html.Table] = typedTag[dom.html.Table]("table") + lazy val caption: ConcreteHtmlTag[dom.html.TableCaption] = typedTag[dom.html.TableCaption]("caption") + lazy val colgroup: ConcreteHtmlTag[dom.html.TableCol] = typedTag[dom.html.TableCol]("colgroup") + lazy val col: ConcreteHtmlTag[dom.html.TableCol] = typedTag[dom.html.TableCol]("col", void = true) + lazy val tbody: ConcreteHtmlTag[dom.html.TableSection] = typedTag[dom.html.TableSection]("tbody") + lazy val thead: ConcreteHtmlTag[dom.html.TableSection] = typedTag[dom.html.TableSection]("thead") + lazy val tfoot: ConcreteHtmlTag[dom.html.TableSection] = typedTag[dom.html.TableSection]("tfoot") + lazy val tr: ConcreteHtmlTag[dom.html.TableRow] = typedTag[dom.html.TableRow]("tr") + lazy val td: ConcreteHtmlTag[dom.html.TableCell] = typedTag[dom.html.TableCell]("td") + lazy val th: ConcreteHtmlTag[dom.html.TableCell] = typedTag[dom.html.TableCell]("th") // Forms - lazy val form = typedTag[dom.html.Form]("form") - lazy val fieldset = typedTag[dom.html.FieldSet]("fieldset") - lazy val legend = typedTag[dom.html.Legend]("legend") - lazy val label = typedTag[dom.html.Label]("label") - lazy val input = typedTag[dom.html.Input]("input", void = true) - lazy val button = typedTag[dom.html.Button]("button") - lazy val select = typedTag[dom.html.Select]("select") - lazy val datalist = typedTag[dom.html.DataList]("datalist") - lazy val optgroup = typedTag[dom.html.OptGroup]("optgroup") - lazy val option = typedTag[dom.html.Option]("option") - lazy val textarea = typedTag[dom.html.TextArea]("textarea") + lazy val form: ConcreteHtmlTag[dom.html.Form] = typedTag[dom.html.Form]("form") + lazy val fieldset: ConcreteHtmlTag[dom.html.FieldSet] = typedTag[dom.html.FieldSet]("fieldset") + lazy val legend: ConcreteHtmlTag[dom.html.Legend] = typedTag[dom.html.Legend]("legend") + lazy val label: ConcreteHtmlTag[dom.html.Label] = typedTag[dom.html.Label]("label") + lazy val input: ConcreteHtmlTag[dom.html.Input] = typedTag[dom.html.Input]("input", void = true) + lazy val button: ConcreteHtmlTag[dom.html.Button] = typedTag[dom.html.Button]("button") + lazy val select: ConcreteHtmlTag[dom.html.Select] = typedTag[dom.html.Select]("select") + lazy val datalist: ConcreteHtmlTag[dom.html.DataList] = typedTag[dom.html.DataList]("datalist") + lazy val optgroup: ConcreteHtmlTag[dom.html.OptGroup] = typedTag[dom.html.OptGroup]("optgroup") + lazy val option: ConcreteHtmlTag[dom.html.Option] = typedTag[dom.html.Option]("option") + lazy val textarea: ConcreteHtmlTag[dom.html.TextArea] = typedTag[dom.html.TextArea]("textarea") } diff --git a/scalatags/js/test/src/scalatags/jsdom/DomTests.scala b/scalatags/js/test/src/scalatags/jsdom/DomTests.scala index a22453ae..4a8e7076 100644 --- a/scalatags/js/test/src/scalatags/jsdom/DomTests.scala +++ b/scalatags/js/test/src/scalatags/jsdom/DomTests.scala @@ -8,6 +8,10 @@ import org.scalajs.dom import org.scalajs.dom.html.Paragraph object DomTests extends TestSuite{ + class SharedTemplates[Builder, Output <: FragT, FragT](val bundle: scalatags.generic.Bundle[Builder, Output, FragT]){ + import bundle.all._ + val widget: Tag = div("hello") + } def tests = TestSuite{ test("basic"){ import scalatags.JsDom.all._ @@ -98,11 +102,6 @@ object DomTests extends TestSuite{ } test("crossTag"){ - class SharedTemplates[Builder, Output <: FragT, FragT](val bundle: scalatags.generic.Bundle[Builder, Output, FragT]){ - import bundle.all._ - val widget: Tag = div("hello") - } - object JsTemplates extends SharedTemplates(scalatags.JsDom) object TextTemplates extends SharedTemplates(scalatags.Text) diff --git a/scalatags/src-2/scalatags/stylesheet/SourceClasses.scala b/scalatags/src-2/scalatags/stylesheet/SourceClasses.scala new file mode 100644 index 00000000..3f4557a4 --- /dev/null +++ b/scalatags/src-2/scalatags/stylesheet/SourceClasses.scala @@ -0,0 +1,30 @@ +package scalatags.stylesheet + +import scala.language.experimental.macros +import scala.reflect.macros.Context + +class SourceClasses[T](val value: T => Seq[Cls]) +object SourceClasses{ + implicit def apply[T]: SourceClasses[T] = macro manglerImpl[T] + def manglerImpl[T: c.WeakTypeTag](c: Context) = { + import c.universe._ + + val weakType = weakTypeOf[T] + + val stylesheetName = newTermName("stylesheet") + val names = for { + member <- weakType.members.toSeq.reverse + // Not sure if there's a better way to capture by-name types + if member.typeSignature.toString == "=> scalatags.stylesheet.Cls" || + member.typeSignature.toString == "scalatags.stylesheet.Cls" + if member.isPublic + } yield q"$stylesheetName.${member.name.toTermName}" + val res = q""" + new scalatags.stylesheet.SourceClasses[$weakType]( + ($stylesheetName: $weakType) => Seq[scalatags.stylesheet.Cls](..$names) + ) + """ + + c.Expr[SourceClasses[T]](res) + } +} diff --git a/scalatags/src-3/scalatags/stylesheet/SourceClasses.scala b/scalatags/src-3/scalatags/stylesheet/SourceClasses.scala new file mode 100644 index 00000000..4092eb1f --- /dev/null +++ b/scalatags/src-3/scalatags/stylesheet/SourceClasses.scala @@ -0,0 +1,19 @@ +package scalatags.stylesheet + +import scala.quoted.* + +class SourceClasses[T](val value: T => Seq[Cls]) +object SourceClasses { + inline implicit def apply[T]: SourceClasses[T] = ${ manglerImpl[T] } + + def manglerImpl[T: Type](using Quotes): Expr[SourceClasses[T]] = { + '{ new SourceClasses[T]((t: T) => ${ Expr.ofSeq(terms('t)) }) } + } + + private def terms[T: Type](t: Expr[T])(using ctx: Quotes): Seq[Expr[Cls]] = { + import ctx.reflect._ + val valdefs = TypeRepr.of[T].typeSymbol.declaredFields.map(_.tree.asInstanceOf[ValDef]) + val clsesOnly: Seq[ValDef] = valdefs.filter(_.tpt.tpe =:= TypeRepr.of[Cls]) + clsesOnly.map(valdef => t.asTerm.select(valdef.symbol).asExprOf[Cls]) + } +} diff --git a/scalatags/src/scalatags/DataTypes.scala b/scalatags/src/scalatags/DataTypes.scala index 1a8ced8a..8ec73c91 100644 --- a/scalatags/src/scalatags/DataTypes.scala +++ b/scalatags/src/scalatags/DataTypes.scala @@ -1,4 +1,7 @@ package scalatags + +import scala.language.implicitConversions + /** * Module containing convenient ways of constructing CSS data types */ @@ -32,42 +35,42 @@ trait DataConverters{ * * MDN */ - def px = x + "px" + def px = s"${x}px" /** * One point which is 1/72 of an inch. * * MDN */ - def pt = x + "pt" + def pt = s"${x}pt" /** * One millimeter. * * MDN */ - def mm = x + "mm" + def mm = s"${x}mm" /** * One centimeter 10 millimeters. * * MDN */ - def cm = x + "cm" + def cm = s"${x}cm" /** * One inch 2.54 centimeters. * * MDN */ - def in = x + "in" + def in = s"${x}in" /** * One pica which is 12 points. * * MDN */ - def pc = x + "pc" + def pc = s"${x}pc" /** * This unit represents the calculated font-size of the element. If used on * the font-size property itself, it represents the inherited font-size @@ -75,7 +78,7 @@ trait DataConverters{ * * MDN */ - def em = x + "em" + def em = s"${x}em" /** * This unit represents the width, or more precisely the advance measure, of @@ -83,7 +86,7 @@ trait DataConverters{ * * MDN */ - def ch = x + "ch" + def ch = s"${x}ch" /** * This unit represents the x-height of the element's font. On fonts with the @@ -92,7 +95,7 @@ trait DataConverters{ * * MDN */ - def ex = x + "ex" + def ex = s"${x}ex" /** * This unit represents the font-size of the root element e.g. the font-size @@ -101,12 +104,12 @@ trait DataConverters{ * * MDN */ - def rem = x + "rem" + def rem = s"${x}rem" /** * An angle in degrees. One full circle is 360deg. E.g. 0deg, 90deg, 360deg. */ - def deg = x + "deg" + def deg = s"${x}deg" /** * An angle in gradians. One full circle is 400grad. E.g. 0grad, 100grad, @@ -114,7 +117,7 @@ trait DataConverters{ * * MDN */ - def grad = x + "grad" + def grad = s"${x}grad" /** * An angle in radians. One full circle is 2π radians which approximates @@ -122,7 +125,7 @@ trait DataConverters{ * * MDN */ - def rad = x + "rad" + def rad = s"${x}rad" /** * The number of turns the angle is. One full circle is 1turn. E.g. 0turn, @@ -130,12 +133,12 @@ trait DataConverters{ * * MDN */ - def turn = x + "turn" + def turn = s"${x}turn" /** * A percentage value */ - def pct = x + "%" + def pct = s"${x}%" } } diff --git a/scalatags/src/scalatags/Text.scala b/scalatags/src/scalatags/Text.scala index 13d6ec34..74731c70 100644 --- a/scalatags/src/scalatags/Text.scala +++ b/scalatags/src/scalatags/Text.scala @@ -6,6 +6,8 @@ import scala.annotation.unchecked.uncheckedVariance import scalatags.stylesheet.{StyleSheetFrag, StyleTree} import scalatags.text.Builder +import scala.language.implicitConversions + /** * A Scalatags module that works with a text back-end, i.e. it creates HTML * `String`s. @@ -51,18 +53,18 @@ object Text protected[this] implicit def stringStyleX = new GenericStyle[String] protected[this] implicit def stringPixelStyleX = new GenericPixelStyle[String](stringStyleX) implicit def UnitFrag(u: Unit) = new Text.StringFrag("") - def makeAbstractTypedTag[T](tag: String, void: Boolean, namespaceConfig: Namespace) = { + def makeAbstractTypedTag[T <: String](tag: String, void: Boolean, namespaceConfig: Namespace): TypedTag[T] = { TypedTag(tag, Nil, void) } implicit class SeqFrag[A](xs: Seq[A])(implicit ev: A => Frag) extends Frag{ Objects.requireNonNull(xs) - def applyTo(t: text.Builder) = xs.foreach(_.applyTo(t)) - def render = xs.map(_.render).mkString + def applyTo(t: text.Builder) = xs.foreach(elem => ev(elem).applyTo(t)) + def render = xs.map(elem => ev(elem).render).mkString } implicit class GeneratorFrag[A](xs: geny.Generator[A])(implicit ev: A => Frag) extends Frag{ Objects.requireNonNull(xs) - def applyTo(t: text.Builder) = xs.foreach(_.applyTo(t)) - def render = xs.map(_.render).mkString + def applyTo(t: text.Builder) = xs.foreach(elem => ev(elem).applyTo(t)) + def render = xs.map(elem => ev(elem).render).mkString } case class doctype(s: String)(content: text.Frag) extends geny.Writable{ @@ -129,9 +131,8 @@ object Text } def writeTo(strb: java.io.Writer) = Escaping.escape(v, strb) } - object StringFrag extends Companion[StringFrag] - object RawFrag extends Companion[RawFrag] - case class RawFrag(v: String) extends text.Frag { + + case class RawFrag(v: String) extends text.Frag{ Objects.requireNonNull(v) def render = v def writeTo(strb: java.io.Writer) = strb.append(v) @@ -153,7 +154,7 @@ object Text } class GenericPixelStylePx[T](ev: StyleValue[String]) extends PixelStyleValue[T]{ def apply(s: Style, v: T) = { - StylePair(s, v + "px", ev) + StylePair(s, s"${v}px", ev) } } diff --git a/scalatags/src/scalatags/VirtualDom.scala b/scalatags/src/scalatags/VirtualDom.scala index fbb9b3bd..cdd6b056 100644 --- a/scalatags/src/scalatags/VirtualDom.scala +++ b/scalatags/src/scalatags/VirtualDom.scala @@ -2,13 +2,11 @@ package scalatags import java.util.Objects - -import scala.language.implicitConversions - -import scala.annotation.unchecked.uncheckedVariance import scalatags.generic.{Aliases, Namespace, StylePair} import scalatags.stylesheet.{StyleSheetFrag, StyleTree} +import scala.annotation.unchecked.uncheckedVariance +import scala.language.implicitConversions /** * A Scalatags module that can be configured to construct arbitrary virtual DOM @@ -101,33 +99,31 @@ trait VirtualDom[Output <: FragT, FragT] protected[this] implicit def stringStyleX = new GenericStyle[String] protected[this] implicit def stringPixelStyleX = new GenericPixelStyle[String](stringStyleX) implicit def UnitFrag(u: Unit): VirtualDom.this.StringFrag = new VirtualDom.this.StringFrag("") - def makeAbstractTypedTag[T](tag: String, void: Boolean, namespaceConfig: Namespace) = { + def makeAbstractTypedTag[T <: Output](tag: String, void: Boolean, namespaceConfig: Namespace): TypedTag[T] = { TypedTag(tag, Nil, void, namespaceConfig) } implicit class SeqFrag[A](xs: Seq[A])(implicit ev: A => Frag) extends Frag{ Objects.requireNonNull(xs) - def applyTo(t: vdom.Builder[Output, FragT]): Unit = xs.foreach(_.applyTo(t)) + def applyTo(t: vdom.Builder[Output, FragT]): Unit = xs.foreach(elem => ev(elem).applyTo(t)) def render: FragT = { throw new Exception("Rendering of bare arrays of nodes is not supported in virtual dom backend") } } implicit class GeneratorFrag[A](xs: geny.Generator[A])(implicit ev: A => Frag) extends Frag{ Objects.requireNonNull(xs) - def applyTo(t: vdom.Builder[Output, FragT]): Unit = xs.foreach(_.applyTo(t)) + def applyTo(t: vdom.Builder[Output, FragT]): Unit = xs.foreach(elem => ev(elem).applyTo(t)) def render: FragT = { throw new Exception("Rendering of bare arrays of nodes is not supported in virtual dom backend") } } } - object StringFrag extends Companion[StringFrag] case class StringFrag(v: String) extends vdom.Frag[Output, FragT]{ Objects.requireNonNull(v) def render: FragT = stringToFrag(v) } - object RawFrag extends Companion[RawFrag] case class RawFrag(v: String) extends vdom.Frag[Output, FragT]{ Objects.requireNonNull(v) def render = rawToFrag(v) @@ -148,7 +144,7 @@ trait VirtualDom[Output <: FragT, FragT] def apply(s: Style, v: T) = StylePair(s, v, ev) } class GenericPixelStylePx[T](ev: StyleValue[String]) extends PixelStyleValue[T]{ - def apply(s: Style, v: T) = StylePair(s, v + "px", ev) + def apply(s: Style, v: T) = StylePair(s, s"${v}px", ev) } case class TypedTag[+O <: Output](tag: String = "", modifiers: List[Seq[Modifier]], diff --git a/scalatags/src/scalatags/generic/Bundle.scala b/scalatags/src/scalatags/generic/Bundle.scala index 23389b6e..63a60710 100644 --- a/scalatags/src/scalatags/generic/Bundle.scala +++ b/scalatags/src/scalatags/generic/Bundle.scala @@ -3,6 +3,8 @@ package generic import scalatags.stylesheet.StyleSheetFrag import scalatags.text +import scala.language.implicitConversions + /** * An abstract representation of the Scalatags package. This allows you to * customize Scalatags to work with different backends, by defining your own @@ -106,13 +108,11 @@ trait Aliases[Builder, Output <: FragT, FragT]{ * A [[Modifier]] which contains a String which will not be escaped. */ protected[this] type RawFrag <: Modifier - protected[this] val RawFrag: Companion[RawFrag] /** * A [[Modifier]] which contains a String. */ protected[this] type StringFrag <: Modifier - protected[this] val StringFrag: Companion[StringFrag] type Frag = generic.Frag[Builder, FragT] } @@ -120,35 +120,35 @@ trait Aggregate[Builder, Output <: FragT, FragT] extends Aliases[Builder, Output implicit def StyleFrag(s: StylePair[Builder, _]): StyleSheetFrag implicit def ClsModifier(s: stylesheet.Cls): Modifier def genericAttr[T]: AttrValue[T] - implicit val stringAttr = genericAttr[String] - implicit val booleanAttr = genericAttr[Boolean] - implicit val byteAttr = genericAttr[Byte] - implicit val shortAttr = genericAttr[Short] - implicit val intAttr = genericAttr[Int] - implicit val longAttr = genericAttr[Long] - implicit val floatAttr = genericAttr[Float] - implicit val doubleAttr = genericAttr[Double] + implicit val stringAttr: AttrValue[String] = genericAttr[String] + implicit val booleanAttr: AttrValue[Boolean] = genericAttr[Boolean] + implicit val byteAttr: AttrValue[Byte] = genericAttr[Byte] + implicit val shortAttr: AttrValue[Short] = genericAttr[Short] + implicit val intAttr: AttrValue[Int] = genericAttr[Int] + implicit val longAttr: AttrValue[Long] = genericAttr[Long] + implicit val floatAttr: AttrValue[Float] = genericAttr[Float] + implicit val doubleAttr: AttrValue[Double] = genericAttr[Double] def genericStyle[T]: StyleValue[T] - implicit val stringStyle = genericStyle[String] - implicit val booleanStyle = genericStyle[Boolean] - implicit val byteStyle = genericStyle[Byte] - implicit val shortStyle = genericStyle[Short] - implicit val intStyle = genericStyle[Int] - implicit val longStyle = genericStyle[Long] - implicit val floatStyle = genericStyle[Float] - implicit val doubleStyle = genericStyle[Double] + implicit val stringStyle: StyleValue[String] = genericStyle[String] + implicit val booleanStyle: StyleValue[Boolean] = genericStyle[Boolean] + implicit val byteStyle: StyleValue[Byte] = genericStyle[Byte] + implicit val shortStyle: StyleValue[Short] = genericStyle[Short] + implicit val intStyle: StyleValue[Int] = genericStyle[Int] + implicit val longStyle: StyleValue[Long] = genericStyle[Long] + implicit val floatStyle: StyleValue[Float] = genericStyle[Float] + implicit val doubleStyle: StyleValue[Double] = genericStyle[Double] def genericPixelStyle[T](implicit ev: StyleValue[T]): PixelStyleValue[T] def genericPixelStylePx[T](implicit ev: StyleValue[String]): PixelStyleValue[T] - implicit val stringPixelStyle = genericPixelStyle[String] - implicit val booleanPixelStyle = genericPixelStyle[Boolean] - implicit val bytePixelStyle = genericPixelStylePx[Byte] - implicit val shortPixelStyle = genericPixelStylePx[Short] - implicit val intPixelStyle = genericPixelStylePx[Int] - implicit val longPixelStyle = genericPixelStylePx[Long] - implicit val floatPixelStyle = genericPixelStylePx[Float] - implicit val doublePixelStyle = genericPixelStylePx[Double] + implicit val stringPixelStyle: PixelStyleValue[String] = genericPixelStyle[String] + implicit val booleanPixelStyle: PixelStyleValue[Boolean] = genericPixelStyle[Boolean] + implicit val bytePixelStyle: PixelStyleValue[Byte] = genericPixelStylePx[Byte] + implicit val shortPixelStyle: PixelStyleValue[Short] = genericPixelStylePx[Short] + implicit val intPixelStyle: PixelStyleValue[Int] = genericPixelStylePx[Int] + implicit val longPixelStyle: PixelStyleValue[Long] = genericPixelStylePx[Long] + implicit val floatPixelStyle: PixelStyleValue[Float] = genericPixelStylePx[Float] + implicit val doublePixelStyle: PixelStyleValue[Double] = genericPixelStylePx[Double] implicit def byteFrag(v: Byte): Frag = stringFrag(v.toString) implicit def shortFrag(v: Short): Frag = stringFrag(v.toString) diff --git a/scalatags/src/scalatags/generic/Core.scala b/scalatags/src/scalatags/generic/Core.scala index 24a41aae..cc564514 100644 --- a/scalatags/src/scalatags/generic/Core.scala +++ b/scalatags/src/scalatags/generic/Core.scala @@ -208,7 +208,7 @@ trait Namespace { def uri: String } object Namespace{ - implicit val htmlNamespaceConfig = new Namespace { + implicit val htmlNamespaceConfig: Namespace = new Namespace { def uri = "http://www.w3.org/1999/xhtml" } val svgNamespaceConfig = new Namespace { diff --git a/scalatags/src/scalatags/generic/Styles.scala b/scalatags/src/scalatags/generic/Styles.scala index 5cfa770d..d069dddd 100644 --- a/scalatags/src/scalatags/generic/Styles.scala +++ b/scalatags/src/scalatags/generic/Styles.scala @@ -2373,7 +2373,7 @@ trait Styles[Builder, Output <: FragT, FragT] extends StyleMisc[Builder, Output, lazy val none = this := "none" def ~(pairs: (String, String)*) = { - this := pairs.flatMap(x => Seq(x._1, x._2)).map('"' + _ + '"').mkString(" ") + this := pairs.flatMap(x => Seq(x._1, x._2)).map(item => s""""$item"""").mkString(" ") } } diff --git a/scalatags/src/scalatags/generic/SvgTags.scala b/scalatags/src/scalatags/generic/SvgTags.scala index 99e35c63..b562b7a4 100644 --- a/scalatags/src/scalatags/generic/SvgTags.scala +++ b/scalatags/src/scalatags/generic/SvgTags.scala @@ -11,13 +11,13 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val altGlyph: TypedTag[Builder, Output, FragT] + def altGlyph: TypedTag[Builder, Output, FragT] /** * The altGlyphDef element defines a substitution representation for glyphs. * * MDN */ - val altGlyphDef: TypedTag[Builder, Output, FragT] + def altGlyphDef: TypedTag[Builder, Output, FragT] /** * The altGlyphItem element provides a set of candidates for glyph substitution @@ -25,21 +25,21 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val altGlyphItem: TypedTag[Builder, Output, FragT] + def altGlyphItem: TypedTag[Builder, Output, FragT] /** * The animate element is put inside a shape element and defines how an * attribute of an element changes over the animation * * MDN */ - val animate: TypedTag[Builder, Output, FragT] + def animate: TypedTag[Builder, Output, FragT] /** * The animateMotion element causes a referenced element to move along a * motion path. * * MDN */ - val animateMotion: TypedTag[Builder, Output, FragT] + def animateMotion: TypedTag[Builder, Output, FragT] /** * The animateTransform element animates a transformation attribute on a target * element, thereby allowing animations to control translation, scaling, @@ -47,14 +47,14 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val animateTransform: TypedTag[Builder, Output, FragT] + def animateTransform: TypedTag[Builder, Output, FragT] /** * The circle element is an SVG basic shape, used to create circles based on a * center point and a radius. * * MDN */ - val circle: TypedTag[Builder, Output, FragT] + def circle: TypedTag[Builder, Output, FragT] /** * The clipping path restricts the region to which paint can be applied. * Conceptually, any parts of the drawing that lie outside of the region @@ -62,13 +62,13 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val clipPath: TypedTag[Builder, Output, FragT] + def clipPath: TypedTag[Builder, Output, FragT] /** * The element allows describing the color profile used for the image. * * MDN */ - val `color-profile`: TypedTag[Builder, Output, FragT] + def `color-profile`: TypedTag[Builder, Output, FragT] /** * The cursor element can be used to define a platform-independent custom * cursor. A recommended approach for defining a platform-independent custom @@ -78,7 +78,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val cursor: TypedTag[Builder, Output, FragT] + def cursor: TypedTag[Builder, Output, FragT] /** * SVG allows graphical objects to be defined for later reuse. It is * recommended that, wherever possible, referenced elements be defined inside @@ -90,7 +90,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val defs: TypedTag[Builder, Output, FragT] + def defs: TypedTag[Builder, Output, FragT] /** * Each container element or graphics element in an SVG drawing can supply a * desc description string where the description is text-only. When the @@ -102,7 +102,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val desc: TypedTag[Builder, Output, FragT] + def desc: TypedTag[Builder, Output, FragT] /** * The ellipse element is an SVG basic shape, used to create ellipses based * on a center coordinate, and both their x and y radius. @@ -113,7 +113,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val ellipse: TypedTag[Builder, Output, FragT] + def ellipse: TypedTag[Builder, Output, FragT] /** * The feBlend filter composes two objects together ruled by a certain blending * mode. This is similar to what is known from image editing software when @@ -121,7 +121,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val feBlend: TypedTag[Builder, Output, FragT] + def feBlend: TypedTag[Builder, Output, FragT] /** * This filter changes colors based on a transformation matrix. Every pixel's * color value (represented by an [R,G,B,A] vector) is matrix multiplied to @@ -129,7 +129,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val feColorMatrix: TypedTag[Builder, Output, FragT] + def feColorMatrix: TypedTag[Builder, Output, FragT] /** * The color of each pixel is modified by changing each channel (R, G, B, and * A) to the result of what the children feFuncR, feFuncB, feFuncG, @@ -137,7 +137,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val feComponentTransfer: TypedTag[Builder, Output, FragT] + def feComponentTransfer: TypedTag[Builder, Output, FragT] /** * This filter primitive performs the combination of two input images pixel-wise * in image space using one of the Porter-Duff compositing operations: over, @@ -146,7 +146,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val feComposite: TypedTag[Builder, Output, FragT] + def feComposite: TypedTag[Builder, Output, FragT] /** * the feConvolveMatrix element applies a matrix convolution filter effect. * A convolution combines pixels in the input image with neighboring pixels @@ -156,7 +156,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val feConvolveMatrix: TypedTag[Builder, Output, FragT] + def feConvolveMatrix: TypedTag[Builder, Output, FragT] /** * This filter primitive lights an image using the alpha channel as a bump map. * The resulting image, which is an RGBA opaque image, depends on the light @@ -164,14 +164,14 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val feDiffuseLighting: TypedTag[Builder, Output, FragT] + def feDiffuseLighting: TypedTag[Builder, Output, FragT] /** * This filter primitive uses the pixels values from the image from in2 to * spatially displace the image from in. * * MDN */ - val feDisplacementMap: TypedTag[Builder, Output, FragT] + def feDisplacementMap: TypedTag[Builder, Output, FragT] /** * This filter primitive define a distant light source that can be used * within a lighting filter primitive: feDiffuseLighting or @@ -179,49 +179,49 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val feDistantLighting: TypedTag[Builder, Output, FragT] + def feDistantLighting: TypedTag[Builder, Output, FragT] /** * The filter fills the filter subregion with the color and opacity defined by * flood-color and flood-opacity. * * MDN */ - val feFlood: TypedTag[Builder, Output, FragT] + def feFlood: TypedTag[Builder, Output, FragT] /** * This filter primitive defines the transfer function for the alpha component * of the input graphic of its parent feComponentTransfer element. * * MDN */ - val feFuncA: TypedTag[Builder, Output, FragT] + def feFuncA: TypedTag[Builder, Output, FragT] /** * This filter primitive defines the transfer function for the blue component * of the input graphic of its parent feComponentTransfer element. * * MDN */ - val feFuncB: TypedTag[Builder, Output, FragT] + def feFuncB: TypedTag[Builder, Output, FragT] /** * This filter primitive defines the transfer function for the green component * of the input graphic of its parent feComponentTransfer element. * * MDN */ - val feFuncG: TypedTag[Builder, Output, FragT] + def feFuncG: TypedTag[Builder, Output, FragT] /** * This filter primitive defines the transfer function for the red component * of the input graphic of its parent feComponentTransfer element. * * MDN */ - val feFuncR: TypedTag[Builder, Output, FragT] + def feFuncR: TypedTag[Builder, Output, FragT] /** * The filter blurs the input image by the amount specified in stdDeviation, * which defines the bell-curve. * * MDN */ - val feGaussianBlur: TypedTag[Builder, Output, FragT] + def feGaussianBlur: TypedTag[Builder, Output, FragT] /** * The feImage filter fetches image data from an external source and provides @@ -230,7 +230,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val feImage: TypedTag[Builder, Output, FragT] + def feImage: TypedTag[Builder, Output, FragT] /** * The feMerge filter allows filter effects to be applied concurrently @@ -240,7 +240,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val feMerge: TypedTag[Builder, Output, FragT] + def feMerge: TypedTag[Builder, Output, FragT] /** * The feMergeNode takes the result of another filter to be processed by its @@ -248,22 +248,22 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val feMergeNode: TypedTag[Builder, Output, FragT] + def feMergeNode: TypedTag[Builder, Output, FragT] /** * This filter is used to erode or dilate the input image. It's usefulness * lies especially in fattening or thinning effects. * * MDN */ - val feMorphology: TypedTag[Builder, Output, FragT] + def feMorphology: TypedTag[Builder, Output, FragT] /** * The input image as a whole is offset by the values specified in the dx * and dy attributes. It's used in creating drop-shadows. * * MDN */ - val feOffset: TypedTag[Builder, Output, FragT] - val fePointLight: TypedTag[Builder, Output, FragT] + def feOffset: TypedTag[Builder, Output, FragT] + def fePointLight: TypedTag[Builder, Output, FragT] /** * This filter primitive lights a source graphic using the alpha channel as a * bump map. The resulting image is an RGBA image based on the light color. @@ -275,18 +275,18 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val feSpecularLighting: TypedTag[Builder, Output, FragT] + def feSpecularLighting: TypedTag[Builder, Output, FragT] /** * */ - val feSpotlight: TypedTag[Builder, Output, FragT] + def feSpotlight: TypedTag[Builder, Output, FragT] /** * An input image is tiled and the result used to fill a target. The effect * is similar to the one of a pattern. * * MDN */ - val feTile: TypedTag[Builder, Output, FragT] + def feTile: TypedTag[Builder, Output, FragT] /** * This filter primitive creates an image using the Perlin turbulence * function. It allows the synthesis of artificial textures like clouds or @@ -294,7 +294,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val feTurbulance: TypedTag[Builder, Output, FragT] + def feTurbulance: TypedTag[Builder, Output, FragT] /** * The filter element serves as container for atomic filter operations. It is * never rendered directly. A filter is referenced by using the filter @@ -302,34 +302,34 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val filter: TypedTag[Builder, Output, FragT] + def filter: TypedTag[Builder, Output, FragT] /** * The font element defines a font to be used for text layout. * * MDN */ - val font: TypedTag[Builder, Output, FragT] + def font: TypedTag[Builder, Output, FragT] /** * The font-face element corresponds to the CSS @font-face declaration. It * defines a font's outer properties. * * MDN */ - val `font-face`: TypedTag[Builder, Output, FragT] + def `font-face`: TypedTag[Builder, Output, FragT] /** * The font-face-format element describes the type of font referenced by its * parent font-face-uri. * * MDN */ - val `font-face-format`: TypedTag[Builder, Output, FragT] + def `font-face-format`: TypedTag[Builder, Output, FragT] /** * The font-face-name element points to a locally installed copy of this font, * identified by its name. * * MDN */ - val `font-face-name`: TypedTag[Builder, Output, FragT] + def `font-face-name`: TypedTag[Builder, Output, FragT] /** * The font-face-src element corresponds to the src property in CSS @font-face * descriptions. It serves as container for font-face-name, pointing to @@ -338,13 +338,13 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val `font-face-src`: TypedTag[Builder, Output, FragT] + def `font-face-src`: TypedTag[Builder, Output, FragT] /** * The font-face-uri element points to a remote definition of the current font. * * MDN */ - val `font-face-uri`: TypedTag[Builder, Output, FragT] + def `font-face-uri`: TypedTag[Builder, Output, FragT] /** * The foreignObject element allows for inclusion of a foreign XML namespace * which has its graphical content drawn by a different user agent. The @@ -353,7 +353,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val foreignObject: TypedTag[Builder, Output, FragT] + def foreignObject: TypedTag[Builder, Output, FragT] /** * The g element is a container used to group objects. Transformations applied * to the g element are performed on all of its child elements. Attributes @@ -362,48 +362,48 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val g: TypedTag[Builder, Output, FragT] + def g: TypedTag[Builder, Output, FragT] /** * A glyph defines a single glyph in an SVG font. * * MDN */ - val glyph: TypedTag[Builder, Output, FragT] + def glyph: TypedTag[Builder, Output, FragT] /** * The glyphRef element provides a single possible glyph to the referencing * altGlyph substitution. * * MDN */ - val glyphRef: TypedTag[Builder, Output, FragT] + def glyphRef: TypedTag[Builder, Output, FragT] /** * The horizontal distance between two glyphs can be fine-tweaked with an * hkern Element. This process is known as Kerning. * * MDN */ - val hkern: TypedTag[Builder, Output, FragT] + def hkern: TypedTag[Builder, Output, FragT] /** * The SVG Image Element (image) allows a raster image into be included in * an SVG document. * * MDN */ - val image: TypedTag[Builder, Output, FragT] + def image: TypedTag[Builder, Output, FragT] /** * The line element is an SVG basic shape, used to create a line connecting * two points. * * MDN */ - val line: TypedTag[Builder, Output, FragT] + def line: TypedTag[Builder, Output, FragT] /** * linearGradient lets authors define linear gradients to fill or stroke * graphical elements. * * MDN */ - val linearGradient: TypedTag[Builder, Output, FragT] + def linearGradient: TypedTag[Builder, Output, FragT] /** * The marker element defines the graphics that is to be used for drawing * arrowheads or polymarkers on a given path, line, polyline or @@ -411,7 +411,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val marker: TypedTag[Builder, Output, FragT] + def marker: TypedTag[Builder, Output, FragT] /** * In SVG, you can specify that any other graphics object or g element can * be used as an alpha mask for compositing the current object into the @@ -420,7 +420,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val mask: TypedTag[Builder, Output, FragT] + def mask: TypedTag[Builder, Output, FragT] /** * Metadata is structured data about data. Metadata which is included with SVG * content should be specified within metadata elements. The contents of the @@ -429,26 +429,26 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val metadata: TypedTag[Builder, Output, FragT] + def metadata: TypedTag[Builder, Output, FragT] /** * The missing-glyph's content is rendered, if for a given character the font * doesn't define an appropriate glyph. * * MDN */ - val `missing-glyph`: TypedTag[Builder, Output, FragT] + def `missing-glyph`: TypedTag[Builder, Output, FragT] /** * the mpath sub-element for the animateMotion element provides the ability * to reference an external path element as the definition of a motion path. * * MDN */ - val mpath: TypedTag[Builder, Output, FragT] + def mpath: TypedTag[Builder, Output, FragT] /** * The path element is the generic element to define a shape. All the basic * shapes can be created with a path element. */ - val path: TypedTag[Builder, Output, FragT] + def path: TypedTag[Builder, Output, FragT] /** * A pattern is used to fill or stroke an object using a pre-defined graphic * object which can be replicated ("tiled") at fixed intervals in x and y to @@ -459,14 +459,14 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val pattern: TypedTag[Builder, Output, FragT] + def pattern: TypedTag[Builder, Output, FragT] /** * The polygon element defines a closed shape consisting of a set of connected * straight line segments. * * MDN */ - val polygon: TypedTag[Builder, Output, FragT] + def polygon: TypedTag[Builder, Output, FragT] /** * The polyline element is an SVG basic shape, used to create a series of * straight lines connecting several points. Typically a polyline is used to @@ -474,14 +474,14 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val polyline: TypedTag[Builder, Output, FragT] + def polyline: TypedTag[Builder, Output, FragT] /** * radialGradient lets authors define radial gradients to fill or stroke * graphical elements. * * MDN */ - val radialGradient: TypedTag[Builder, Output, FragT] + def radialGradient: TypedTag[Builder, Output, FragT] /** * The rect element is an SVG basic shape, used to create rectangles based on * the position of a corner and their width and height. It may also be used to @@ -489,7 +489,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val rect: TypedTag[Builder, Output, FragT] + def rect: TypedTag[Builder, Output, FragT] /** * The set element provides a simple means of just setting the value of an * attribute for a specified duration. It supports all attribute types, @@ -499,7 +499,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val set: TypedTag[Builder, Output, FragT] + def set: TypedTag[Builder, Output, FragT] /** * The ramp of colors to use on a gradient is defined by the stop elements * that are child elements to either the lineargradient element or the @@ -507,7 +507,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val stop: TypedTag[Builder, Output, FragT] + def stop: TypedTag[Builder, Output, FragT] /** * When it is not the root element, the svg element can be used to nest a * standalone SVG fragment inside the current document (which can be an HTML @@ -516,7 +516,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val svg: TypedTag[Builder, Output, FragT] + def svg: TypedTag[Builder, Output, FragT] /** * The switch element evaluates the requiredFeatures, requiredExtensions and * systemLanguage attributes on its direct child elements in order, and then @@ -527,7 +527,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val switch: TypedTag[Builder, Output, FragT] + def switch: TypedTag[Builder, Output, FragT] /** * The symbol element is used to define graphical template objects which can * be instantiated by a use element. The use of symbol elements for @@ -540,7 +540,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val symbol: TypedTag[Builder, Output, FragT] + def symbol: TypedTag[Builder, Output, FragT] /** * The text element defines a graphics element consisting of text. Note that * it is possible to apply a gradient, pattern, clipping path, mask or filter @@ -548,7 +548,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val text: TypedTag[Builder, Output, FragT] + def text: TypedTag[Builder, Output, FragT] /** * In addition to text drawn in a straight line, SVG also includes the * ability to place text along the shape of a path element. To specify that @@ -558,7 +558,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val textPath: TypedTag[Builder, Output, FragT] + def textPath: TypedTag[Builder, Output, FragT] /** * The textual content for a text can be either character data directly * embedded within the text element or the character data content of a @@ -566,7 +566,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val tref: TypedTag[Builder, Output, FragT] + def tref: TypedTag[Builder, Output, FragT] /** * Within a text element, text and font properties and the current text * position can be adjusted with absolute or relative coordinate values by @@ -574,7 +574,7 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val tspan: TypedTag[Builder, Output, FragT] + def tspan: TypedTag[Builder, Output, FragT] /** * The use element takes nodes from within the SVG document, and duplicates * them somewhere else. The effect is the same as if the nodes were deeply @@ -586,21 +586,21 @@ trait SvgTags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, Fra * * MDN */ - val use: TypedTag[Builder, Output, FragT] + def use: TypedTag[Builder, Output, FragT] /** * A view is a defined way to view the image, like a zoom level or a detail * view. * * MDN */ - val view: TypedTag[Builder, Output, FragT] + def view: TypedTag[Builder, Output, FragT] /** * The vertical distance between two glyphs in top-to-bottom fonts can be * fine-tweaked with an vkern Element. This process is known as Kerning. * * MDN */ - val vkern: TypedTag[Builder, Output, FragT] + def vkern: TypedTag[Builder, Output, FragT] } diff --git a/scalatags/src/scalatags/generic/Tags.scala b/scalatags/src/scalatags/generic/Tags.scala index 88574675..5f2d6df6 100644 --- a/scalatags/src/scalatags/generic/Tags.scala +++ b/scalatags/src/scalatags/generic/Tags.scala @@ -16,7 +16,7 @@ trait Tags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT] * * MDN */ - val html: TypedTag[Builder, Output, FragT] + def html: TypedTag[Builder, Output, FragT] // Document Metadata /** @@ -25,26 +25,26 @@ trait Tags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT] * * MDN */ - val head: TypedTag[Builder, Output, FragT] + def head: TypedTag[Builder, Output, FragT] /** * Defines the base URL for relative URLs in the page. * * MDN */ - val base: TypedTag[Builder, Output, FragT] + def base: TypedTag[Builder, Output, FragT] /** * Used to link JavaScript and external CSS with the current HTML document. * * MDN */ - val link: TypedTag[Builder, Output, FragT] + def link: TypedTag[Builder, Output, FragT] /** * Defines metadata that can't be defined using another HTML element. * * MDN */ - val meta: TypedTag[Builder, Output, FragT] + def meta: TypedTag[Builder, Output, FragT] // Scripting @@ -54,7 +54,7 @@ trait Tags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT] * * MDN */ - val script: TypedTag[Builder, Output, FragT] + def script: TypedTag[Builder, Output, FragT] // Sections @@ -64,58 +64,58 @@ trait Tags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT] * * MDN */ - val body: TypedTag[Builder, Output, FragT] + def body: TypedTag[Builder, Output, FragT] /** * Heading level 1 * * MDN */ - val h1: TypedTag[Builder, Output, FragT] + def h1: TypedTag[Builder, Output, FragT] /** * Heading level 2 * * MDN */ - val h2: TypedTag[Builder, Output, FragT] + def h2: TypedTag[Builder, Output, FragT] /** * Heading level 3 * * MDN */ - val h3: TypedTag[Builder, Output, FragT] + def h3: TypedTag[Builder, Output, FragT] /** * Heading level 4 * * MDN */ - val h4: TypedTag[Builder, Output, FragT] + def h4: TypedTag[Builder, Output, FragT] /** * Heading level 5 * * MDN */ - val h5: TypedTag[Builder, Output, FragT] + def h5: TypedTag[Builder, Output, FragT] /** * Heading level 6 * * MDN */ - val h6: TypedTag[Builder, Output, FragT] + def h6: TypedTag[Builder, Output, FragT] /** * Defines the header of a page or section. It often contains a logo, the * title of the Web site, and a navigational table of content. * * MDN */ - val header: TypedTag[Builder, Output, FragT] + def header: TypedTag[Builder, Output, FragT] /** * Defines the footer for a page or section. It often contains a copyright * notice, some links to legal information, or addresses to give feedback. * * MDN */ - val footer: TypedTag[Builder, Output, FragT] + def footer: TypedTag[Builder, Output, FragT] // Grouping content @@ -124,81 +124,81 @@ trait Tags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT] * * MDN */ - val p: TypedTag[Builder, Output, FragT] + def p: TypedTag[Builder, Output, FragT] /** * Represents a thematic break between paragraphs of a section or article or * any longer content. * * MDN */ - val hr: TypedTag[Builder, Output, FragT] + def hr: TypedTag[Builder, Output, FragT] /** * Indicates that its content is preformatted and that this format must be * preserved. * * MDN */ - val pre: TypedTag[Builder, Output, FragT] + def pre: TypedTag[Builder, Output, FragT] /** * Represents a content that is quoted from another source. * * MDN */ - val blockquote: TypedTag[Builder, Output, FragT] + def blockquote: TypedTag[Builder, Output, FragT] /** * Defines an ordered list of items. * * MDN */ - val ol: TypedTag[Builder, Output, FragT] + def ol: TypedTag[Builder, Output, FragT] /** * Defines an unordered list of items. * * MDN */ - val ul: TypedTag[Builder, Output, FragT] + def ul: TypedTag[Builder, Output, FragT] /** * Defines an item of an list. * * MDN */ - val li: TypedTag[Builder, Output, FragT] + def li: TypedTag[Builder, Output, FragT] /** * Defines a definition list; a list of terms and their associated definitions. * * MDN */ - val dl: TypedTag[Builder, Output, FragT] + def dl: TypedTag[Builder, Output, FragT] /** * Represents a term defined by the next dd * * MDN */ - val dt: TypedTag[Builder, Output, FragT] + def dt: TypedTag[Builder, Output, FragT] /** * Represents the definition of the terms immediately listed before it. * * MDN */ - val dd: TypedTag[Builder, Output, FragT] + def dd: TypedTag[Builder, Output, FragT] /** * Represents a figure illustrated as part of the document. * * MDN */ - val figure: TypedTag[Builder, Output, FragT] + def figure: TypedTag[Builder, Output, FragT] /** * Represents the legend of a figure. * * MDN */ - val figcaption: TypedTag[Builder, Output, FragT] + def figcaption: TypedTag[Builder, Output, FragT] /** * Represents a generic container with no special meaning. * * MDN */ - val div: TypedTag[Builder, Output, FragT] + def div: TypedTag[Builder, Output, FragT] // Text-level semantics /** @@ -206,76 +206,76 @@ trait Tags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT] * * MDN */ - val a: TypedTag[Builder, Output, FragT] + def a: TypedTag[Builder, Output, FragT] /** * Represents emphasized text. * * MDN */ - val em: TypedTag[Builder, Output, FragT] + def em: TypedTag[Builder, Output, FragT] /** * Represents especially important text. * * MDN */ - val strong: TypedTag[Builder, Output, FragT] + def strong: TypedTag[Builder, Output, FragT] /** * Represents a side comment; text like a disclaimer or copyright, which is not * essential to the comprehension of the document. * * MDN */ - val small: TypedTag[Builder, Output, FragT] + def small: TypedTag[Builder, Output, FragT] /** * Strikethrough element, used for that is no longer accurate or relevant. * * MDN */ - val s: TypedTag[Builder, Output, FragT] + def s: TypedTag[Builder, Output, FragT] /** * Represents the title of a work being cited. * * MDN */ - val cite: TypedTag[Builder, Output, FragT] + def cite: TypedTag[Builder, Output, FragT] /** * Represents computer code. * * MDN */ - val code: TypedTag[Builder, Output, FragT] + def code: TypedTag[Builder, Output, FragT] /** * Subscript tag * * MDN */ - val sub: TypedTag[Builder, Output, FragT] + def sub: TypedTag[Builder, Output, FragT] /** * Superscript tag. * * MDN */ - val sup: TypedTag[Builder, Output, FragT] + def sup: TypedTag[Builder, Output, FragT] /** * Italicized text. * * MDN */ - val i: TypedTag[Builder, Output, FragT] + def i: TypedTag[Builder, Output, FragT] /** * Bold text. * * MDN */ - val b: TypedTag[Builder, Output, FragT] + def b: TypedTag[Builder, Output, FragT] /** * Underlined text. * * MDN */ - val u: TypedTag[Builder, Output, FragT] + def u: TypedTag[Builder, Output, FragT] /** * Represents text with no specific meaning. This has to be used when no other @@ -284,20 +284,20 @@ trait Tags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT] * * MDN */ - val span: TypedTag[Builder, Output, FragT] + def span: TypedTag[Builder, Output, FragT] /** * Represents a line break. * * MDN */ - val br: TypedTag[Builder, Output, FragT] + def br: TypedTag[Builder, Output, FragT] /** * Represents a line break opportunity, that is a suggested point for wrapping * text in order to improve readability of text split on several lines. * * MDN */ - val wbr: TypedTag[Builder, Output, FragT] + def wbr: TypedTag[Builder, Output, FragT] // Edits /** @@ -305,13 +305,13 @@ trait Tags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT] * * MDN */ - val ins: TypedTag[Builder, Output, FragT] + def ins: TypedTag[Builder, Output, FragT] /** * Defines a removal from the document. * * MDN */ - val del: TypedTag[Builder, Output, FragT] + def del: TypedTag[Builder, Output, FragT] // Embedded content /** @@ -319,79 +319,79 @@ trait Tags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT] * * MDN */ - val img: TypedTag[Builder, Output, FragT] + def img: TypedTag[Builder, Output, FragT] /** * Represents a nested browsing context, that is an embedded HTML document. * * MDN */ - val iframe: TypedTag[Builder, Output, FragT] + def iframe: TypedTag[Builder, Output, FragT] /** * Represents a integration point for an external, often non-HTML, application * or interactive content. * * MDN */ - val embed: TypedTag[Builder, Output, FragT] + def embed: TypedTag[Builder, Output, FragT] /** * Represents an external resource, which is treated as an image, an HTML * sub-document, or an external resource to be processed by a plug-in. * * MDN */ - val `object`: TypedTag[Builder, Output, FragT] + def `object`: TypedTag[Builder, Output, FragT] /** * Defines parameters for use by plug-ins invoked by object elements. * * MDN */ - val param: TypedTag[Builder, Output, FragT] + def param: TypedTag[Builder, Output, FragT] /** * Represents a video, and its associated audio files and captions, with the * necessary interface to play it. * * MDN */ - val video: TypedTag[Builder, Output, FragT] + def video: TypedTag[Builder, Output, FragT] /** * Represents a sound or an audio stream. * * MDN */ - val audio: TypedTag[Builder, Output, FragT] + def audio: TypedTag[Builder, Output, FragT] /** * Allows the authors to specify alternate media resources for media elements * like video or audio * * MDN */ - val source: TypedTag[Builder, Output, FragT] + def source: TypedTag[Builder, Output, FragT] /** * Allows authors to specify timed text track for media elements like video or * audio * * MDN */ - val track: TypedTag[Builder, Output, FragT] + def track: TypedTag[Builder, Output, FragT] /** * Represents a bitmap area that scripts can use to render graphics like graphs, * games or any visual images on the fly. * * MDN */ - val canvas: TypedTag[Builder, Output, FragT] + def canvas: TypedTag[Builder, Output, FragT] /** * In conjunction with area, defines an image map. * * MDN */ - val map: TypedTag[Builder, Output, FragT] + def map: TypedTag[Builder, Output, FragT] /** * In conjunction with map, defines an image map * * MDN */ - val area: TypedTag[Builder, Output, FragT] + def area: TypedTag[Builder, Output, FragT] // Tabular data @@ -400,61 +400,61 @@ trait Tags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT] * * MDN */ - val table: TypedTag[Builder, Output, FragT] + def table: TypedTag[Builder, Output, FragT] /** * The title of a table. * * MDN */ - val caption: TypedTag[Builder, Output, FragT] + def caption: TypedTag[Builder, Output, FragT] /** * A set of columns. * * MDN */ - val colgroup: TypedTag[Builder, Output, FragT] + def colgroup: TypedTag[Builder, Output, FragT] /** * A single column. * * MDN */ - val col: TypedTag[Builder, Output, FragT] + def col: TypedTag[Builder, Output, FragT] /** * The table body. * * MDN */ - val tbody: TypedTag[Builder, Output, FragT] + def tbody: TypedTag[Builder, Output, FragT] /** * The table headers. * * MDN */ - val thead: TypedTag[Builder, Output, FragT] + def thead: TypedTag[Builder, Output, FragT] /** * The table footer. * * MDN */ - val tfoot: TypedTag[Builder, Output, FragT] + def tfoot: TypedTag[Builder, Output, FragT] /** * A single row in a table. * * MDN */ - val tr: TypedTag[Builder, Output, FragT] + def tr: TypedTag[Builder, Output, FragT] /** * A single cell in a table. * * MDN */ - val td: TypedTag[Builder, Output, FragT] + def td: TypedTag[Builder, Output, FragT] /** * A header cell in a table. * * MDN */ - val th: TypedTag[Builder, Output, FragT] + def th: TypedTag[Builder, Output, FragT] // Forms /** @@ -463,65 +463,65 @@ trait Tags[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT] * * MDN */ - val form: TypedTag[Builder, Output, FragT] + def form: TypedTag[Builder, Output, FragT] /** * A set of fields. * * MDN */ - val fieldset: TypedTag[Builder, Output, FragT] + def fieldset: TypedTag[Builder, Output, FragT] /** * The caption for a fieldset. * * MDN */ - val legend: TypedTag[Builder, Output, FragT] + def legend: TypedTag[Builder, Output, FragT] /** * The caption of a single field * * MDN */ - val label: TypedTag[Builder, Output, FragT] + def label: TypedTag[Builder, Output, FragT] /** * A typed data field allowing the user to input data. * * MDN */ - val input: TypedTag[Builder, Output, FragT] + def input: TypedTag[Builder, Output, FragT] /** * A button * * MDN */ - val button: TypedTag[Builder, Output, FragT] + def button: TypedTag[Builder, Output, FragT] /** * A control that allows the user to select one of a set of options. * * MDN */ - val select: TypedTag[Builder, Output, FragT] + def select: TypedTag[Builder, Output, FragT] /** * A set of predefined options for other controls. * * MDN */ - val datalist: TypedTag[Builder, Output, FragT] + def datalist: TypedTag[Builder, Output, FragT] /** * A set of options, logically grouped. * * MDN */ - val optgroup: TypedTag[Builder, Output, FragT] + def optgroup: TypedTag[Builder, Output, FragT] /** * An option in a select element. * * MDN */ - val option: TypedTag[Builder, Output, FragT] + def option: TypedTag[Builder, Output, FragT] /** * A multiline text edit control. * * MDN */ - val textarea: TypedTag[Builder, Output, FragT] + def textarea: TypedTag[Builder, Output, FragT] } diff --git a/scalatags/src/scalatags/generic/Tags2.scala b/scalatags/src/scalatags/generic/Tags2.scala index ce1f096e..508702fb 100644 --- a/scalatags/src/scalatags/generic/Tags2.scala +++ b/scalatags/src/scalatags/generic/Tags2.scala @@ -15,14 +15,14 @@ trait Tags2[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT * * MDN */ - val title: TypedTag[Builder, Output, FragT] + def title: TypedTag[Builder, Output, FragT] /** * Used to write inline CSS. * * MDN */ - val style: TypedTag[Builder, Output, FragT] + def style: TypedTag[Builder, Output, FragT] // Scripting /** * Defines alternative content to display when the browser doesn't support @@ -30,7 +30,7 @@ trait Tags2[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT * * MDN */ - val noscript: TypedTag[Builder, Output, FragT] + def noscript: TypedTag[Builder, Output, FragT] // Sections /** @@ -39,34 +39,34 @@ trait Tags2[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT * * MDN */ - val section: TypedTag[Builder, Output, FragT] + def section: TypedTag[Builder, Output, FragT] /** * Represents a section of a page that links to other pages or to parts within * the page: a section with navigation links. * * MDN */ - val nav: TypedTag[Builder, Output, FragT] + def nav: TypedTag[Builder, Output, FragT] /** * Defines self-contained content that could exist independently of the rest * of the content. * * MDN */ - val article: TypedTag[Builder, Output, FragT] + def article: TypedTag[Builder, Output, FragT] /** * Defines some content loosely related to the page content. If it is removed, * the remaining content still makes sense. * * MDN */ - val aside: TypedTag[Builder, Output, FragT] + def aside: TypedTag[Builder, Output, FragT] /** * Defines a section containing contact information. * * MDN */ - val address: TypedTag[Builder, Output, FragT] + def address: TypedTag[Builder, Output, FragT] /** * Defines the main or important content in the document. There is only one @@ -74,7 +74,7 @@ trait Tags2[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT * * MDN */ - val main: TypedTag[Builder, Output, FragT] + def main: TypedTag[Builder, Output, FragT] // Text level semantics @@ -83,66 +83,66 @@ trait Tags2[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT * * MDN */ - val q: TypedTag[Builder, Output, FragT] + def q: TypedTag[Builder, Output, FragT] /** * Represents a term whose definition is contained in its nearest ancestor * content. * * MDN */ - val dfn: TypedTag[Builder, Output, FragT] + def dfn: TypedTag[Builder, Output, FragT] /** * An abbreviation or acronym; the expansion of the abbreviation can be * represented in the title attribute. * * MDN */ - val abbr: TypedTag[Builder, Output, FragT] + def abbr: TypedTag[Builder, Output, FragT] /** * Associates to its content a machine-readable equivalent. * * MDN */ - val data: TypedTag[Builder, Output, FragT] + def data: TypedTag[Builder, Output, FragT] /** * Represents a date and time value; the machine-readable equivalent can be * represented in the datetime attribetu * * MDN */ - val time: TypedTag[Builder, Output, FragT] + def time: TypedTag[Builder, Output, FragT] /** * Represents a variable. * * MDN */ - val `var`: TypedTag[Builder, Output, FragT] + def `var`: TypedTag[Builder, Output, FragT] /** * Represents the output of a program or a computer. * * MDN */ - val samp: TypedTag[Builder, Output, FragT] + def samp: TypedTag[Builder, Output, FragT] /** * Represents user input, often from a keyboard, but not necessarily. * * MDN */ - val kbd: TypedTag[Builder, Output, FragT] + def kbd: TypedTag[Builder, Output, FragT] /** * Defines a mathematical formula. * * MDN */ - val math: TypedTag[Builder, Output, FragT] + def math: TypedTag[Builder, Output, FragT] /** * Represents text highlighted for reference purposes, that is for its * relevance in another context. * * MDN */ - val mark: TypedTag[Builder, Output, FragT] + def mark: TypedTag[Builder, Output, FragT] /** * Represents content to be marked with ruby annotations, short runs of text * presented alongside the text. This is often used in conjunction with East @@ -151,13 +151,13 @@ trait Tags2[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT * * MDN */ - val ruby: TypedTag[Builder, Output, FragT] + def ruby: TypedTag[Builder, Output, FragT] /** * Represents the text of a ruby annotation. * * MDN */ - val rt: TypedTag[Builder, Output, FragT] + def rt: TypedTag[Builder, Output, FragT] /** * Represents parenthesis around a ruby annotation, used to display the * annotation in an alternate way by browsers not supporting the standard @@ -165,7 +165,7 @@ trait Tags2[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT * * MDN */ - val rp: TypedTag[Builder, Output, FragT] + def rp: TypedTag[Builder, Output, FragT] /** * Represents text that must be isolated from its surrounding for bidirectional * text formatting. It allows embedding a span of text with a different, or @@ -173,14 +173,14 @@ trait Tags2[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT * * MDN */ - val bdi: TypedTag[Builder, Output, FragT] + def bdi: TypedTag[Builder, Output, FragT] /** * Represents the directionality of its children, in order to explicitly * override the Unicode bidirectional algorithm. * * MDN */ - val bdo: TypedTag[Builder, Output, FragT] + def bdo: TypedTag[Builder, Output, FragT] // Forms @@ -189,25 +189,25 @@ trait Tags2[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT * * MDN */ - val keygen: TypedTag[Builder, Output, FragT] + def keygen: TypedTag[Builder, Output, FragT] /** * The result of a calculation * * MDN */ - val output: TypedTag[Builder, Output, FragT] + def output: TypedTag[Builder, Output, FragT] /** * A progress completion bar * * MDN */ - val progress: TypedTag[Builder, Output, FragT] + def progress: TypedTag[Builder, Output, FragT] /** * A scalar measurement within a known range. * * MDN */ - val meter: TypedTag[Builder, Output, FragT] + def meter: TypedTag[Builder, Output, FragT] // Interactive elements @@ -217,23 +217,23 @@ trait Tags2[Builder, Output <: FragT, FragT] extends Util[Builder, Output, FragT * * MDN */ - val details: TypedTag[Builder, Output, FragT] + def details: TypedTag[Builder, Output, FragT] /** * A summary, caption, or legend for a given details. * * MDN */ - val summary: TypedTag[Builder, Output, FragT] + def summary: TypedTag[Builder, Output, FragT] /** * A command that the user can invoke. * * MDN */ - val command: TypedTag[Builder, Output, FragT] + def command: TypedTag[Builder, Output, FragT] /** * A list of commands * * MDN */ - val menu: TypedTag[Builder, Output, FragT] + def menu: TypedTag[Builder, Output, FragT] } diff --git a/scalatags/src/scalatags/generic/Util.scala b/scalatags/src/scalatags/generic/Util.scala index 0f4eb428..0307ad0b 100644 --- a/scalatags/src/scalatags/generic/Util.scala +++ b/scalatags/src/scalatags/generic/Util.scala @@ -3,6 +3,7 @@ package generic import java.util.Objects import scala.language.higherKinds +import scala.language.implicitConversions /** * Created by haoyi on 6/2/14. @@ -68,20 +69,20 @@ trait Util[Builder, Output <: FragT, FragT] extends LowPriUtil[Builder, Output, */ implicit class SeqNode[A](xs: Seq[A])(implicit ev: A => Modifier[Builder]) extends Modifier[Builder]{ Objects.requireNonNull(xs) - def applyTo(t: Builder) = xs.foreach(_.applyTo(t)) + def applyTo(t: Builder) = xs.foreach(elem => ev(elem).applyTo(t)) } /** * Allows you to modify a [[ConcreteHtmlTag]] by adding an Option containing other nest-able * objects to its list of children. */ - implicit def OptionNode[A](xs: Option[A])(implicit ev: A => Modifier[Builder]) = new SeqNode(xs.toSeq) + implicit def OptionNode[A](xs: Option[A])(implicit ev: A => Modifier[Builder]): SeqNode[A] = new SeqNode(xs.toSeq) /** * Allows you to modify a [[ConcreteHtmlTag]] by adding an Array containing other nest-able * objects to its list of children. */ - implicit def ArrayNode[A](xs: Array[A])(implicit ev: A => Modifier[Builder]) = new SeqNode[A](xs.toSeq) + implicit def ArrayNode[A](xs: Array[A])(implicit ev: A => Modifier[Builder]): SeqNode[A] = new SeqNode[A](xs.toSeq) } @@ -99,12 +100,12 @@ trait LowPriUtil[Builder, Output <: FragT, FragT]{ /** * Renders an Option of [[FragT]] into a single [[FragT]] */ - implicit def OptionFrag[A](xs: Option[A])(implicit ev: A => Frag[Builder, FragT]) = SeqFrag(xs.toSeq) + implicit def OptionFrag[A](xs: Option[A])(implicit ev: A => Frag[Builder, FragT]): Frag[Builder, FragT] = SeqFrag(xs.toSeq) /** * Renders an Seq of [[FragT]] into a single [[FragT]] */ - implicit def ArrayFrag[A](xs: Array[A])(implicit ev: A => Frag[Builder, FragT]) = SeqFrag[A](xs.toSeq) + implicit def ArrayFrag[A](xs: Array[A])(implicit ev: A => Frag[Builder, FragT]): Frag[Builder, FragT] = SeqFrag[A](xs.toSeq) /** * Lets you put Unit into a scalatags tree, as a no-op. diff --git a/scalatags/src/scalatags/package.scala b/scalatags/src/scalatags/package.scala index 74200324..2d321e3b 100644 --- a/scalatags/src/scalatags/package.scala +++ b/scalatags/src/scalatags/package.scala @@ -23,9 +23,4 @@ package object scalatags { override def compare(x: Attr, y: Attr): Int = x.name compareTo y.name } - trait Companion[V] extends (String => V){ - def apply(target: String): V - def unapply(target: V): Option[String] - } - } diff --git a/scalatags/src/scalatags/stylesheet/StyleSheet.scala b/scalatags/src/scalatags/stylesheet/StyleSheet.scala index 6ab8b3b5..342c05e0 100644 --- a/scalatags/src/scalatags/stylesheet/StyleSheet.scala +++ b/scalatags/src/scalatags/stylesheet/StyleSheet.scala @@ -1,8 +1,7 @@ package scalatags.stylesheet -import scala.language.experimental.macros -import scala.collection.immutable.SortedMap -import scala.reflect.macros.Context +import scala.collection.immutable.SortedMap +import scala.language.implicitConversions /** * A [[StyleSheet]] which lets you define cascading tag/class @@ -86,39 +85,13 @@ abstract class StyleSheet(implicit sourceName: sourcecode.FullName){ def styleSheetText = allClasses.map(_.structure.stringify(Nil)).mkString("\n") } -class SourceClasses[T](val value: T => Seq[Cls]) -object SourceClasses{ - implicit def apply[T]: SourceClasses[T] = macro manglerImpl[T] - def manglerImpl[T: c.WeakTypeTag](c: Context) = { - import c.universe._ - - val weakType = weakTypeOf[T] - - val stylesheetName = newTermName("stylesheet") - val names = for { - member <- weakType.members.toSeq.reverse - // Not sure if there's a better way to capture by-name types - if member.typeSignature.toString == "=> scalatags.stylesheet.Cls" || - member.typeSignature.toString == "scalatags.stylesheet.Cls" - if member.isPublic - } yield q"$stylesheetName.${member.name.toTermName}" - - val res = q""" - new scalatags.stylesheet.SourceClasses[$weakType]( - ($stylesheetName: $weakType) => Seq[scalatags.stylesheet.Cls](..$names) - ) - """ - - c.Expr[SourceClasses[T]](res) - } -} /** * A rendered class; both the class `name` (used when injected into Scalatags * fragments) and the `structure` (used when injected into further class definitions) */ case class Cls(name: String, pseudoSelectors: Seq[String], args: Seq[StyleSheetFrag]){ - lazy val structure = args.foldLeft(StyleTree(Seq("." + name + pseudoSelectors.map(':'+_).mkString), SortedMap.empty, Nil))( + lazy val structure = args.foldLeft(StyleTree(Seq(s".$name${pseudoSelectors.map(s => s":$s").mkString}"), SortedMap.empty, Nil))( (c, f) => f.applyTo(c) ) def splice = new StyleSheetFrag{ diff --git a/scalatags/src/scalatags/vdom/SvgTags.scala b/scalatags/src/scalatags/vdom/SvgTags.scala index bec0e694..c3d723a5 100644 --- a/scalatags/src/scalatags/vdom/SvgTags.scala +++ b/scalatags/src/scalatags/vdom/SvgTags.scala @@ -5,7 +5,7 @@ import scalatags.generic.{Namespace, Util} trait SvgTags[Output <: FragT, FragT] extends generic.SvgTags[Builder[Output, FragT], Output, FragT] with TagFactory[Output, FragT]{ - implicit lazy val svgNamespaceConfig = Namespace.svgNamespaceConfig + implicit lazy val svgNamespaceConfig: Namespace = Namespace.svgNamespaceConfig lazy val altGlyph = tag("altGlyph") lazy val altGlyphDef = tag("altGlyphDef") lazy val altGlyphItem = tag("altGlyphItem") diff --git a/scalatags/test/src/scalatags/generic/BasicTests.scala b/scalatags/test/src/scalatags/generic/BasicTests.scala index 574ee7a9..bfe61b26 100644 --- a/scalatags/test/src/scalatags/generic/BasicTests.scala +++ b/scalatags/test/src/scalatags/generic/BasicTests.scala @@ -140,21 +140,22 @@ class BasicTests[Builder, Output <: FragT, FragT](omg: Bundle[Builder, Output, F ) } test("compileErrors"){ + def writeType(tpe: String) = if(BuildInfo.scalaMajorVersion == "3") s"($tpe)" else tpe test("niceErrorsForAttributes"){ val msg = compileError("""a(onclick := {() => "lol"})""").msg - assert(msg.contains("scalatags does not know how to use () => String as an attribute")) + assert(msg.contains(s"scalatags does not know how to use ${writeType("() => String")} as an attribute")) } test("niceErrorsForStyles"){ val msg = compileError("""a(opacity:= {() => "lol"})""").msg - assert(msg.contains("scalatags does not know how to use () => String as an style")) + assert(msg.contains(s"scalatags does not know how to use ${writeType("() => String")} as an style")) } } test("nulls"){ val nullString: String = null - * - intercept[NullPointerException](div(nullString)) - * - intercept[NullPointerException](div(null: Seq[Int])) - * - intercept[NullPointerException](div(height := nullString)) - * - intercept[NullPointerException](div(opacity := nullString)) + test("1") { intercept[NullPointerException](div(nullString)) } + test("2") { intercept[NullPointerException](div(null: Seq[Int])) } + test("3") { intercept[NullPointerException](div(height := nullString)) } + test("4") { intercept[NullPointerException](div(opacity := nullString)) } } test("rawAttrs"){ strCheck( diff --git a/scalatags/test/src/scalatags/text/BundlingTests.scala b/scalatags/test/src/scalatags/text/BundlingTests.scala index 74dada49..f53e03a4 100644 --- a/scalatags/test/src/scalatags/text/BundlingTests.scala +++ b/scalatags/test/src/scalatags/text/BundlingTests.scala @@ -2,6 +2,10 @@ package scalatags package text import utest._ object BundlingTests extends TestSuite{ + object CustomBundle extends Text.Cap with text.Tags with text.Tags2 with Text.Aggregate{ + object st extends Text.Cap with Text.Styles with Text.Styles2 + object at extends Text.Cap with Text.Attrs + } val tests = TestSuite{ val expected = """ @@ -19,10 +23,6 @@ object BundlingTests extends TestSuite{ """ - object CustomBundle extends Text.Cap with text.Tags with text.Tags2 with Text.Aggregate{ - object st extends Text.Cap with Text.Styles with Text.Styles2 - object at extends Text.Cap with Text.Attrs - } test("custom"){ import CustomBundle._ TestUtil.strCheck(