Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MutationObserver.observe()'s dictionary argument must be optional per WebIDL #316

Closed
ayg opened this issue Aug 28, 2016 · 0 comments
Closed

Comments

@ayg
Copy link
Contributor

ayg commented Aug 28, 2016

The spec says:

  void observe(Node target, MutationObserverInit options);

But WebIDL says:

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. whatwg/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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant