w3c / gamepad

Gamepad
https://w3c.github.io/gamepad/
Other
138 stars 49 forks source link

gamepad*connected handlers are only needed on Window #166

Closed dontcallmedom closed 1 year ago

dontcallmedom commented 1 year ago

144 (cc @saschanaz ) added the ongamepadconnected and ongamepaddiscconnected to WindowEventHandlers, but that mixin is also included in HTMLBodyElement, HTMLFrameSetElement, SVGSVGElement which have no reason to expose these handlers, since the events is never fired to these interfaces.

I guess this should be replaced by a partial on Window directly?

marcoscaceres commented 1 year ago

which have no reason to expose these handlers, since the events is never fired to these interfaces.

Coincidently, they are fired on body (in Gecko). This is the same in WebKit, thought we only really care about them on Window and Body. It's actually also fine that they are fired on SVGSVGElement, but I haven't tested that.

For consistency (and because, well, the web is weird like this), I think it's fine keeping them on the (erroneously and terribly misleading-named) WindowEventHandlers mixin.

dontcallmedom commented 1 year ago

well, I meant that the spec never instructs to fire the event to any interface but the relevant global object (i.e. Window). So if the event is also meant to be fired on body, that should be spec'd.

marcoscaceres commented 1 year ago

Yes, I agree about that (that event behavior should be noted, but not specified): Somewhere in HTML (or DOM) the eventing behavior for WindowEventHandlers is specified. In theory, "fire an event" handles all this automatically, by matching event handler names to "onwhatever" attributes across the various objects listed above.

Let me see if I can find it...

dontcallmedom commented 1 year ago

oh, indeed https://html.spec.whatwg.org/multipage/webappapis.html#determining-the-target-of-an-event-handler

dontcallmedom commented 1 year ago

although if I understand https://html.spec.whatwg.org/multipage/webappapis.html#event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-6 correctly, this means the gamepad events should be added as event handler content attributes and the associated table.

marcoscaceres commented 1 year ago

Yes, they should be in the table.... then I think this algorithm comes into play:

https://html.spec.whatwg.org/#determining-the-target-of-an-event-handler

When setting the attribute. If I'm reading correctly, the event target is determined there?

marcoscaceres commented 1 year ago

(just spotted your comment above where you landed at the same place)

marcoscaceres commented 1 year ago

@dontcallmedom, I'll file a bug an HTML and send a PR...

marcoscaceres commented 1 year ago

Filed https://github.com/whatwg/html/issues/8079