From ab4a32deccd5772a4fc61dccee86bbfacc39c282 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Mon, 23 May 2022 13:59:00 +0200 Subject: [PATCH] Clean multiple bindings --- .../main/scala/io/udash/bindings/modifiers/Binding.scala | 8 ++++++++ .../test/scala/io/udash/bindings/TagsBindingTest.scala | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/.js/src/main/scala/io/udash/bindings/modifiers/Binding.scala b/core/.js/src/main/scala/io/udash/bindings/modifiers/Binding.scala index 7ce1bef27..0f85d06b0 100644 --- a/core/.js/src/main/scala/io/udash/bindings/modifiers/Binding.scala +++ b/core/.js/src/main/scala/io/udash/bindings/modifiers/Binding.scala @@ -17,6 +17,10 @@ trait Binding extends Modifier[Element] { nestedBindings.push(binding) binding } + override def multi(bindings: Binding*): bindings.type = { + nestedBindings.push(bindings: _*) + bindings + } } def addRegistration(registration: Registration): Unit = propertyListeners += registration @@ -40,6 +44,10 @@ object Binding { /** Every interceptor is expected to return the value received as argument. */ trait NestedInterceptor { def apply(binding: Binding): binding.type + def multi(bindings: Binding*): bindings.type = { + bindings.foreach(apply(_)) + bindings + } } object NestedInterceptor { diff --git a/core/.js/src/test/scala/io/udash/bindings/TagsBindingTest.scala b/core/.js/src/test/scala/io/udash/bindings/TagsBindingTest.scala index 4e830ebf3..2e46b1852 100644 --- a/core/.js/src/test/scala/io/udash/bindings/TagsBindingTest.scala +++ b/core/.js/src/test/scala/io/udash/bindings/TagsBindingTest.scala @@ -1912,7 +1912,7 @@ class TagsBindingTest extends UdashFrontendTest with Bindings { bindings: Bindin val el = div( repeatWithIndex(p) { case (item, idx, nested) => - span(nested(bind(idx)), nested(bind(item))).render + span(nested.multi(bind(idx), nested(bind(item)))).render } ).render