Skip to content

Upgrade scalajs-dom to 2.0.0-RC1 #995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:

- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10

1 change: 1 addition & 0 deletions bin/ci
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ cmd=(
++$SCALA_VER
'set ThisBuild / parallelExecution := false'
'set Global / concurrentRestrictions += Tags.limit(ScalaJSTags.Link, 1)'
clean
test # Test development-mode
'set ThisBuild / scalaJSStage := FullOptStage' test # Test production-mode
publishLocal # For downstream tests
Expand Down
11 changes: 6 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
ThisBuild / organization := "com.github.japgolly.scalajs-react"
ThisBuild / homepage := Some(url("https://github.com/japgolly/scalajs-react"))
ThisBuild / licenses := ("Apache-2.0", url("http://opensource.org/licenses/Apache-2.0")) :: Nil
ThisBuild / shellPrompt := ((s: State) => Project.extract(s).currentRef.project + "> ")
sonatypeProfileName := "com.github.japgolly"
ThisBuild / organization := "com.github.japgolly.scalajs-react"
ThisBuild / homepage := Some(url("https://github.com/japgolly/scalajs-react"))
ThisBuild / licenses := ("Apache-2.0", url("http://opensource.org/licenses/Apache-2.0")) :: Nil
ThisBuild / shellPrompt := ((s: State) => Project.extract(s).currentRef.project + "> ")
ThisBuild / versionScheme := Some("early-semver")
sonatypeProfileName := "com.github.japgolly"

val callback = ScalaJsReact.callback
val callbackExtCats = ScalaJsReact.callbackExtCats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import japgolly.scalajs.react.util.Effect.Sync
import japgolly.scalajs.react.util.JsUtil
import japgolly.scalajs.react.util.Util.{catchAll, identityFn}
import java.time.{Duration, Instant}
import org.scalajs.dom.raw.Window
import org.scalajs.dom.window
import org.scalajs.dom.{Window, window}
import scala.annotation.tailrec
import scala.collection.BuildFrom
import scala.concurrent.duration.{FiniteDuration, MILLISECONDS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import japgolly.scalajs.react.util.Effect.Sync
import japgolly.scalajs.react.util.JsUtil
import japgolly.scalajs.react.util.Util.{catchAll, identityFn}
import java.time.{Duration, Instant}
import org.scalajs.dom.raw.Window
import org.scalajs.dom.Window
import org.scalajs.dom.window
import scala.annotation.tailrec
import scala.collection.BuildFrom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object ComponentDom {
}

/** unsafe! may throw an exception */
final def domCast[N <: dom.raw.Node]: N =
final def domCast[N <: dom.Node]: N =
asElement().domCast[N]

/** unsafe! may throw an exception */
Expand Down
3 changes: 3 additions & 0 deletions doc/changelog/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ Contents:

# Changes: Backwards-Incompatible

* scalajs-dom has been bumped to v2.0.0. This is backwards-incompatible with v1.x.y.

* If you used to just add the `extra` module to your sbt's `libraryDependencies` and
rely on `core` being included as a transitive dependency, it will no longer work.
Explicitly add the `core` to your `libraryDependencies`.
Expand Down Expand Up @@ -360,6 +362,7 @@ You can run the script in the Migration section at the bottom of the page to aut
* `ReactTestUtils` is now a `trait` as well as an `object` so that you can mix it into your own test utils collection
* Upgrade deps
* Cats-effect to 3.2.9
* scalajs-dom 2.0.0-RC1


# Thanks
Expand Down
15 changes: 8 additions & 7 deletions downstream-tests/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ def scalac3Flags = Seq(
def commonSettings: Project => Project = _
.configure(preventPublication)
.settings(
scalaVersion := Ver.scala3,
crossScalaVersions := Seq(Ver.scala2, Ver.scala3),
scalacOptions ++= scalacCommonFlags,
scalacOptions ++= byScalaVersion {
case (2, _) => scalac2Flags
case (3, _) => scalac3Flags
}.value,
scalaVersion := Ver.scala3,
crossScalaVersions := Seq(Ver.scala2, Ver.scala3),
scalacOptions ++= scalacCommonFlags,
scalacOptions ++= byScalaVersion {
case (2, _) => scalac2Flags
case (3, _) => scalac3Flags
}.value,
dependencyOverrides ++= globalDependencyOverrides.value,
)

lazy val cleanTestAll = taskKey[Unit]("cleanTestAll")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import japgolly.scalajs.react.util.DomUtil._
import japgolly.scalajs.react.util.Effect.Sync
import japgolly.scalajs.react.vdom.html_<^._
import org.scalajs.dom.html.Element
import org.scalajs.dom.raw.{CSSStyleDeclaration, Node}
import org.scalajs.dom.{console, document, window}
import org.scalajs.dom.{CSSStyleDeclaration, Node, console, document, window}
import scala.concurrent.duration._

object DefaultReusabilityOverlay {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package japgolly.scalajs.react.extra

import japgolly.scalajs.react._
import japgolly.scalajs.react.util.Effect.Dispatch
import org.scalajs.dom.Event
import org.scalajs.dom.raw.EventTarget
import org.scalajs.dom.{Event, EventTarget}
import scala.scalajs.js

class EventListenerF[F[_]] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package japgolly.scalajs.react.extra.internal

import japgolly.scalajs.react.util.Effect
import org.scalajs.dom.ext.AjaxException
import org.scalajs.dom.{ProgressEvent, XMLHttpRequest}
import scala.scalajs.js
import scala.util.{Failure, Success}
Expand Down Expand Up @@ -206,3 +205,7 @@ class AjaxF[F[_], Async[_]](implicit F: Effect.Sync[F], Async: Effect.Async[Asyn

private val newXHR = F.delay(new XMLHttpRequest())
}

final case class AjaxException(xhr: XMLHttpRequest) extends Exception {
def isTimeout = xhr.status == 0 && xhr.readyState == 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trait ReactDOM extends js.Object {

val version: String = js.native

final type Container = dom.Element | dom.raw.Document
final type Container = dom.Element | dom.Document

final def render(element : React.Node,
container: Container,
Expand Down
5 changes: 1 addition & 4 deletions ghpages/src/main/scala/ghpages/examples/TouchExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ object TouchExample {
)

private def formatTouches(touches: dom.TouchList) =
toSeq(touches).map(formatCoordinates).mkString(" | ")

private def toSeq[A](list: dom.DOMList[A]) =
for(i <- 0 to list.length - 1) yield list.item(i)
touches.iterator.map(formatCoordinates).mkString(" | ")

private def formatCoordinates(touch: dom.Touch) =
s"${touch.screenX}x${touch.screenY}: ${touch.radiusX}x${touch.radiusY}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package ghpages.examples.util
import japgolly.scalajs.react._
import japgolly.scalajs.react.vdom.html_<^._
import org.scalajs.dom.Element
import org.scalajs.dom.ext.PimpedNodeList
import scala.scalajs.js.Dynamic.global

object CodeSnippets {
Expand Down
9 changes: 5 additions & 4 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ object Dependencies {
// Externally observable
val cats = "2.6.1"
val catsEffect = "3.2.9"
val microlibs = "3.0.1"
val microlibs = "4.0.0-RC1"
val monocle2 = "2.1.0"
val monocle3 = "3.1.0"
val scala2 = "2.13.6"
val scala3 = "3.0.2"
val scalaJsDom = "1.2.0"
val scalaJsDom = "2.0.0-RC1"
val sourcecode = "0.2.7"

// Internal
Expand All @@ -29,7 +29,7 @@ object Dependencies {
val scalaJsJavaTime = "1.0.0"
val scalaTest = "3.2.10"
val sizzleJs = "2.3.0"
val univEq = "1.6.0"
val univEq = "2.0.0-RC1"
val utest = "0.7.10"
}

Expand All @@ -50,7 +50,7 @@ object Dependencies {
val nyayaProp = Def.setting("com.github.japgolly.nyaya" %%% "nyaya-prop" % Ver.nyaya)
val nyayaTest = Def.setting("com.github.japgolly.nyaya" %%% "nyaya-test" % Ver.nyaya)
val scalaCompiler = Def.setting("org.scala-lang" % "scala-compiler" % scalaVersion.value)
val scalaJsDom = Def.setting("org.scala-js" %%% "scalajs-dom" % Ver.scalaJsDom cross CrossVersion.for3Use2_13)
val scalaJsDom = Def.setting("org.scala-js" %%% "scalajs-dom" % Ver.scalaJsDom)
val scalaJsJavaTime = Def.setting("org.scala-js" %%% "scalajs-java-time" % Ver.scalaJsJavaTime cross CrossVersion.for3Use2_13)
val scalaReflect = Def.setting("org.scala-lang" % "scala-reflect" % scalaVersion.value)
val scalaTest = Def.setting("org.scalatest" %%% "scalatest" % Ver.scalaTest)
Expand Down Expand Up @@ -78,6 +78,7 @@ object Dependencies {
}

def globalDependencyOverrides = Def.setting(Seq(
Dep.scalaJsDom.value,
Dep.univEq.value,
Dep.univEqCats.value,
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ trait ReactTestUtils extends japgolly.scalajs.react.test.internal.ReactTestUtilE
(c: GenericComponent[P, CtorType.Props, U], m: M)(f: P => P): M = {
val container = m.getDOMNode.asMounted().node.parentNode
val p2 = f(m.props)
act(c(p2).renderIntoDOM(container.domCast[org.scalajs.dom.raw.Element]))
act(c(p2).renderIntoDOM(container.domCast[org.scalajs.dom.Element]))
}

def replaceProps[P, U <: GenericComponent.Unmounted[P, M], M <: GenericComponent.MountedImpure[P, _]]
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test/scala/japgolly/scalajs/react/MiscTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ object MiscTest extends TestSuite {
}

"domExt" - {
import org.scalajs.dom.raw._
import org.scalajs.dom._
"domCast" - assertType[Node].map(_.domCast[HTMLInputElement]).is[HTMLInputElement]
"domAsHtml" - assertType[Node].map(_.domAsHtml).is[HTMLElement]
"domToHtml" - {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import japgolly.scalajs.react.test.ReactTestUtils
import japgolly.scalajs.react.test.TestUtil._
import japgolly.scalajs.react.vdom.html_<^._
import org.scalajs.dom._
import org.scalajs.dom.raw.EventInit
import utest._

object EventListenerTest extends TestSuite {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import japgolly.scalajs.react.facade.SyntheticEvent
import japgolly.scalajs.react.test.TestUtil._
import japgolly.scalajs.react.vdom.html_<^._
import org.scalajs.dom
import org.scalajs.dom.document
import org.scalajs.dom.raw.{HTMLElement, HTMLInputElement}
import org.scalajs.dom.{HTMLElement, HTMLInputElement, document}
import scala.annotation.nowarn
import scala.concurrent.Promise
import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue
Expand Down
6 changes: 3 additions & 3 deletions util/src/main/scala/japgolly/scalajs/react/util/DomUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import org.scalajs.dom.html
object DomUtil {

/** Extensions to plain old DOM. */
@inline implicit final class ReactExt_DomNode(private val n: dom.raw.Node) extends AnyVal {
@inline implicit final class ReactExt_DomNode(private val n: dom.Node) extends AnyVal {

@inline def domCast[N <: dom.raw.Node]: N =
@inline def domCast[N <: dom.Node]: N =
n.asInstanceOf[N]

@inline def domAsHtml: html.Element =
Expand All @@ -26,6 +26,6 @@ object DomUtil {
trait DomUtil {
import DomUtil._

@inline final implicit def ReactExt_DomNode(n: dom.raw.Node): ReactExt_DomNode =
@inline final implicit def ReactExt_DomNode(n: dom.Node): ReactExt_DomNode =
new ReactExt_DomNode(n)
}