According to the usage in InputEvent specInputEvent.data should be nullable. (Link to the definition in UIEvent)
The reasons are:
InputEvent.data is not inherited from UIEvent, so it's OK to make it nullable;
InputEvent relies on the null check to tell JS which attribute they should use - data or dataTransfer;
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)
@garykac
According to the usage in InputEvent spec
InputEvent.data
should be nullable. (Link to the definition in UIEvent)The reasons are:
InputEvent.data
is not inherited fromUIEvent
, so it's OK to make it nullable;InputEvent
relies on the null check to tell JS which attribute they should use -data
ordataTransfer
;data == ""
in this case because:inputType
s (e.g.'formatBold'
) that shouldn't have adata
field, and havingdata == ""
would make it confusing;InputEvent
with empty text, which should still be valid (Not 100% sure if any browser is actually doing this though)