document.doctype instanceof DocumentType // true
document.doctype instanceof Node // true
Object.getPrototypeOf(document.doctype) == DocumentType.prototype // true
typeof document.doctype["remove"] // "function"
document.doctype instanceof ChildNode // ReferenceError: ChildNode is not defined
As you can see, a doctype instance has the method defined by ChildNode
in the specification, but since javascript does not support multiple inheritance this is not expressible through the type system.
In other programming languages multiple inheritance or support for mixins in the type system would be used to codify the relationship.
The chain of concrete prototype objects looks as follows, at least in firefox:
document.doctype ->
DocumentType.prototype ->
Node.prototype ->
EventTarget.prototype ->
Object.prototype ->
null
The ChildNode
methods seem to be injected into DocumentType.prototype
.