[heycam/webidl] Why can getter operations can implicitly return undefined? (#944)

There are two types of getter operations in the IDL world: returning null or undefined.

The first one is straightforward, it returns null when there is no item.

```webidl
[Exposed=(Window,Worker)]
interface DOMStringList {
  readonly attribute unsigned long length;
  getter DOMString? item(unsigned long index);
  boolean contains(DOMString string);
};
```

But the second one is surprising. Even when the return type must be DOMString, it just returns `undefined` when there is no item.

```webidl
[Exposed=Window,
 LegacyOverrideBuiltIns]
interface DOMStringMap {
  getter DOMString (DOMString name);
  [CEReactions] setter undefined (DOMString name, DOMString value);
  [CEReactions] deleter undefined (DOMString name);
};
```

Does the Web IDL spec allow this, or should this be specced? Or should it just be `(DOMString or undefined)` as it's now supported?

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

Received on Monday, 21 December 2020 15:33:04 UTC