Skip to content

v2.0.0

Compare
Choose a tag to compare
@armanbilge armanbilge released this 21 Oct 06:42
a96c76d

scala-js-dom v2.0.0 is the first release in the 2.x series. It is published for Scala 2.11, 2.12, 2.13, and 3.0+ with Scala.js 1.5+. Note that it breaks binary-compatibility with the 1.x series.

!! IMPORTANT: Remove CrossVersion.for3Use2_13 !!

As scala-js-dom v2.x publishes a Scala 3 artifact, this setting is no longer necessary. Failing to remove this from your build.sbt will cause your library to become binary-incompatible with other libraries correctly depending on scala-js-dom v2.x.

Migration guide

Update: for the latest migration guide with additional notes/hints from the community see #627.

scala-js-dom v2.0.0 is source-compatible to a great extent with v1.2.0, besides some corrections to facades and many new deprecation warnings. While testing the RC, we were able to upgrade several projects without making any changes!

To address the deprecation warnings:

  1. Replace imports into the dom.raw.*, dom.experimental.* and dom.crypto.* sub-packages with dom.*. Nearly everything is in dom.* now except for intl and webgl.
  2. Use new-based constructors instead of apply-based constructors.

Note that a consequence of retiring the experimental package is that we no longer designate experimental APIs. You can consult MDN and caniuse to determine which APIs are suitable for your projects.

You can also automate some, hopefully the majority, of your migration by running this quick script:

find . -type f -path '*/src/*.scala' -exec perl -pi -e '
  s/\bdom\.(raw|crypto|webworkers)\./dom./;
  s/\bdom\.experimental\.[a-z]+\./dom./;
  s/\bClientRect\b/DOMRect/g;
' {} +

Example migration

import org.scalajs.dom

// Before (deprecated)
val response = dom.experimental.ResponseInit(myStatus, myStatusText, myHeaders)

// After
val response = new dom.ResponseInit {
  var status = myStatus
  var statusText = myStatusText
  var headers = myHeaders
}

User-facing PRs

Thanks to our community contributors to this release for bravely opening PRs despite the significant churn as we put together 2.0.0! Now that things have stabilized, we look forward to many more PRs. Check out the contributing guide and help-wanted issues.

Full Changelog: v1.2.0...v2.0.0