-
Notifications
You must be signed in to change notification settings - Fork 29
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
Editorial: combine safety check steps into new section #251
Conversation
<p> | ||
The <dfn>common safety checks</dfn> for a {{Document}} | ||
|document:Document| are the following steps: | ||
</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should make these throw an exception. Web IDL will do the conversion from a thrown exception to a rejected promise. Returning an exception is very weird.
Alternatively you could return a(n) (string) enum and branch on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, yeah, good point... will make them throw directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, sooooo... these all throw now. And yes, the IDL layer would automatically wrap the exceptions.
However, just from the sake of clarity and consistency, I'd still like to use "Return a promise rejected with X" for .lock()
. I've had instances in the past of reviewers getting confused about methods throwing even though they always return a promise.
Similarly, for .unlock(), just for clarity, I have it re-throw and abort the steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that's okay, but I'd rather we explain the mechanism in a note so implementations with correct binding layers don't do this redundantly as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it would be way cleaner. I'd also rather just be writing:
- If X throw {{WhateverError}}.
- If Y throw {{OtherError}}.
And so on... It feels like WebIDL's [=exception/throw=] should include such a note. Currently, it's not super clear what should happen and every example in WebIDL is using [=return a promise rejected with=].
I'll raise an issue on WebIDL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyone interested whatwg/webidl#1301
292ceca
to
9a61afc
Compare
<li data-tests="hidden_document.html">If |document|'s | ||
[=Document/visibility state=] is "hidden", [=exception/throw=] | ||
{{"SecurityError"}} {{DOMException}}. | ||
</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It strikes me that if you adopt whatwg/html@2db564c here (and I think you should in a follow-up) you won't get to distinguish exceptions, but that's probably okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's ok. And yeah, will do that as a followup.
<p> | ||
The <dfn>common safety checks</dfn> for a {{Document}} | ||
|document:Document| are the following steps: | ||
</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that's okay, but I'd rather we explain the mechanism in a note so implementations with correct binding layers don't do this redundantly as well.
Closes #237
Preview | Diff