WebAudio / web-midi-api

The Web MIDI API, developed by the W3C Audio WG
http://webaudio.github.io/web-midi-api/
Other
321 stars 55 forks source link

MIDIMessageEvent data is not nullable #233

Closed padenot closed 9 months ago

padenot commented 2 years ago

STR in Chrome:

> var event = new MIDIMessageEvent("something");
> console.log(event.data);
< null

MIDIMessageEvent.data is not nullable, so this should be an empty array. It's harmless to allow an empty MIDIMessageEvent but it's not particularly useful either. We can change the spec for compat instead of having Chrome fixed maybe.

hoch commented 2 years ago
partial interface MIDIMessageEvent : Event {
  readonly attribute Uint8Array? data;
}

Does this look good? I agree that null is better.

padenot commented 2 years ago
dictionary MIDIMessageEventInit: EventInit {
  Uint8Array? data;
};

? is implied, the opposite being to specify require iirc.

hoch commented 2 years ago

Yes. Then we can lose the dictionary bit. I edited my comment above. Thanks!

padenot commented 2 years ago

https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/webmidi/midi_message_event_init.idl;l=8-11 a related TODO in Chromium.

padenot commented 2 years ago

https://github.com/WebAudio/web-midi-api/issues/168 seems to be a dupe, I'll sort it out.

mjwilson-google commented 9 months ago

Fixed by #252