Is it possible to get the changed/live DOM of a website with jsdom?
For example:
Client
In my test.html
file I have a button, which appends new <div class="p">
elements:
$('#button').click(function(){
$('body').append('<div class="p">new</div>');
});
Then I have another button that calls a function on the server (with NowJS or Socket.IO).
Server
In my server.js
file, now, I want to count all the appended div
elements with the class="p"
:
everyone.now.countDiv = function() {
var jquery = fs.readFileSync("./jquery16.js").toString();
jsdom.env(
{
html: 'http://localhost:8080/test.html',
src: [
jquery
],
done: function(errors, window) {
var $ = window.$;
var len = window.$('.p').length;
console.log("Divs: ", len);
}
});
}
I know that I could count the elements on the client side and pass it to the server. But I am interested if jsdom can access the "new/current" DOM.
I assume jsdom reads the DOM of the text.html
, but can't access the live DOM of a website!?