Kevvv
Kevvv

Reputation: 4023

Does DOM API use constructors and prototypes in creating/manipulating nodes?

I'm trying to understand DOM API through OOP frame of mind. Since DOM API uses properties and methods that are built into the browser and document in, say, document.createElement is an instance of Document, is it safe to say that document is an instance created from the Document constructor? For example, when I'm using DOM, is this what is happening in under the hood?:

let document = new Document();

where Document() is defined as something like:

class Document {
 constructor()
 //some properties and methods
}

Also, when the following codes are executed:

let link = document.querySelector('a');
link.textContent('This is a link');

is this a case where link inherits prototype from Document and the method textContent is invoked through a setter:

class Document {
 set textContent(x){
  some_variable = x;
 }
}

Is there a way to see the source code of Document other than console.log(Document)?

Upvotes: 1

Views: 47

Answers (1)

MarmiK
MarmiK

Reputation: 5785

The Document Object Model (DOM) is a programming API for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.

Its not part of JS its a W3C standard implemented, The Document Object Model can be used with any programming language.

The actions performed using language bindings, it provides language bindings for Java and ECMAScript.

User can refer specification standard document at Source W3C

Upvotes: 1

Related Questions