webidl
webidl copied to clipboard
Should 'undefined' be disallowed as an attribute type?
Over on WebGPU, there is the following IDL fragment specified:
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?
I think @domenic wanted (… or undefined)
as type of an attribute. See https://github.com/whatwg/webidl/pull/906#issuecomment-670724983. Though in this particular case, I feel it would better adhere to convention if it instead said USVString?
.
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
The patch for switching Gecko's WebIDL parser/codegen to undefined hasn't landed yet, so taking that example as any sign one way or the other isn't right.
ok, closing this for now.