RE: Defining a constructor for Element and friends

From: Boris Zbarsky [mailto:bzbarsky@mit.edu] 

> But it also means that user-space code that has to create an HTML element generically now has to go through document.createElement instead of being able to do |new HTMLElement("a")|, right?

That seems totally fine to me though. The idea of a string-based factory for when you don't know what constructor you want to use has precedent all over software design.

> Those aren't the same thing at all, right?  The prototype chain has absolutely nothing to do with internal slots, unless we're assuming some sort of vanilla untouched tate of the world.

Agreed. However, in a "normal" situation---where all constructors in the chain call super() appropriately, and nobody __proto__-munges, and so on---they should be the same. That's why I'm saying that implicitly it was probably also part of what I was thinking when writing that.

> Really, this idea of "primary interface" and your idea of "own-instance" seem fairly similar, right?  Except that "primary interface" can only refer to Web IDL interfaces, not user-defined subclasses... or something.

Yeah, that sounds about right. Honestly, own-interface was just my attempt at capturing a JavaScript concept that I work with pretty often ("this over here is a Foo; this over here is a Bar").

Received on Tuesday, 13 January 2015 17:26:26 UTC