- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Wed, 17 Oct 2012 22:08:39 -0400
- To: "public-script-coord@w3.org" <public-script-coord@w3.org>
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? -Boris
Received on Thursday, 18 October 2012 02:09:08 UTC