slinky icon indicating copy to clipboard operation
slinky copied to clipboard

Tag support for Scala 3

Open steinybot opened this issue 2 years ago • 1 comments

This issue is for doing something about T#tagType which is not supported in Scala 3, as mentioned in #494.

  type supports[T <: Tag] = AttrPair[attrType] => AttrPair[T#tagType]

Changing that to something like:

type supports[T <: Tag] = Conversion[AttrPair[attrType], AttrPair[T]]

could be an option but then there is the question of what to do about:

@inline def :=[T <: slinky.core.TagElement](v: slinky.web.SyntheticMouseEvent[T#RefType] => Unit) =
  new slinky.core.AttrPair[T]("onClick", v)

It would probably require an explicit type to be given for the handler which would suck but maybe this could work:

@inline def :=[T <: slinky.core.Tag, R](v: slinky.web.SyntheticMouseEvent[R] => Unit) =
  new slinky.core.AttrPair[T]("onClick", v)

This then begs the question, should AttrPair (and TagMod) keep the A phantom type? I'm not so sure.

Perhaps there is a better way to represent which attributes a tag supports.

steinybot avatar May 25 '23 00:05 steinybot

Yeah, unfortunately maybe the answer is just to give up on inferred DOM types for events and require the user to do manual casting. I'll try to think if there is some workaround but there doesn't seem to be one based on my (limited) knowledge of Scala 3's type member support.

shadaj avatar Aug 12 '23 17:08 shadaj