w3c / uievents

UI Events
https://w3c.github.io/uievents/
Other
145 stars 52 forks source link

InputEvent.data should be nullable #116

Closed chong-z closed 7 years ago

chong-z commented 7 years ago

@garykac

According to the usage in InputEvent spec InputEvent.data should be nullable. (Link to the definition in UIEvent)

The reasons are:

  1. InputEvent.data is not inherited from UIEvent, so it's OK to make it nullable;
  2. InputEvent relies on the null check to tell JS which attribute they should use - data or dataTransfer;
  3. We can't use data == "" in this case because:
    • There are other inputTypes (e.g. 'formatBold') that shouldn't have a data field, and having data == "" would make it confusing;
    • It's possible for an IME to fire an InputEvent with empty text, which should still be valid (Not 100% sure if any browser is actually doing this though)