This is a prerelease of jsdom's first major version. It incorporates several great additions, as well as a general cleanup of the API surface, which make it more backward-incompatible than usual. Starting with the 1.0.0 release, we will be following semantic versioning, so that you can depend on stability within major version ranges. But we still have a few more issues before we can get there, so I don't want to do 1.0.0 quite yet.
This release owes a special thanks to @Sebmaster, for his amazing work taking on some of the hardest problems in jsdom and solving them with gusto.
Major changes
- jsdom now can be browserified into a bundle that works in web workers! This is highly experimental, but also highly exciting! (@lawnsea)
- An overhaul of the initialization lifecycle, to bring more control and address common use cases. (@Sebmaster)
- The excellent parse5 HTML parser is now the default parser, fixing many parsing bugs and giving us full, official-test-suite-passing HTML parsing support. This especially impacts documents that didn't include optional tags like
<html>,<head>, or<body>in their source. We also use parse5 for serialization, fixing many bugs there. (@Sebmaster) - As part of the new parser story, we are not supporting XML for now. It might work if you switch to a different parser (e.g. htmlparser2), but in the end, HTML and XML are very different, and we are not attempting to be an XML DOM. That said, we eventually want to support XML to the same extent browsers do (i.e., support XHTML and SVG, with an appropriate MIME type switch); this is being planned in #820.
Removed jsdom APIs
jsdom.createWindow: usedocument.parentWindowafter creating a documentjsdom.html: usejsdom.jsdomjsdom.version: userequire("jsdom/package.json").versionjsdom.level: levels are deprecated and will probably be removed in 2.0.0jsdom.domjsdom.browserAugmentationjsdom.windowAugmentation
Changed jsdom APIs
jsdom.jsdomno longer takes a level as its second argument.jsdom.jQueryifynow requires a jQuery URL, since always picking the latest was a bad idea.
Removed non-standard DOM APIs
document.createWindow: usedocument.parentWindowdocument.innerHTMLanddocument.outerHTML: use the newjsdom.serializeDocumentto include the DOCTYPE, or usedocument.documentElement.outerHTMLto omit it.
Other fixes
- Allow empty strings to be passed to
jsdom.env. (@michaelmior) - Fix for a memory leak in
EventTarget.prototype.dispatchEvent. (@Joris-van-der-Wel) - Make event listeners in the capture phase also fire on the event target. (@Joris-van-der-Wel)
- Correctly reset
eventPhaseandcurrentTargeton events, before and after a dispatch. (@Joris-van-der-Wel) - Fix
document.cookie = nullto not throw, but instead just do nothing. (@kapouer)