-
Notifications
You must be signed in to change notification settings - Fork 13
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
Need to adjust IDL to make overload definitions distinguishable? #21
Comments
The deeper issue here is there's no way to distinguish these two types, so such an overload---or union---is meaningless. JavaScript functions passed to your method don't signal their return value in some way spec code can distinguish. You can't know what a JavaScript function will return, until you call it! Probably instead you want the callback to return object, and then you can do tests in prose accounting for the three cases of interest: the result of calling the callback implements HTMLMediaElement, the result implements AudioContext, or neither of those things are true. |
Hmm, that means that browsers would need to call the constructor themselves to check the return type. That does not sound like very good design (arbitrary constructors may have side effects). For context, the current design originates from #15 (comment) @alastor0325, this may suggest that the spec needs to consider a different approach. Perhaps with an enum? Something like:
|
… result, which replaces methods using constructor as an input.
…d on review suggestions.
…d on review suggestions. SHA: f82f69c Reason: push, by @alastor0325 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: 5167882 Reason: push, by @alastor0325 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: 0eed9a8 Reason: push, by @alastor0325 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Issue #21 - create a new enum type and use it to query the general result, which replaces methods using constructor as an input.
#20 takes care of merging overloaded definitions to meet one of the overloading requirements defined in Web IDL. Web IDL also requires that overload definitions be distinguishable.
The Autoplay Policy defines the following IDL:
If I'm reading Web IDL correctly, two callback functions are not distinguishable (see the matrix in the Web IDL spec).
This can probaby be fixed with a union type instead:
The Web IDL validator does not check these requirements, so I'm not 100% sure that the above analysis is correct. It may be worth checking with Web IDL experts. Cc @w3c/webidl-design for possible confirmation.
The text was updated successfully, but these errors were encountered: