scala-dom-types
scala-dom-types copied to clipboard
Integrate with `InputEvent`
Finally added this 😅
I'm a bit confused, it wasn't obvious to me if DomInputEvent is being used anywhere?
https://github.com/raquo/scala-dom-types/blob/de166bd3816ae2ad35bbc2fb405a120e46a03afb/shared/src/main/scala/com/raquo/domtypes/generic/defs/eventProps/FormEventProps.scala#L24-L33
Nice, thanks!
I'm a bit confused, it wasn't obvious to me if DomInputEvent is being used anywhere?
Huh, I figured that would be for the input event, but no, apparently it's just a generic Event.
The only event I can find that uses InputEvent is beforeinput, but currently we don't have it defined because it's rarely used and not supported by IE.
But well, since we're here, might as well add onBeforeInput and use the type param? If you do, please add Note: IE does not support this event on a new line in its ScalaDoc.
I think the problem is that IE just doesn't support InputEvent.
https://caniuse.com/mdn-api_inputevent
For example the note on this page suggests that an InputEvent is indeed used for input.
On browsers that don't fully implement the InputEvent interface which is used for the beforeinput and input events, you may get incorrect output on those lines of the log output.
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key#result
Ah, here is some explanation.
For and elements that accept text input (type=text, type=tel, etc.), the interface is InputEvent; for others, the interface is Event.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event
Ok well I don't think there's anything we can do to make that more typesafe is there?
I will add onBeforeInput as you suggested, thanks!
For and elements that accept text input (type=text, type=tel, etc.), the interface is InputEvent; for others, the interface is Event.
Sigh... Don't you just love the JS DOM API? Thanks for looking into it.
PR looks good to me, I will merge and release it when I get back to OSS work in October. (I try to keep master free of unreleased changes even if they're approved)
Thanks again!