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

Quoting Travis Leithead <travil@microsoft.com>:

> 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.

Arguably the XMLHttpRequest spec special cases this so all three forms
work at [1] (I am not sure what exactly is meant by "constructor is
invoked" here since it could mean "[[Construct]] method is called" or
"[[Call]] method is called"; this should probably be clarified in the
spec). Therefore that is not a good example from which to derive a
general rule.

On general principles I would prefer [[Call]] === [[Construct]] for
new host object constructors; it seems closest to the behaviour of
ECMAScript builtins and convenient for authors, but for legacy
constructors we probably need to mimic deployed UA behaviour.

[1] http://www.w3.org/TR/XMLHttpRequest/#constructors

Received on Friday, 11 June 2010 22:06:07 UTC