-
Notifications
You must be signed in to change notification settings - Fork 743
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
callback should follow error-first convention #83
Comments
I had thought of this previously, but never implemented it for a couple reasons:
Due to the fact that it would be completely backwards incompatible, it is not likely that We could, however add a completely new method that follows Node conventions; but it would be a non-trivial effort to capture all the possible error conditions and ensure they are passed back alongside results. |
Yep, totally. A new method would be necessary, or at the very least, making the change only in a major release.
I'm not sure I follow this. In node, you usually get an error or results. Since you can't throw an exception when running async, the |
It just logs errors to the console; which is not great, but at least you can see them. We purposely do not throw exceptions because of the nature of the DOM. Weird things can happen and prototypes can be clobbered, so it is important that a single failing Check doesn't stop execution. A good example of an exception we can't really prevent is if a <form id="something">
<input name="id" type="hidden">
</form> When rules that need to look at the ID of elements will choke when The conditions which you pointed out would be useful:
In addition there are a few more error conditions with frames:
Additionally there are other exceptions that might occur with Rules and Checks:
|
Wanted to share another reason that would make the node-style preferable: promises. Nearly every promise library out there has some form of denodeify method that can be used to seamlessly convert a callback-accepting function into a promise-returning function. These denodeify helpers only work, of course, when the callback follows the error-first node convention. Without the node-style callback, To the error handling side of things. Since |
DECISION: We will implement this as a new API for doing the audit. The existing API will be built on top of this new API to ensure backwards compatibility. Still trying to determine the feasibility of cascading errors up from all the iframes. |
Update messages - consistentency and whatnot
This has been implemented with |
For better or for worse, nodejs conventions are taking over JavaScript as a whole, even in browser js.
One convention that applies to a11yCheck is the callback parameters. It currently accepts a single successful result parameter. NodeJS convention, by contrast, is well established that callbacks are defined as
cb(error, result)
.I strongly recommend that the a11yCheck callback conform to this pattern, as it would make it possible to use all the nodejs async utilities (like
async
itself, and any promise library with denodify-like support).Some ready on node's error-first callbacks: http://thenodeway.io/posts/understanding-error-first-callbacks/
The text was updated successfully, but these errors were encountered: