Re: A proposal for Element constructors

On 25/10/11 8:54 PM, Adam Barth wrote:
> Another solution to that "more than one tag per interface" problem is
> to introduce subclasses of those interfaces for each tag.

Instead of introducing more interfaces (which don't have additional 
functionality), and instead of introducing Element.create, I would 
rather see a pattern like:

   var e = new Element("div", ...);

There is no requirement that the object returned from a constructor be 
an object that has the constructor.prototype as its [[Prototype]], so 
having the above constructor return an HTMLDivElement is fine.

(Also note that the constructor text nodes should be Text rather than 
TextNode, according to the interface name in DOM Core.)

Received on Wednesday, 26 October 2011 20:33:38 UTC