Skip to content

Commit

Permalink
Ensures children are correctly handled when not varargs
Browse files Browse the repository at this point in the history
  • Loading branch information
harana-bot committed Aug 10, 2024
1 parent 68b3cb8 commit b6afeb1
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sbt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
scalajs: ["1.9.0"]
scalajs: ["1.16.0"]
es2015_enabled: ["false", "true"]
steps:
- name: Configure git to disable Windows line feeds
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<a href="https://www.scala-js.org">
<img src="https://www.scala-js.org/assets/badges/scalajs-0.6.17.svg"/>
</a>
<a href="https://maven-central-latest.netlify.com/.netlify/functions/latest-link?org=me.shadaj&name=slinky-core_sjs1_2.13&format=libraryDependencies%20%2B%3D%20%22me.shadaj%22%20%25%25%25%20%22slinky-core%22%20%25%20%22VERSION%22">
<img src="https://maven-central-latest.netlify.com/.netlify/functions/latest-link?org=me.shadaj&name=slinky-core_sjs1_2.13&formatRedirect=https%3A%2F%2Fimg.shields.io%2Fbadge%2Fmaven--central-VERSIONDOUBLEDASHED-orange.svg"/>
<a href="https://mvnrepository.com/artifact/me.shadaj/slinky-core">
<img src="https://img.shields.io/maven-central/v/me.shadaj/slinky-core_sjs1_2.13"/>
</a>
<a href="https://gitter.im/shadaj/slinky?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge">
<img src="https://badges.gitter.im/shadaj/slinky.svg"/>
Expand Down
9 changes: 5 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ addCommandAlias(
"compile:scalafix --check; test:scalafix --check; compile:scalafmtCheck; test:scalafmtCheck; scalafmtSbtCheck"
)

val scala212 = "2.12.17"
val scala213 = "2.13.10"
val scala3 = "3.2.2"
val scala212 = "2.12.19"
val scala213 = "2.13.14"
val scala3 = "3.3.3"

ThisBuild / scalaVersion := scala213
ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := "4.7.6"
ThisBuild / semanticdbVersion := "4.9.9"

ThisBuild / tpolecatDefaultOptionsMode := DevMode

Expand Down Expand Up @@ -46,6 +46,7 @@ addCommandAlias(

lazy val crossScalaSettings = Seq(
crossScalaVersions := Seq(scala212, scala213, scala3),
scalacOptions += "-Wconf:cat=unused-nowarn:s",
Compile / unmanagedSourceDirectories ++= {
val sourceDir = (Compile / sourceDirectory).value
CrossVersion.partialVersion(scalaVersion.value) match {
Expand Down
14 changes: 13 additions & 1 deletion core/src/main/scala-2/slinky/core/annotations/react.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,19 @@ object ReactMacrosImpl {
q"this.apply(Props.apply[..$tparams](...$applyValues))"
}

q"""def apply[..$tparams](...$paramssWithoutChildren)(${childrenParam.get}): _root_.slinky.core.KeyAndRefAddingStage[Def] =
val children = {
val tpe = childrenParam.get.tpe
if (tpe != null && (tpe =:= typeOf[Seq[_root_.slinky.core.facade.ReactElement]] ||
tpe =:= typeOf[List[_root_.slinky.core.facade.ReactElement]] ||
(tpe.typeSymbol == definitions.RepeatedParamClass &&
tpe.typeArgs.headOption.exists(_ =:= typeOf[_root_.slinky.core.facade.ReactElement])))) {
q"${childrenParam.get.name}: _root_.slinky.core.facade.ReactElement"
} else {
q"${childrenParam.get}"
}
}

q"""def apply[..$tparams](...$paramssWithoutChildren)($children): _root_.slinky.core.KeyAndRefAddingStage[Def] =
$body"""
} else {
q"""def apply[..$tparams](...$paramssWithoutChildren): _root_.slinky.core.KeyAndRefAddingStage[Def] =
Expand Down
Loading

0 comments on commit b6afeb1

Please sign in to comment.