Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to incorporate or implement a DOM API to v8?

I am writing a server application that is able to manipulate the DOM before it is served to the client.

I am using C++ and Google's v8 as a javascript engine but I don't see any DOM API in v8.

Is there an open source implementation for doing DOM manipulation on HTML?
If not how would you implement one?

like image 377
the_drow Avatar asked Jul 26 '09 09:07

the_drow


1 Answers

The DOM is created and linked to the V8 engine in Chrome. The V8 sources know nothing about the browser DOM. The quickest way to get this working for you would be to try to extract the parts of Chrome (Chromium, really) that load HTML into a structure, and the parts that link the DOM and DOM methods into V8. It's probably not as bad as you think. If anything, Google produces pretty clean C++, as far as I can tell from looking at the V8 source code. It's probably not as bad as you think.

like image 198
postfuturist Avatar answered Sep 22 '22 03:09

postfuturist