From 20d71f0235d1f59b50bbe17504d267c2c6f572ad Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 24 Oct 2021 05:07:31 +0000 Subject: [PATCH 1/4] Update to scala-js-dom 2.0.0 --- build.sbt | 4 ++-- mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala | 2 +- tests/unit-js/src/test/scala/tests/js/JsSuite.scala | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index 521afb266..0f3b621c3 100644 --- a/build.sbt +++ b/build.sbt @@ -9,7 +9,7 @@ def allScalaVersions = scala2Versions :+ scala3 def scalajs = "1.7.1" def scalajsBinaryVersion = "1" -def scalajsDom = "1.1.0" +def scalajsDom = "2.0.0" def isScala2(v: Option[(Long, Long)]): Boolean = v.exists(_._1 == 2) def isScala212(v: Option[(Long, Long)]): Boolean = v.exists(_._1 == 2) && v.exists(_._2 == 12) @@ -278,7 +278,7 @@ val jsdocs = project _.withModuleKind(ModuleKind.CommonJSModule) }, libraryDependencies ++= List( - "org.scala-js" %%% "scalajs-dom" % scalajsDom cross CrossVersion.for3Use2_13 + "org.scala-js" %%% "scalajs-dom" % scalajsDom ), scalaJSUseMainModuleInitializer := true, Compile / npmDependencies ++= List( diff --git a/mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala b/mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala index 982fad3f3..7ecf2dfaf 100644 --- a/mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala +++ b/mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala @@ -252,7 +252,7 @@ class JsModifier extends mdoc.PreModifier { new CodeBuilder() .println(s"""@_root_.scala.scalajs.js.annotation.JSExportTopLevel("$jsId") """) .println( - s"""def $run($mountNodeParam: _root_.org.scalajs.dom.raw.HTMLElement): Unit = {""" + s"""def $run($mountNodeParam: _root_.org.scalajs.dom.HTMLElement): Unit = {""" ) .println(input.text) .println("}") diff --git a/tests/unit-js/src/test/scala/tests/js/JsSuite.scala b/tests/unit-js/src/test/scala/tests/js/JsSuite.scala index eae3a5c8d..817fd8377 100644 --- a/tests/unit-js/src/test/scala/tests/js/JsSuite.scala +++ b/tests/unit-js/src/test/scala/tests/js/JsSuite.scala @@ -269,7 +269,7 @@ class JsSuite extends BaseMarkdownSuite { "onclick", """ |```scala mdoc:js - |import org.scalajs.dom.raw.MouseEvent + |import org.scalajs.dom.MouseEvent |node.onclick = {(_: MouseEvent) => println(42)} |``` """.stripMargin @@ -283,7 +283,7 @@ class JsSuite extends BaseMarkdownSuite { |``` """.stripMargin, """|error: no-dom.md:4 (mdoc generated code) object scalajs is not a member of package org - |def run0(node: _root_.org.scalajs.dom.raw.HTMLElement): Unit = { + |def run0(node: _root_.org.scalajs.dom.HTMLElement): Unit = { | ^ """.stripMargin, settings = { @@ -299,7 +299,7 @@ class JsSuite extends BaseMarkdownSuite { |error: |no-dom.md:3 (mdoc generated code) | value scalajs is not a member of org - |def run0(node: _root_.org.scalajs.dom.raw.HTMLElement): Unit = { + |def run0(node: _root_.org.scalajs.dom.HTMLElement): Unit = { """.stripMargin ) ) From ffac43e9cac6aba3f94f728247b82c163fd83e61 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 24 Oct 2021 05:14:40 +0000 Subject: [PATCH 2/4] Bump sjs-dom version somewhere else --- mdoc-sbt/src/sbt-test/sbt-mdoc/basic/build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mdoc-sbt/src/sbt-test/sbt-mdoc/basic/build.sbt b/mdoc-sbt/src/sbt-test/sbt-mdoc/basic/build.sbt index d5627b569..9b4e8eafe 100644 --- a/mdoc-sbt/src/sbt-test/sbt-mdoc/basic/build.sbt +++ b/mdoc-sbt/src/sbt-test/sbt-mdoc/basic/build.sbt @@ -28,6 +28,6 @@ println("Hello Scala.js!") lazy val jsapp = project .settings( - libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "1.1.0" + libraryDependencies += "org.scala-js" %%% "scalajs-dom" % "2.0.0" ) .enablePlugins(ScalaJSPlugin) From 0413839b45f23997f92918b9a8b8a12cc76c2316 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 24 Oct 2021 06:18:21 +0000 Subject: [PATCH 3/4] Revert to sjs-dom v1 compatible imports --- mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala | 2 +- tests/unit-js/src/test/scala/tests/js/JsSuite.scala | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala b/mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala index 7ecf2dfaf..982fad3f3 100644 --- a/mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala +++ b/mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala @@ -252,7 +252,7 @@ class JsModifier extends mdoc.PreModifier { new CodeBuilder() .println(s"""@_root_.scala.scalajs.js.annotation.JSExportTopLevel("$jsId") """) .println( - s"""def $run($mountNodeParam: _root_.org.scalajs.dom.HTMLElement): Unit = {""" + s"""def $run($mountNodeParam: _root_.org.scalajs.dom.raw.HTMLElement): Unit = {""" ) .println(input.text) .println("}") diff --git a/tests/unit-js/src/test/scala/tests/js/JsSuite.scala b/tests/unit-js/src/test/scala/tests/js/JsSuite.scala index 817fd8377..eae3a5c8d 100644 --- a/tests/unit-js/src/test/scala/tests/js/JsSuite.scala +++ b/tests/unit-js/src/test/scala/tests/js/JsSuite.scala @@ -269,7 +269,7 @@ class JsSuite extends BaseMarkdownSuite { "onclick", """ |```scala mdoc:js - |import org.scalajs.dom.MouseEvent + |import org.scalajs.dom.raw.MouseEvent |node.onclick = {(_: MouseEvent) => println(42)} |``` """.stripMargin @@ -283,7 +283,7 @@ class JsSuite extends BaseMarkdownSuite { |``` """.stripMargin, """|error: no-dom.md:4 (mdoc generated code) object scalajs is not a member of package org - |def run0(node: _root_.org.scalajs.dom.HTMLElement): Unit = { + |def run0(node: _root_.org.scalajs.dom.raw.HTMLElement): Unit = { | ^ """.stripMargin, settings = { @@ -299,7 +299,7 @@ class JsSuite extends BaseMarkdownSuite { |error: |no-dom.md:3 (mdoc generated code) | value scalajs is not a member of org - |def run0(node: _root_.org.scalajs.dom.HTMLElement): Unit = { + |def run0(node: _root_.org.scalajs.dom.raw.HTMLElement): Unit = { """.stripMargin ) ) From 70b11a93a6963414844af57b24c80f7aec05ce42 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 24 Oct 2021 17:05:38 +0000 Subject: [PATCH 4/4] Find a common, non-deprecated set of FQCNs --- mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala | 2 +- tests/unit-js/src/test/scala/tests/js/JsSuite.scala | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala b/mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala index 982fad3f3..f96893305 100644 --- a/mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala +++ b/mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala @@ -252,7 +252,7 @@ class JsModifier extends mdoc.PreModifier { new CodeBuilder() .println(s"""@_root_.scala.scalajs.js.annotation.JSExportTopLevel("$jsId") """) .println( - s"""def $run($mountNodeParam: _root_.org.scalajs.dom.raw.HTMLElement): Unit = {""" + s"""def $run($mountNodeParam: _root_.org.scalajs.dom.html.Element): Unit = {""" ) .println(input.text) .println("}") diff --git a/tests/unit-js/src/test/scala/tests/js/JsSuite.scala b/tests/unit-js/src/test/scala/tests/js/JsSuite.scala index eae3a5c8d..a4459f644 100644 --- a/tests/unit-js/src/test/scala/tests/js/JsSuite.scala +++ b/tests/unit-js/src/test/scala/tests/js/JsSuite.scala @@ -269,7 +269,7 @@ class JsSuite extends BaseMarkdownSuite { "onclick", """ |```scala mdoc:js - |import org.scalajs.dom.raw.MouseEvent + |import org.scalajs.dom.MouseEvent |node.onclick = {(_: MouseEvent) => println(42)} |``` """.stripMargin @@ -283,7 +283,7 @@ class JsSuite extends BaseMarkdownSuite { |``` """.stripMargin, """|error: no-dom.md:4 (mdoc generated code) object scalajs is not a member of package org - |def run0(node: _root_.org.scalajs.dom.raw.HTMLElement): Unit = { + |def run0(node: _root_.org.scalajs.dom.html.Element): Unit = { | ^ """.stripMargin, settings = { @@ -299,7 +299,7 @@ class JsSuite extends BaseMarkdownSuite { |error: |no-dom.md:3 (mdoc generated code) | value scalajs is not a member of org - |def run0(node: _root_.org.scalajs.dom.raw.HTMLElement): Unit = { + |def run0(node: _root_.org.scalajs.dom.html.Element): Unit = { """.stripMargin ) )