Description
The connect
and disconnect
events are currently only fired on navigator.usb
. For disconnects in particular it is useful to be able to listen for a particular device being disconnected. For the Web Serial API we did this by making SerialPort
itself an EventTarget
and defining a custom parent algorithm so that the events bubble to navigator.serial
after being fired on the SerialPort
.
We should do the same for this API. I believe such a change would be backwards compatible. The only difference is that the target
attribute of the USBConnectionEvent
would be set to the value of its device
attribute instead of navigator.usb
.
The current workaround developers have to employ is to register an event handler and compare it against the device they are interested in.
CC @RReverser
Activity