-
Notifications
You must be signed in to change notification settings - Fork 168
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
Web IDL validation errors #2514
Comments
One possible solution is to differentiate the dictionary AudioSinkOptions {
required AudioSinkType type;
}
interface AudioSinkInfo {
readonly attribute AudioSinkType type;
}
partial interface AudioContext {
[SecureContext] readonly attribute (DOMString or AudioSinkInfo) sinkId;
} |
Yeah that would work. |
An alternative, which is simpler, is: dictionary AudioContextOptions {
...
DOMString? sinkId = "";
...
}
partial interface AudioContext {
[SecureContext] readlonly attribute DOMString? sinkId;
} So the usage for a silent sink (muted AudioContext) would be: new AudioContext({sinkId: null};
context.setSinkId(null);
console.log(context.sinkId); // null We lose flexibility and extensibility by not using the |
During the TPAC, I vaguely remember @padenot and I had a discussion on why the simpler approach doesn't work out well. I suggest that we give thoughts on this for a couple of more days and make a decision. |
As we all know, the confusion around context.setSinkId(null);
console.log(context.sinkId === undefined); // false
console.log(context.sinkId == undefined); // true
if (context.sinkId) {
// Does this mean |sinkId| is not defined yet? Or does it mean it's silent?
} It's different from being "undefined" because we defined the sink identifier, but in JS comparison it falls back to falsy and it is confusing. Also based on my experience, it's usually better to specify in details than taking a short path which is seemingly "intuitive". cc/ @jackschaedler - curious about your thoughts on this. |
I think what Hongchan mentioned about why not using context.setSinkId(null) is correct. It does become bug-prone if return sinkId as null. I vote +1 for using (DOMString or AudioSinkInfo) as sinkId return type. |
I think you might want to simply change the type of the attribute to
|
Thanks for the input, @saschanaz! I still see the benefit of having a defined class like |
Not too much from IDL side except it simply has less code. You also need to make sure you cache and reuse the instance so that this keeps being true: context.sinkId === context.sinkId // should be true! (Dictionary type is disallowed as the attribute would always create a new instance and thus make it false.) |
Good point. With |
Yup, that should work. |
https://webidl.spec.whatwg.org/#SameObject
Oh, maybe not 🙁. |
Yeah, it looks like DOMString is just a type, not an interface type: In that case, I can add a prose saying that this property is cached upon update and the user code will get the same object for reuse after caching. |
Such prose is a must even with In other words, the actual algorithm should describe the caching mechanism. |
@padenot Any thoughts? I can work on a PR based on #2514 (comment) and #2514 (comment). |
Yes, that sounds good to me, thanks! |
@saschanaz Is there any way to run autokagami against a PR? I would like to validate IDL before we land the change. |
No direct way exists for now. We do have https://w3c.github.io/webidl2.js/checker/ where you can copy paste and check. There also is w3c/spec-prod that does some validation in CI, but I don't think it does IDL validation right now. @sidvishnoi am I right? |
@saschanaz spec-prod supports WebIDL validation since sometime. Powered by webidl2.js and reffy. |
Yay! Then we can try replacing current autopublish.yml with spec-prod to take advantage of it 👍 |
@sidvishnoi Do you have an example GitHub action that I can take a look? |
@hoch If you want to see it working live: |
Thank you both @saschanaz and @sidvishnoi for being so responsive. Super helpful. I'll add this action to our workflow. |
Hmm. I am getting errors: I guess I'll have to dig around the log and figure out why we couldn't put the validator in our workflow. |
Just a validation error! |
Turns out there were already several bikeshed errors that were suppressed: https://github.com/WebAudio/web-audio-api/actions/runs/3191055463/jobs/5206917845 Time to solve them 😉 |
This is now fixed by #2517. |
No comment |
🤖 This is an automatic issue report for Web IDL validation error. 🤖
The bot found validation errors but couldn't fix them automatically, since there is no proper autofix for them. Please check the following messages and fix them.
Please file an issue at https://github.com/saschanaz/webidl-updater/issues/new if you think this is invalid or should be enhanced.
The text was updated successfully, but these errors were encountered: