2016-05-05 10 views
1

ich weiß, wollen verwendet, wenn ich einen unbekannten Htmlelement wie ein Apfel-Tag erstellen:Which Prototyp wird zum Erstellen eines Knotens mit einem unbekannten Tag

var apple = document.create("apple") 

würde ich es gemacht hat, aus dem Prototyp interessiert. .. , weil ich versucht:

apple.isPrototypeOf(HTMLElement.prototype) 
console: false 

Meine Frage ist, was Prototyp für unbekannte Tags verwendet wird.

Vielen Dank!

+0

'Object' Prototyp? – MarcoS

+0

nur der Objektprototyp ?? – reuta

+3

Sie haben es falsch verstanden, Sie sollten 'HTMLElement.prototype.isPrototypeOf (apple)' testen. Oder 'apple instanceof HTMLElement' (testet die gesamte Prototyp-Kette). Oder einfach 'console.log (Object.getPrototypeOf (apple))' – Bergi

Antwort

2

Die Antwort auf Ihre Frage ist HTMLUnknownElement. Es ist eine Unterklasse von HTMLElement.

var myApple = document.createElement('apple'); 
 
document.write(myApple.constructor.name); // "HTMLUnknownElement"

+0

genau 'HTMLUnknownElement.prototype' – Supersharp