diff --git a/src/main/scala/com/raquo/laminar/api/Laminar.scala b/src/main/scala/com/raquo/laminar/api/Laminar.scala index 898bd94e..c25a14cb 100644 --- a/src/main/scala/com/raquo/laminar/api/Laminar.scala +++ b/src/main/scala/com/raquo/laminar/api/Laminar.scala @@ -123,6 +123,18 @@ trait Laminar new DetachedRoot(rootNode, activateNow) } + /** + * Get a Seq of modifiers. You could just use Seq(...), but this helper + * has better type inference in some cases. + */ + def modSeq[El <: Element](mods: Modifier[El]*): Seq[Modifier[El]] = mods + + /** + * Get a Seq of nodes. You could just use Seq(...), but this helper + * has better type inference in some cases. + */ + def nodeSeq[El <: Node](nodes: Node*): Seq[Node] = nodes + /** A universal Modifier that does nothing */ val emptyMod: Modifier.Base = Modifier.empty diff --git a/src/test/scala/com/raquo/laminar/basic/ModSpec.scala b/src/test/scala/com/raquo/laminar/basic/ModSpec.scala index 8cedda4f..a412374f 100644 --- a/src/test/scala/com/raquo/laminar/basic/ModSpec.scala +++ b/src/test/scala/com/raquo/laminar/basic/ModSpec.scala @@ -46,4 +46,37 @@ class ModSpec extends UnitSpec { )) } + it("nodeSeq type inference") { + + val nodes = nodeSeq("text", span("element")) + + val el = div( + nodes + ) + + mount(el) + + expectNode( + div.of("text", span.of("element")) + ) + } + + it("modSeq type inference") { + + val mods = modSeq(title("world"), "text", span("element")) + + val el = div( + "hello", + mods + ) + + mount(el) + + expectNode( + div.of("hello", title is "world", "text", span.of("element")) + ) + } + + + }