- From: Ojan Vafai <ojan@chromium.org>
- Date: Mon, 22 Oct 2012 18:18:34 -0700
- To: Boris Zbarsky <bzbarsky@mit.edu>
- Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
- Message-ID: <CANMdWTsCSnwKWs23a7=D=RgAL=DFYxoYE5eAt41Czy-e+Pbemg@mail.gmail.com>
A somewhat related issue is that there's no way for a developer to know whether the object being passed in is a dictionary or an object that is actually held onto. var obj = { handleEvent: function() { alert('noclick') } }; document.body.addEventListener('click', obj); obj.handleEvent = function() { alert('click') }; // Alerts 'click' when clicking on the body. var obj = { bubbles: true } var myEvent = new Event('customevent', obj); obj.bubbles = false; // myEvent.bubbles == true This is kind of gross. I'm not really sure what we can do to make it better. On Wed, Oct 17, 2012 at 7:08 PM, Boris Zbarsky <bzbarsky@mit.edu> 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? > > -Boris > >
Received on Tuesday, 23 October 2012 01:19:23 UTC