w3c / performance-timeline

Performance Timeline
https://w3c.github.io/performance-timeline/
Other
111 stars 34 forks source link

WebIDL spec does not allow required dictionary argument with no required members #119

Closed hawkinsw closed 5 years ago

hawkinsw commented 5 years ago

It is my understanding from reading the WebIDL spec that the combination of the proposed declaration of the observe() method and the PerformanceObserverInit dictionary are incompatible.

In particular, the spec says that

If the type of an argument is a dictionary type or a union type that has a dictionary 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.

There are precedents with other specs where this same change needed to be made. E.g., https://github.com/whatwg/dom/issues/316

A change to optional will have a knock-on affect as to the value of the observe method's length. (It will go from 1 to 0).

I hope that this is a cogent analysis and look forward to helping make any necessary changes. Thank you!

npm1 commented 5 years ago

Ahh thanks for the investigation! So I think the only change needed here would be to make the PerformanceObserverInit options optional. The observe processing model already throws a SyntaxError if the entryTypes and type members are both missing, so it shouldn't affect behavior.

@igrigorik @yoavweiss @toddreifsteck @rniwa @mstange FYI

hawkinsw commented 5 years ago

Thanks for the reply. I agree with you.

rniwa commented 5 years ago

Makes sense.