jsdom
31.0.1 · 13 Nov 2026MIT166.8M / weekRepositoryHomepagenpmAtom feed
6.5.1 is the newest release of 6.x.
In short
1 breaking1 new3 faster3 fixed8 changed
- Breaking
The potential breaking changes are highlighted in bold below; the largest ones are around the
jsdom.enverror-handling paradigm.
Release note
This major release is focused on massive improvements in speed, URL parsing, and error handling. The potential breaking changes are highlighted in bold below; the largest ones are around the jsdom.env error-handling paradigm.
This release also welcomes long-time contributer @Joris-van-der-Wel to the core team. You may recognize him from earlier changelogs. We're very happy to have his help in making jsdom awesome!
io.js 2.0 onward is now required, as we have begun using ES2015 features only present there.
Improved performance dramatically, by ~10000x in some cases, due to the following changes:
Overhauled the named properties tracker to not walk the entire tree, thus greatly speeding up the setting of
idandnameattributes (including during parsing).Overhauled everything dealing with tree traversal to use a new library, symbol-tree, to turn many operations that were previously O(n^2) or O(n) into O(n) or O(1).
Sped up
node.compareDocumentPositionand anything that used it (likenode.contains) by doing more intelligent tree traversal instead of directly implementing the specced algorithm.
Overhauled how error handling works in jsdom:
window.onerror(orwindow.addEventListener("error", ...)) now work, and will catch all script errors, similar to in browsers. This also introduces theErrorEventclass, incidentally.The virtual console is now the destination for several types of errors from jsdom, using the new event
"jsdomError". This includes: errors loading external resources; script execution errors unhandled bywindow.onerror; and not-implemented warnings resulting from calling methods likewindow.alertwhich jsdom explicitly does not support.Since script errors are now handled by
window.onerrorand the virtual console, they are no longer included in the initialization process. This results in two changes tojsdom.envand the initialization lifecycle:The
load(errors, window)callback was changed toonload(window), to reflect that it is now just sugar for setting awindow.onloadhandler.The
done(errors, window)callback (i.e., the default callback forjsdom.env) has becomedone(error, window), and like every other io.js callback now simply gives you a single error object, instead of an array of them.
Nodes no longer have a nonstandard
errorsarray, or araisemethod used to put things in that array.
URL parsing and resolution was entirely overhauled to follow the URL standard!
This fixes several long-standing bugs and hacks in the jsdom URL parser, which already had a mess of gross patches on top of the built-in io.js parser to be more web-compatible.
The new
URLclass has been added towindowThe interfaces for
HTMLAnchorElement.prototypeanddocument.location(as well asURL, of course) are now uniformized to follow theURLUtilsAPI (minussearchParamsfor now).As part of this change, you may need to start passing in
file:URLs tojsdom.envwhere previously you were able to get away with passing in filenames.
Added the
XMLHttpRequest.prototype.responsegetter.Fixed
StyleSheetList.prototype.itemto actually work.Fixed the browser
vmshim to properly add the built-in global properties (Object,Array, etc.) to the sandbox. If you were running jsdom inside a web worker and most of your scripts were broken, this should fix that.Fixed the
hashchangeevent to correctly fireHashChangeEventinstances, with correct propertiesnewURLandoldURL(instead of the incorrectnewUrlandoldUrlused previously).Removed usage of the setimmediate library, as it required
evaland thus did not work in CSP scenarios.
Finally, if you're a loyal jsdom fan whose made it this far into the changelog, I'd urge you to come join us in #1139, where we are brainstorming a modernized jsdom API that could get rid of many of the warts in the current one.
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.