From ef3956c163f13ea405df49b8d14acb7cda4c453b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kozak?= Date: Fri, 8 Sep 2023 15:31:45 +0200 Subject: [PATCH 1/7] upgrade jQuery to 3.6.4 due to CVE-2020-11022, CVE-2020-23064, CVE-2020-11023 vulnerabilities --- README.md | 2 +- build.sbt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 32fdc79..b794ab8 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Static types for the jQuery API for [Scala.js](http://www.scala-js.org/) program Add the following dependency to your SBT build: ```scala -libraryDependencies += "io.udash" %%% "udash-jquery" % "3.0.4" +libraryDependencies += "io.udash" %%% "udash-jquery" % "3.2.0" ``` then import the jQuery package: diff --git a/build.sbt b/build.sbt index 5259e63..4103db2 100644 --- a/build.sbt +++ b/build.sbt @@ -85,6 +85,6 @@ lazy val root = project.in(file(".")) "com.lihaoyi" %%% "scalatags" % "0.10.0" % Test ), - Compile / npmDependencies += "jquery" -> "3.4.1", - jsDependencies += "org.webjars" % "jquery" % "3.4.1" / "3.4.1/jquery.js" minified s"3.4.1/jquery.min.js", + Compile / npmDependencies += "jquery" -> "3.6.4", + jsDependencies += "org.webjars" % "jquery" % "3.6.4" / "3.6.4/jquery.js" minified s"3.6.4/jquery.min.js", ) From f8ba96599e71f42de970ead9caabc236d2004404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kozak?= Date: Mon, 2 Oct 2023 10:47:34 +0200 Subject: [PATCH 2/7] upgrade scalaJs, add jQuery methods --- build.sbt | 2 +- project/build.properties | 2 +- project/plugins.sbt | 4 ++-- src/main/scala/io/udash/wrappers/jquery/JQuery.scala | 8 ++++++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 4103db2..3ccda35 100644 --- a/build.sbt +++ b/build.sbt @@ -80,7 +80,7 @@ lazy val root = project.in(file(".")) deploymentConfiguration, libraryDependencies ++= Seq( - "org.scala-js" %%% "scalajs-dom" % "2.0.0", + "org.scala-js" %%% "scalajs-dom" % "2.7.0", "org.scalatest" %%% "scalatest" % "3.2.9" % Test, "com.lihaoyi" %%% "scalatags" % "0.10.0" % Test ), diff --git a/project/build.properties b/project/build.properties index e9db047..657d488 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1,2 +1,2 @@ # suppress inspection "UnusedProperty" -sbt.version=1.5.5 \ No newline at end of file +sbt.version=1.9.2 \ No newline at end of file diff --git a/project/plugins.sbt b/project/plugins.sbt index fa81d0b..6e5469d 100755 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,7 +1,7 @@ logLevel := Level.Warn -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.0") -addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.20.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.2") +addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") addSbtPlugin("org.scala-js" % "sbt-jsdependencies" % "1.0.2") // Deployment configuration diff --git a/src/main/scala/io/udash/wrappers/jquery/JQuery.scala b/src/main/scala/io/udash/wrappers/jquery/JQuery.scala index 8218c5a..89f1be9 100644 --- a/src/main/scala/io/udash/wrappers/jquery/JQuery.scala +++ b/src/main/scala/io/udash/wrappers/jquery/JQuery.scala @@ -164,6 +164,10 @@ trait JQuery extends js.Object { @JSName("eq") def at(index: Int): JQuery = js.native + /** Reduce the set of matched elements to the even ones in the set, numbered from zero.
+ * See: jQuery Docs */ + def even(): JQuery = js.native + /** Display the matched elements by fading them to opaque.
* See: jQuery Docs */ def fadeIn(duration: Int = js.native, easing: EasingFunction = js.native): JQuery = js.native @@ -381,6 +385,10 @@ trait JQuery extends js.Object { * See: jQuery Docs */ def not(el: Element*): JQuery = js.native + /** Reduce the set of matched elements to the odd ones in the set, numbered from zero.
+ * See: jQuery Docs */ + def odd(): JQuery = js.native + /** Remove an event handler.
* See: jQuery Docs */ def off(): JQuery = js.native From 121e7f150c075ae1a5ba8e3b86b0deedba0b9ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kozak?= Date: Mon, 2 Oct 2023 11:03:25 +0200 Subject: [PATCH 3/7] upgrade webpack to 5.75.0 --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index 3ccda35..11f17e7 100644 --- a/build.sbt +++ b/build.sbt @@ -22,6 +22,7 @@ val commonSettings = Seq( "-Ycache-plugin-class-loader:last-modified", "-Ycache-macro-class-loader:last-modified", ), + webpack / version := "5.75.0" ) val commonJSSettings = Seq( From 1ddf89a6e5bc7714b7734460711738b100286a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kozak?= Date: Tue, 3 Oct 2023 09:08:46 +0200 Subject: [PATCH 4/7] move webpack version declaration --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 11f17e7..6d600cf 100644 --- a/build.sbt +++ b/build.sbt @@ -22,7 +22,6 @@ val commonSettings = Seq( "-Ycache-plugin-class-loader:last-modified", "-Ycache-macro-class-loader:last-modified", ), - webpack / version := "5.75.0" ) val commonJSSettings = Seq( @@ -34,6 +33,7 @@ val commonJSSettings = Seq( val githubDir = "https://raw.githubusercontent.com/UdashFramework/scala-js-jquery" s"-P:scalajs:mapSourceURI:$localDir->$githubDir/v${version.value}/" }, + webpack / version := "5.75.0", // TODO: can be removed when sbt-scalajs-bundler > 0.21.1 ) val deploymentConfiguration = Seq( From cf69232e99b644dbac8e220ed2cbb0f8d03d7013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kozak?= Date: Tue, 3 Oct 2023 12:56:15 +0200 Subject: [PATCH 5/7] add "even/odd matching element" test case --- .../wrappers/jquery_test/TraversingTest.scala | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala b/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala index 82116cf..007e03e 100644 --- a/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala +++ b/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala @@ -1,8 +1,12 @@ package io.udash.wrappers.jquery_test +import org.scalajs.dom.HTMLSpanElement import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec +import scala.scalajs.js +import scala.scalajs.js.Object.entries + class TraversingTest extends AnyWordSpec with Matchers { import io.udash.wrappers.jquery._ @@ -166,5 +170,29 @@ class TraversingTest extends AnyWordSpec with Matchers { root.children("a").first().length should be(0) root.children("a").last().length should be(0) } + + "even/odd matching element" in { + val dom = div( + span("0"), + span("1"), + span("2"), + span("3"), + span("4"), + span("5"), + ).render + + val root = jQ(dom) + val evens = root.children("span").even() + val odds = root.children("span").odd() + + entries(evens).collect { + case js.Tuple2(_: String, x: HTMLSpanElement) => x.textContent + }.toSeq shouldBe Seq("0", "2", "4") + + entries(odds).collect { + case js.Tuple2(_: String, x: HTMLSpanElement) => x.textContent + }.toSeq shouldBe Seq("1", "3", "5") + + } } } From 2b80181a7208f6c13909ddd90ee371ab53f33e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kozak?= Date: Wed, 4 Oct 2023 08:52:35 +0200 Subject: [PATCH 6/7] refactor test --- .../wrappers/jquery_test/TraversingTest.scala | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala b/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala index 007e03e..cf6b100 100644 --- a/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala +++ b/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala @@ -4,9 +4,6 @@ import org.scalajs.dom.HTMLSpanElement import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec -import scala.scalajs.js -import scala.scalajs.js.Object.entries - class TraversingTest extends AnyWordSpec with Matchers { import io.udash.wrappers.jquery._ @@ -182,17 +179,9 @@ class TraversingTest extends AnyWordSpec with Matchers { ).render val root = jQ(dom) - val evens = root.children("span").even() - val odds = root.children("span").odd() - - entries(evens).collect { - case js.Tuple2(_: String, x: HTMLSpanElement) => x.textContent - }.toSeq shouldBe Seq("0", "2", "4") - - entries(odds).collect { - case js.Tuple2(_: String, x: HTMLSpanElement) => x.textContent - }.toSeq shouldBe Seq("1", "3", "5") - + root.children("span").even().text() shouldBe "024" + root.children("span").odd().text() shouldBe "135" } + } } From bcbd790b1a6dcaf75e5beeee6d5adf574b184aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kozak?= Date: Wed, 4 Oct 2023 10:23:18 +0200 Subject: [PATCH 7/7] refactor test --- .../scala/io/udash/wrappers/jquery_test/TraversingTest.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala b/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala index cf6b100..2ff1b89 100644 --- a/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala +++ b/src/test/scala/io/udash/wrappers/jquery_test/TraversingTest.scala @@ -1,6 +1,5 @@ package io.udash.wrappers.jquery_test -import org.scalajs.dom.HTMLSpanElement import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec