[whatwg/webidl] Should 'undefined' be disallowed as an attribute type? (Issue #1112)

Over on WebGPU, there is the following [IDL fragment](https://www.w3.org/TR/webgpu/#webgpu-interfaces) specified:

```WebIDL
interface mixin GPUObjectBase {
    attribute (USVString or undefined) label;
};
```

Leaving aside the issues with this `label` attribute itself, I'm wondering if we should outright ban `undefined` as an attribute type? 

I personally can't think of any strong reason for an attribute to be declared `undefined` (unless it was settable to `any`). But I might be missing something obvious. It would be extremely confusing if an attribute was present and yet `undefined` (instead of null or "", in the case above for instance).  

For the case above, Gecko, for instance, willfully violates the spec by null'ing the label attribute:
https://searchfox.org/mozilla-central/source/dom/webidl/WebGPU.webidl#51
 
A quick grep of WPT's IDLs and also Gecko's IDLs, I can't find any place in the Platform the where there is a `attribute undefined` specified or a union that is includes `undefined` for an attribute type. 

Thoughts? 


-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1112
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/issues/1112@github.com>

Received on Wednesday, 2 March 2022 02:24:46 UTC