Re: [Bindings] 'new' behavior on interface objects

Travis Leithead wrote:
> Since this spec is presumably creating a language binding for JavaScript, (and assuming interface objects are Functions, as seen by Opera), then why does:
> 
> var div = new HTMLDivElement();
> 
> produce a script error?
> 
> Seems like a perfectly valid thing to do, essentially a shortcut to document.createElement('div')

The problem is that this doesn't make sense for lots of interfaces. What 
does

var a = new HTMLElement();

do for example? And while there might only be one object that implement 
HTMLDivElement right now, who's to say that is true in the future.

As it so happens there are actually at least 2 objects in firefox that 
implement that interface, a HTML <div> and an XHTML <div> (they differ 
in case sensitivity handling), which one should be instantiated by your 
code?

/ Jonas

Received on Wednesday, 19 March 2008 16:13:51 UTC