<commit_before>package io.udash.bindings.modifiers

import io.udash.utils.Registration
import org.scalajs.dom.Element
import scalatags.generic.Modifier

import scala.scalajs.js

/** Modifier representing data binding. */
trait Binding extends Modifier[Element] {
  protected final val propertyListeners: js.Array[Registration] = js.Array()
  protected final val nestedBindings: js.Array[Binding] = js.Array()

  /** Every interceptor is expected to return the value received as argument. */
  final val nestedInterceptor: Binding.NestedInterceptor = new Binding.NestedInterceptor {
    override def apply(binding: Binding): binding.type = {
      nestedBindings.push(binding)
      binding
    }
    override def multi(bindings: Binding*): bindings.type = {
      nestedBindings.push(bindings: _*)
      bindings
    }
  }

  def addRegistration(registration: Registration): Unit = propertyListeners += registration

  /** This method clears all bindings and listeners. */
  def kill(): Unit = {
    killNestedBindings()
    propertyListeners.foreach(_.cancel())
    propertyListeners.length = 0 // JS way to clear an array
  }

  /** This method clears all nested bindings and listeners. */
  def killNestedBindings(): Unit = {
    nestedBindings.foreach(_.kill())
    nestedBindings.length = 0 // JS way to clear an array
  }
}

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 {
    final val Identity: NestedInterceptor = new NestedInterceptor {
      override def apply(binding: Binding): binding.type = binding
    }
  }

}<commit_msg>Allow discarding multiple handled bindings<commit_after>package io.udash.bindings.modifiers

import io.udash.utils.Registration
import org.scalajs.dom.Element
import scalatags.generic.Modifier

import scala.scalajs.js

/** Modifier representing data binding. */
trait Binding extends Modifier[Element] {
  protected final val propertyListeners: js.Array[Registration] = js.Array()
  protected final val nestedBindings: js.Array[Binding] = js.Array()

  /** Every interceptor is expected to return the value received as argument. */
  final val nestedInterceptor: Binding.NestedInterceptor = new Binding.NestedInterceptor {
    override def apply(binding: Binding): binding.type = {
      nestedBindings.push(binding)
      binding
    }
    override def multi[T <: Binding](bindings: T*): Seq[T] = {
      nestedBindings.push(bindings: _*)
      bindings
    }
  }

  def addRegistration(registration: Registration): Unit = propertyListeners += registration

  /** This method clears all bindings and listeners. */
  def kill(): Unit = {
    killNestedBindings()
    propertyListeners.foreach(_.cancel())
    propertyListeners.length = 0 // JS way to clear an array
  }

  /** This method clears all nested bindings and listeners. */
  def killNestedBindings(): Unit = {
    nestedBindings.foreach(_.kill())
    nestedBindings.length = 0 // JS way to clear an array
  }
}

object Binding {

  /** Every interceptor is expected to return the value received as argument. */
  trait NestedInterceptor {
    def apply(binding: Binding): binding.type
    def multi[T <: Binding](bindings: T*): Seq[T] = {
      bindings.foreach(apply(_))
      bindings
    }
  }

  object NestedInterceptor {
    final val Identity: NestedInterceptor = new NestedInterceptor {
      override def apply(binding: Binding): binding.type = binding
    }
  }

}
{'fraction_non_alphanumeric': 0.09782907392140698, 'fraction_numerical': 0.0010992030777686177, 'mean_word_length': 3.6369426751592355, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4823497', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1010, 'n_words': 298}