- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Wed, 02 Oct 2013 22:32:37 -0400
- To: "public-script-coord@w3.org" <public-script-coord@w3.org>
- CC: Anne van Kesteren <annevk@opera.com>
Consider this script:
try {
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://example.org", undefined);
xhr.send();
alert("Undefined treated as not passed");
} catch (e) {
alert("Undefined treated as false");
}
Note that the WebIDL for XMLHttpRequest.prototype.open is:
void open(ByteString method, DOMString url,
optional boolean async = true,
optional DOMString? user,
optional DOMString? password);
In current browsers the above testcase throws an exception, because the
XHR ends up sync: the undefined is coerced to bool, and ends up false.
But if undefined is treated as missing (as I just tried to do in Gecko),
the XHR ends up _async_, and no exception is thrown.
It's possible that in this case we can simply rewrite the IDL like so:
void open(ByteString method, DOMString url);
void open(ByteString method, DOMString url,
boolean async,
optional DOMString? user,
optional DOMString? password);
with prose saying that the two-argument form is async. That would
preserve the current behavior, which I expect the web depends on....
-Boris
Received on Thursday, 3 October 2013 02:33:08 UTC