Skip to content

Conversation

@nondebug
Copy link
Collaborator

@nondebug nondebug commented Oct 10, 2024

Closes #216

The following tasks have been completed:

  • Modified Web platform tests (link to pull request)

Implementation commitment:


Preview | Diff


interface GamepadEvent: Event {
constructor(DOMString type, GamepadEventInit eventInitDict);
constructor(DOMString type, optional GamepadEventInit eventInitDict = {});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to remove the required from GamepadEventInit's gamepad.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blink, Gecko, WebKit agree that GamepadEventInit's gamepad attribute is optional and nullable, let's update the spec to match.

  Gamepad? gamepad;  // blink
  Gamepad? gamepad = null;  // Gecko
  Gamepad? gamepad = null;  // WebKit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

@tcl3
Copy link

tcl3 commented Sep 2, 2025

Should the type of the gamepad attribute also be nullable, since it can now return null?

@marcoscaceres
Copy link
Member

@tcl3, yes, good catch. I think the attributes are required to mirror the value they are initialized with.

@weinig
Copy link

weinig commented Jan 19, 2026

Other than matching current implementations, is there a reason/use case for a null gamepad on GamepadEvent. In WebKit at least, the engine will never create a GamepadEvent with a null Gamepad (other than in this case where the user constructs it from JS). Is there reason to think there is a compat issue with fixing engines to require it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eventInitDict parameter in GamepadEvent constructor should be optional

5 participants