This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 27048 - Allow partial enums
Summary: Allow partial enums
Status: NEW
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: WebIDL (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Cameron McCormack
QA Contact: public-webapps-bugzilla
Depends on:
Reported: 2014-10-14 15:51 UTC by Mounir Lamouri
Modified: 2016-10-11 20:51 UTC (History)
10 users (show)

See Also:


Description Mounir Lamouri 2014-10-14 15:51:04 UTC
It would be interesting to have partial enums in order to enforce an allowed list of keywords passed as parameters but still allow other specification to extend that list without having to make the parameter an DOMString.

A concrete use case would be the Permissions API that would define a PermissionName enum that could be extended by specifications defining new permissions.
Comment 1 Anne 2014-10-14 15:56:45 UTC
That is not an ideal way of writing specifications. With all the bits fragmented. We have some of that already today and it is rather painful for implementers. What is wrong with reviving the base specification?
Comment 2 Mounir Lamouri 2014-11-06 21:28:54 UTC
We are actually considering using an enum in the specification now.
Comment 3 Tobie Langel 2016-02-04 16:22:08 UTC
So this issue was brought up again today as I'm moving forward with the Generic Sensor API.

Here's the concrete use case:

The editor writes a spec for the Heartbeat Sensor. Said spec obviously requires permissioning. Currently this requires amending the Permissions API to add a corresponding string (e.g. "heartbeat-sensor") to the PermissionName Enum[1].

Now, what happens when an implementor decides to implement the Permissions API, but not the Heartbeat sensor? Will he filter the corresponding string out of the enum?

If an implementor decides to implement the Heartbeat Sensor API, then removes it because it turns out the privacy concerns are to big, aren't the risks of forgetting to modify the enum higher if it lies in the Permissions API? In that case, developers could potentially have the Permission's API tell them the user has granted access to a sensor that's no longer implemented. Seems strange.

None of these are an issue if the "heartbeat-sensor" string is added to the PermissionName Enum[1] from the Heartbeat Sensor spec itself. I'm also not sure there are any downsides to having a split enum in this concrete example. Quite the contrary, actually, as it seems much more logical to split cross-cutting concerns like these across specs.

(Note I'm not suggesting that partial enums are the right choices in all use cases, but it's not because a hammer isn't the appropriate tool to fix a pair of glasses that a carpenter shouldn't be able to use one.)

Comment 4 Harald Alvestrand 2016-10-11 20:48:27 UTC
This bug has been open for 2 years. Can we either get it added to the spec or definitely rejected as a bad idea, so that people won't have hope that it will be added?

(I have need for this type of functionality in making valid IDL for the relationshiop between and If we can't have extensible enums, I'm going to suggest that we use a DOMString instead.)
Comment 5 Domenic Denicola 2016-10-11 20:51:41 UTC
As with many specs, Web IDL has overtaxed editors and a large backlog of bugs, several of which are more urgent than this one. If this is truly important to you, a pull request to add the feature to Web IDL would be excellent, as for example Jeffrey has recently done to close out the long-standing "open ended dictionary" feature.