Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly specify the constructor algorithm and internal slots for SensorErrorEvent #426

Open
anssiko opened this issue Dec 14, 2021 · 3 comments

Comments

@anssiko
Copy link
Member

anssiko commented Dec 14, 2021

We should properly specify the constructor algorithm and internal slots for SensorErrorEvent:

https://www.w3.org/TR/generic-sensor/#the-sensor-error-event-interface

@rakuco
Copy link
Member

rakuco commented Dec 14, 2021

I've been confused about this before too, and I think the current text is fine as-is.

The constructor algorithm is actually specified in the DOM spec:

When a constructor of the Event interface, or of an interface that inherits from the Event interface, is invoked, these steps must be run, given the arguments type and eventInitDict:

  1. Let event be the result of running the inner event creation steps with this interface, null, now, and eventInitDict.
  2. Initialize event’s type attribute to type.
  3. Return event.

which also takes care of initializing the error attribute.

As for the description of the attribute itself, I'm following the style used by the WHATWG specs as well as e.g. AppHistory:

@domenic is this the recommended style or is it better to have internal slots for the attributes and follow the more usual "the error getter steps are to return [=this=].[[Error]]" path?

@domenic
Copy link

domenic commented Dec 14, 2021

Yeah, good question. Events are an unfortunate and confusing exception to the usual rules; we generally fudge them, even in recent specs, as @rakuco points out. So I think your current draft for SensorErrorEvent is reasonable; I would even delete the separate 7.2.1. SensorErrorEvent.error section and do it like other specs.

(Although, separately, it looks like a mistake to have SensorErrorEvent different from ErrorEvent. For app history, we just reuse ErrorEvent.)

rakuco pushed a commit to rakuco/sensors that referenced this issue Dec 16, 2021
Related to w3c#426.

- Refer to Event's constructor steps to describe how SensorErrorEvent is
  initialized and avoid confusion in the future.
- Instead of having a separate session for SensorErrorEvent.error, just have
  a paragraph with the kind of boilerplate description that specs like DOM,
  WebSockets and App History.
@rakuco
Copy link
Member

rakuco commented Dec 16, 2021

Thanks @domenic. #430 should make things a bit more clear. I guess it's too late to deprecate SensorErrorEvent though :/

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

No branches or pull requests

3 participants