RE: [WebIDL] interface objects with [Constructor] and [[Call]]

The way I interpret that, [[Call]] should equal [[Construct]] in all cases for host objects. Why? Because real-world code using XMLHttpRequest today mixes and matches the invocation pattern: 

'new XMLHttpRequest;'
'new XMLHttpRequest();'
'XMLHttpRequest();'

and for web-compat, we want all of these to succeed.


-----Original Message-----
From: public-script-coord-request@w3.org [mailto:public-script-coord-request@w3.org] On Behalf Of Simon Pieters
Sent: Thursday, May 27, 2010 3:56 AM
To: public-script-coord@w3.org
Subject: [WebIDL] interface objects with [Constructor] and [[Call]]

Hi,

Should interface objects with the [Constructor] extended attribute implement [[Call]] in ECMAScript? What should happen when it's invoked? It doesn't seem to be defined in WebIDL.

For builtins in ECMAScript the behavior varies. ES follows [[Call]] === [[Construct]] except for String, Number, Boolean, Date and RegExp.  
Although [[Call]] on those don't throw, just do something different compared to [[Construct]].

For XMLHttpRequest, Opera and Firefox act as if [[Construct]] was invoked for [[Call]], while Safari and Chrome throw a TypeError exception. Please define which is correct.

Cheers,
--
Simon Pieters
Opera Software

Received on Friday, 11 June 2010 20:52:32 UTC