<commit_before>package japgolly.scalajs.react.vdom

import org.scalajs.dom
import scala.scalajs.js
import japgolly.scalajs.react._
import Scalatags._
import Implicits._

object Extra {

  final class CompositeAttr[A](k: Attr, f: (A, List[A]) => A, e: => TagMod) {
    def apply(as: Option[A]*)(implicit ev: AttrValue[A]): TagMod =
      as.toList.filter(_.isDefined).map(_.get) match {
        case h :: t => k := f(h, t)
        case Nil => e
      }
  }

  final class AttrExt(private val _a: Attr) extends AnyVal {

    def -->(callback: => Callback): TagMod =
      _a := ((() => callback.runNow()): js.Function)

    def ==>[N <: dom.Node, E <: SyntheticEvent[N]](eventHandler: E => Callback): TagMod =
      _a := ((eventHandler(_: E).runNow()): js.Function)

    def -->?[O[_]](callback: => O[Callback])(implicit o: Optional[O]): TagMod =
      _a --> Callback(o.foreach(callback)(_.runNow()))

    def ==>?[O[_], N <: dom.Node, E <: SyntheticEvent[N]](eventHandler: E => O[Callback])(implicit o: Optional[O]): TagMod =
      _a.==>[N, E](e => Callback(o.foreach(eventHandler(e))(_.runNow())))
  }
<commit_msg>Add internal comment about --> ==><commit_after>package japgolly.scalajs.react.vdom

import org.scalajs.dom
import scala.scalajs.js
import japgolly.scalajs.react._
import Scalatags._
import Implicits._

object Extra {

  final class CompositeAttr[A](k: Attr, f: (A, List[A]) => A, e: => TagMod) {
    def apply(as: Option[A]*)(implicit ev: AttrValue[A]): TagMod =
      as.toList.filter(_.isDefined).map(_.get) match {
        case h :: t => k := f(h, t)
        case Nil => e
      }
  }

  final class AttrExt(private val attr: Attr) extends AnyVal {

    // Below we only accept Callback and not CallbackTo[_].
    // This provides devs more power in that types can be used to distinguish DOM-ready callbacks and intermediary
    // callbacks that explicitly return a value designed to be processed.
    // Any CallbackTo[_] can trivially be turned into a Callback by calling .void().

    def -->(callback: => Callback): TagMod =
      attr := ((() => callback.runNow()): js.Function)

    def ==>[N <: dom.Node, E <: SyntheticEvent[N]](eventHandler: E => Callback): TagMod =
      attr := ((eventHandler(_: E).runNow()): js.Function)

    def -->?[O[_]](callback: => O[Callback])(implicit o: Optional[O]): TagMod =
      attr --> Callback(o.foreach(callback)(_.runNow()))

    def ==>?[O[_], N <: dom.Node, E <: SyntheticEvent[N]](eventHandler: E => O[Callback])(implicit o: Optional[O]): TagMod =
      attr.==>[N, E](e => Callback(o.foreach(eventHandler(e))(_.runNow())))
  }

{'fraction_non_alphanumeric': 0.1819230769230769, 'fraction_numerical': 0.0, 'mean_word_length': 3.5077989601386483, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, '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': '675630', 'n_tokens_mistral': 933, 'n_tokens_neox': 907, 'n_words': 231}