RE: Convenient way to create element and set its attributes at once
Domenic Denicola <[email protected]>
| Newsgroups | gmane.comp.web.dom.general |
|---|---|
| Message-ID | <93eb8fa0e38b4ce5b73a60e96b2cb6f3@BN1PR05MB325.namprd05.prod.outlook.com> |
From: Tab Atkins Jr. <[email protected]> > Hm, I don't understand. instanceof just walks the prototype chains, and the functions denoted by "HTMLHeadingElement" and "HTML.h1" can have the same prototype. I suspect I'm missing something in your statement. Well, it depends on how HTML.h1 was implemented I guess... What were you thinking? Another way to put it is that you generally want the following invariants: new X() instanceof X (new X()).constructor === X Object.getPrototypeOf(new X()) === X.prototype X.prototype.constructor === X I can't really see a solution that makes HTML.h1 a constructor that follows these identities without creating a new class hierarchy separate from HTMLHeadingElement.