W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2013

Re: Interaction of dictionaries and platform objects is a bit weird

From: Cameron McCormack <cam@mcc.id.au>
Date: Tue, 23 Jul 2013 13:51:48 +1000
Message-ID: <51EDFDD4.6090600@mcc.id.au>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
Boris Zbarsky wrote:
> Consider the following IDL:
> dictionary Dict {
> long a;
> };
> [Constructor()]
> interface Iface {
> void foo(long x, optional Dict y);
> void bar(optional Dict z);
> void bar(Element w);
> };
> and this script, running in a web page:
> var x = new Iface();
> x.foo(5, document);
> x.bar(document);
> What happens?
> As far as I can tell, the foo() call succeeds. The "a" property of the
> document, if any, is placed in the dictionary, and then the number 5 and
> the dictionary are passed to the WebIDL method implementation.
> Also as far as I can tell the call bar() call throws. This is because we
> enter the overload resolution algorithm, set argcount to 1, throw our
> the 0-argument overload, set d to 0, examine arg 0, determine that it
> does not satisfy either overload (because document does not implement
> Element and because document is a platform object, so never enters step
> 13.6 of the overload resolution algorithm), and a TypeError is thrown.
> This seems a bit odd. I think we should either always throw a TypeError
> when converting platform objects to dictionaries or allow any object to
> enter step 13.6 of overload resolution... at least for dictionaries; not
> sure about callbacks. Maybe dictionaries need to be split out into a
> separate step here?

The spec has changed since your comment and it currently will not throw 
for the x.bar(document) call, as all objects (except for Date and 
RegExp, which are treated specially) can be converted to IDL dictionary 
(and sequence) types now.
Received on Tuesday, 23 July 2013 03:52:22 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:17 UTC