I am trying to use jsdom to analyze some html content. Examples that i have seen use the .createWindow() method of a jsdom.jsdom document based on html content.
But when I try to follow these examples, my document does not have a .createWindow() method.
var getaPage=function (req, res, callback) {
jsdom.defaultDocumentFeatures={
FetchExternalResources : ['script'],
ProcessExternalResources : ['script'],
MutationEvents : '2.0',
QuerySelector : false
};
var htmlDoc = '<html lang="en-US">' +
'</html>';
var tstDocument=jsdom.jsdom(htmlDoc);
for (var attr in tstDocument){
if (attr == 'createWindow') {
console.log('Found it');
}else{
console.log('not it');
};
};
};
When I run this, I get a bunch of 'not it' and no 'Found it'.
Why do I not have a .createWindow() method?
jsdom's API changed quite a bit with the 1.0 release. The createWindow()
method is from the old API. You should be able to get the document's window just by accessing tstDocument.defaultView
, just like you'd do if you were in a browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With