v31.0.0
Added 4
- Added WebP serialization through canvas.toDataURL() and canvas.toBlob() behavior changed · vendor-flagged, marked in the notes below
- Added support for cascade layers, nesting, @scope, custom-property substitution and registration through @property and CSS.registerProperty(), typed attr(), conditional if(), shadow-tree styling with :host, ::slotted(), and ::part(), pseudo-element computed styles, and constructable stylesheets with document.adoptedStyleSheets and shadowRoot.adoptedStyleSheets
- Added window.reportError(), which dispatches an error event and reports uncanceled errors to the virtual console
- Added element.ariaBrailleLabel and element.ariaBrailleRoleDescription
Changed 5
- Changed the optional canvas and image decoding backend from canvas to @napi-rs/canvas, which must be installed as v1.0.13 or later in the v1.x series alongside jsdom requirement raised · vendor-flagged, marked in the notes belowbehavior changed · vendor-flagged, marked in the notes below
- Changed the new canvas backend to provide prebuilt Skia binaries on supported platforms, with rendering and encoded image bytes that can differ from before
- Changed CSS parsing, selector matching, and computed styles to use a new integrated implementation with substantially expanded support and faster selector queries and repeated style reads
- Changed HTML and XML parsing to pause at blocking scripts until their required resources are ready, so the JSDOM constructor, JSDOM.fromURL(), and JSDOM.fromFile() can return partially parsed documents
- Changed XML syntax errors encountered after asynchronous parsing resumes to be reported through the virtual console as "xml-parsing" errors
Fixed 17
- Fixed image loading to wait for decoding before firing load, discard obsolete source requests, avoid refetching when dimensions change, and prevent failed images from drawing stale contents behavior changed · inferred, marked in the notes below
- Fixed canvas context and serialization behavior, including unsupported context types, read-only ctx.canvas, image-drawing exceptions, MIME type and quality normalization, and asynchronous null results from canvas.toBlob() for empty canvases or encoding failures
- Fixed numerous cascade, shorthand, serialization, and default-style issues, and made computed declarations stay live across DOM and stylesheet changes
- Fixed page-completion load events to fire only on the window instead of the document
- Fixed document.open(), including implicit calls from document.write(), to clear event listeners and handlers from the document, its descendants, and its window when replacing the input stream
- Fixed document.write() to process successive writes through the parser's input stream, preserve insertion points across nested scripts, and make completed text immediately visible
- Fixed dynamically inserted scripts to respect script.async = false execution order, use their source text and document from preparation time, and avoid executing after adoption into another document
- Fixed scripts parsed through inert fragment APIs so they no longer execute when subsequently inserted
- Fixed unrelated images, stylesheets, and frames being delayed behind scripts, and resource completion events firing before nested stylesheet imports finish
- Fixed cyclic stylesheet imports so they no longer prevent completion, and made style elements in shadow trees fire load events
- Fixed window.stop() to cancel pending subresource and XMLHttpRequest requests in descendant frames and suppress completion events for canceled loads, while allowing subsequent requests to proceed
- Fixed repeated document.close() calls replaying readiness and load events, and incorrect iframe load events when reopening documents from event handlers
- Fixed memory leaks where pending request interceptor promises retained closed windows, introduced in v28.0.0
- Fixed focus remaining on elements that become non-focusable after DOM or style changes, so focus now moves asynchronously to the document's viewport and element.blur() can release it immediately
- Fixed document.hasFocus() returning false before an element is focused or during focus transitions within the document, including inside frames
- Fixed template parsing and template.innerHTML serialization in XML documents, including templates with namespace prefixes
- Fixed rect.toJSON() and performance.toJSON() to create their result objects in the method's realm instead of the host Node.js realm
3 changes to check, marked in the notes below
From jsdom
Breaking changes
- Changed the optional canvas and image decoding backend from
canvasto@napi-rs/canvas. Install@napi-rs/canvasv1.0.13 or later in the v1.x series alongside jsdom; installingcanvasalone no longer enables this support. The new backend provides prebuilt Skia binaries on supported platforms, and rendering and encoded image bytes can differ. Projects using native canvas objects or custom font registration should follow the canvas migration guidance. Added WebP serialization throughcanvas.toDataURL()andcanvas.toBlob(). Fixed image loading to wait for decoding before firingload, discard obsolete source requests, avoid refetching when dimensions change, and prevent failed images from drawing stale contents. Fixed canvas context and serialization behavior, including unsupported context types, read-onlyctx.canvas, image-drawing exceptions, MIME type and quality normalization, and asynchronousnullresults fromcanvas.toBlob()for empty canvases or encoding failures. (@Brooooooklyn) requirement raised · vendor-flagged behavior changed · vendor-flagged - Changed CSS parsing, selector matching, and computed styles to use a new integrated implementation, with substantially expanded support and faster selector queries and repeated style reads. This includes cascade layers, nesting,
@scope, custom-property substitution and registration through@propertyandCSS.registerProperty(), typedattr(), conditionalif(), shadow-tree styling with:host,::slotted(), and::part(), pseudo-element computed styles, and constructable stylesheets withdocument.adoptedStyleSheetsandshadowRoot.adoptedStyleSheets. Fixed numerous cascade, shorthand, serialization, and default-style issues; computed declarations now stay live across DOM and stylesheet changes. CSS serialization and computed values can differ from previous releases. - Changed HTML and XML parsing to pause at blocking scripts until their required resources are ready. The
JSDOMconstructor,JSDOM.fromURL(), andJSDOM.fromFile()can now return partially parsed documents. Wait forDOMContentLoadedfor the finished tree, or the window'sloadevent for load-delaying resources, checkingdocument.readyStatefirst in case the event has already fired. XML syntax errors encountered after asynchronous parsing resumes are reported through the virtual console as"xml-parsing"errors. behavior changed · vendor-flagged
Other changes
- Added
window.reportError(), which dispatches anerrorevent and reports uncanceled errors to the virtual console. (@sarankumar1325) - Added
element.ariaBrailleLabelandelement.ariaBrailleRoleDescription. (@Kjubikstronk) - Fixed page-completion
loadevents to fire only on the window. Usewindow.addEventListener("load", ...)orwindow.onloadinstead of listening on the document. behavior changed · inferred - Fixed
document.open(), including implicit calls fromdocument.write(), to clear event listeners and handlers from the document, its descendants, and its window when replacing the input stream. - Fixed
document.write()to process successive writes through the parser's input stream, preserve insertion points across nested scripts, and make completed text immediately visible. Script-created input streams now remain open untildocument.close(). - Fixed dynamically inserted scripts to respect
script.async = falseexecution order, use their source text and document from preparation time, and avoid executing after adoption into another document. Scripts parsed through inert fragment APIs no longer execute when subsequently inserted. - Fixed unrelated images, stylesheets, and frames being delayed behind scripts, and resource completion events firing before nested stylesheet imports finish. Cyclic imports no longer prevent completion, and
<style>elements in shadow trees now fireloadevents. - Fixed
window.stop()to cancel pending subresource andXMLHttpRequestrequests in descendant frames and suppress completion events for canceled loads, while allowing subsequent requests to proceed. - Fixed repeated
document.close()calls replaying readiness and load events, and incorrect iframe load events when reopening documents from event handlers. - Fixed memory leaks where pending request interceptor promises retained closed windows, introduced in v28.0.0.
- Fixed focus remaining on elements that become non-focusable after DOM or style changes. Focus now moves asynchronously to the document's viewport, and
element.blur()can release it immediately. - Fixed
document.hasFocus()returning false before an element is focused or during focus transitions within the document, including inside frames. - Fixed
<template>parsing andtemplate.innerHTMLserialization in XML documents, including templates with namespace prefixes. (@b84330808) - Fixed
rect.toJSON()andperformance.toJSON()to create their result objects in the method's realm instead of the host Node.js realm.