Jsdom.jsdom missing createWindow method

I am trying to use jsdom to parse some html content. The examples I saw 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 no and found.

Why don't I have a .createWindow () method?

+4
source share
1 answer

The jsdom API has changed a bit since release 1.0. Method createWindow()is an old API. You should be able to get the document window just by turning to tstDocument.defaultView, just as if you were in a browser.

+11

All Articles