[whatwg/dom] MutationObserver.observe()'s dictionary argument must be optional per WebIDL (#316)

The spec says:

```
  void observe(Node target, MutationObserverInit options);
```

But WebIDL [says](http://heycam.github.io/webidl/#idl-operations): 

> If the type of an argument is a dictionary type or a union type that has a dictionary type as one of its flattened member types, and that dictionary type and its ancestors have no required members, and the argument is either the final argument or is followed only by optional arguments, then the argument must be specified as optional. Such arguments are always considered to have a default value of an empty dictionary, unless otherwise specified.
> 
> Note
> This is to encourage API designs that do not require authors to pass an empty dictionary value when they wish only to use the dictionary’s default values.
> 
> Dictionary types cannot have a default value specified explicitly, so the “unless otherwise specified” clause above can only be invoked for a union type that has a dictionary type as one of its flattened member types. 

So either we have to change DOM to make it optional (even though the method will throw TypeError if it's omitted), or we have to change WebIDL.  heycam/webidl#130 discusses the latter option, and was closed.  I'll comment there, although it seems I can't reopen it.

It looks like Edge and Chrome follow the spec and make it mandatory, while Firefox ignores the spec and makes it optional.  (Indeed, Firefox's WebIDL parser will reject invalid IDLs like this at compile time.)

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

Received on Sunday, 28 August 2016 17:36:20 UTC