This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
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.
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?
We are actually considering using an enum in the specification now.
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.) [1]: https://w3c.github.io/permissions/#idl-def-PermissionName
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 https://w3c.github.io/webrtc-stats/webrtc-stats.html and https://w3c.github.io/webrtc-pc/webrtc.html. If we can't have extensible enums, I'm going to suggest that we use a DOMString instead.)
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.