Skip to content

Instantly share code, notes, and snippets.

@patrickkettner
Created May 12, 2011 10:03
Show Gist options
  • Save patrickkettner/968279 to your computer and use it in GitHub Desktop.
Save patrickkettner/968279 to your computer and use it in GitHub Desktop.
engadget crashing jsdom
var jsdom = require('jsdom');
jsdom.env('http://engadget.com', [
'http://code.jquery.com/jquery-1.5.min.js'], function(errors, window) {
var $ = window.$;
if (errors) {
console.log(errors);
}
else {
console.log('foo');
};
});
_______________________________________
throw new core.DOMException(HIERARCHY_REQUEST_ERR);
^
Error: Heirarchy request error
at Object.appendChild (/Users/pdk/projects/looseleafword/node_modules/jsdom/lib/jsdom/level1/core.js:1411:13)
at Object.setChild (/Users/pdk/projects/looseleafword/node_modules/jsdom/lib/jsdom/browser/htmltodom.js:153:17)
at HtmlToDom.appendHtmlToElement (/Users/pdk/projects/looseleafword/node_modules/jsdom/lib/jsdom/browser/htmltodom.js:76:18)
at Object.innerHTML (/Users/pdk/projects/looseleafword/node_modules/jsdom/lib/jsdom/browser/index.js:334:27)
at Object.write (/Users/pdk/projects/looseleafword/node_modules/jsdom/lib/jsdom/level2/html.js:348:22)
at Object.jsdom (/Users/pdk/projects/looseleafword/node_modules/jsdom/lib/jsdom.js:43:9)
at Object.html (/Users/pdk/projects/looseleafword/node_modules/jsdom/lib/jsdom.js:76:18)
at /Users/pdk/projects/looseleafword/node_modules/jsdom/lib/jsdom.js:179:26
at [object Object].callback (/Users/pdk/projects/looseleafword/node_modules/jsdom/lib/jsdom.js:242:9)
at IncomingMessage.<anonymoumacbook:looseleafword pdk$
@jimfleming
Copy link

Ran into this same issue recently. Depending on your needs you can manually load the html using http.get and use a regex (body = body.replace(/(<\/html>)[\s\S]*/g, '$1')) to strip out everything after the closing html tag before passing the html into jsdom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment