W3C home > Mailing lists > Public > public-webapi@w3.org > March 2008

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

From: Jonas Sicking <jonas@sicking.cc>
Date: Wed, 19 Mar 2008 09:12:21 -0700
Message-ID: <47E13B65.2030806@sicking.cc>
To: Travis Leithead <travil@windows.microsoft.com>
CC: "Web APIs WG (public)" <public-webapi@w3.org>

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 

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 

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

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:25 UTC