- Fixed
getComputedStyle()withcalc()and other functions throwing an exception, which regressed in v30.0.0. (@asamuzaK) - Sped up up range operations on large documents (@leonidaz)
jsdom
Developer ToolsPure-JavaScript implementation of web standards, for running the DOM in Node.
Changelog
Breaking changes:
- Node.js minimum version raised to
^22.22.2 || ^24.15.0 || >=26.0.0.
Other changes:
- Added
CSS.escape()andCSS.supports()functions. (@asamuzaK) - Added
'background-position-x'and'background-position-y'CSS properties. (@olagokemills) - Fixed
getComputedStyle()to convert length values into pixels. (@asamuzaK) - Fixed CSS function serialization, e.g., in the return value of
getPropertyValue(). (@asamuzaK) - Fixed the type of error thrown by
document.evaluate()(@dokson)
- Fixed
'border-radius'computed style serialization. (@asamuzaK) - Fixed computed style computation when using
'background-origin'and'background-clip'CSS properties. (@asamuzaK) - Significantly optimized initial calls to
getComputedStyle(), before the cache warms up. (@asamuzaK)
- Added basic support for the ratio CSS type. (@asamuzaK)
- Fixed
getComputedStyle()sometimes returning outdated results after CSS was modified. (@asamuzaK)
- Significantly improved and sped up
getComputedStyle(). Computed value rules are now applied across a broader set of properties, and include fixes related to inheritance, defaulting keywords, custom properties, and color-related values such ascurrentcolorand system colors. (@asamuzaK) - Fixed CSS
'background' and'border'shorthand parsing. (@asamuzaK)
- Fixed CSS parsing of
'border','background', and their sub-shorthands containing keywords orvar(). (@asamuzaK) - Fixed
getComputedStyle()to return a more functionalCSSStyleDeclarationobject, including indexed access support, which regressed in v29.0.0.
- Added
TextEncoderandTextDecoder. - Improved decoding of HTML bytes by using the new
@exodus/bytespackage; it is now much more correct. (@ChALkeR) - Improved decoding of XML bytes to use UTF-8 more often, instead of sniffing for
<meta charset>or using the parent frame's encoding. - Fixed a memory leak when
Ranges were used and then the elements referred to by those ranges were removed.
Breaking changes:
- Node.js v22.13.0+ is now the minimum supported v22 version (was v22.12.0+).
Other changes:
- Overhauled the CSSOM implementation, replacing the
@acemir/cssomandcssstyledependencies with fresh internal implementations built on webidl2js wrappers and thecss-treeparser. Serialization, parsing, and API behavior is improved in various ways, especially around edge cases. - Added
CSSCounterStyleRuleandCSSNamespaceRuleto jsdomWindows. - Added
cssMediaRule.matchesandcssSupportsRule.matchesgetters. - Added proper media query parsing in
MediaList, usingcss-treeinstead of naive comma-splitting. Invalid queries become"not all"per spec. - Added
cssKeyframeRule.keyTextgetter/setter validation. - Added
cssStyleRule.selectorTextsetter validation: invalid selectors are now rejected. - Added
styleSheet.ownerNode,styleSheet.href, andstyleSheet.title. - Added bad port blocking per the fetch specification, preventing fetches to commonly-abused ports.
- Improved
Documentinitialization performance by lazily initializing the CSS selector engine, avoiding ~0.5 ms of overhead perDocument. (@thypon) - Fixed a memory leak when stylesheets were removed from the document.
- Fixed
CSSStyleDeclarationmodifications to properly trigger custom element reactions. - Fixed nested
@mediarule parsing. - Fixed
CSSStyleSheet's "disallow modification" flag not being checked in all mutation methods. - Fixed
XMLHttpRequest'sresponsegetter returning parsed JSON during theLOADINGstate instead ofnull. - Fixed
getComputedStyle()crashing in XHTML documents when stylesheets contained at-rules such as@pageor@font-face. - Fixed a potential hang in synchronous
XMLHttpRequestcaused by a race condition with the worker thread's idle timeout.
- Added
blob.text(),blob.arrayBuffer(), andblob.bytes()methods. - Improved
getComputedStyle()to account for CSS specificity when multiple rules apply. (@asamuzaK) - Improved synchronous
XMLHttpRequestperformance by using a persistent worker thread, avoiding ~400ms of setup overhead on every synchronous request after the first one. - Improved performance of
node.getRootNode(),node.isConnected, andevent.dispatchEvent()by caching the root node of document-connected trees. - Fixed
getComputedStyle()to correctly handle!importantpriority. (@asamuzaK) - Fixed
document.getElementById()to return the first element in tree order when multiple elements share the same ID. - Fixed
<svg>elements to no longer incorrectly proxy event handlers to theWindow. - Fixed
FileReaderevent timing andfileReader.resultstate to more closely follow the spec. - Fixed a potential hang when synchronous
XMLHttpRequestencountered dispatch errors. - Fixed compatibility with environments where Node.js's built-in
fetch()has been used before importing jsdom, by working around undici v6/v7 incompatibilities.
- Overhauled resource loading customization. See the new README for details on the new API.
- Added MIME type sniffing to
<iframe>and<frame>loads. - Regression:
WebSockets are no longer correctly throttled to one connection per origin. This is a result of the bug at nodejs/undici#4743. - Fixed decoding of the query components of
<a>and<area>elements in non-UTF-8 documents. - Fixed
XMLHttpRequestfetches andWebSocketupgrade requests to be interceptable by the new customizable resource loading. (Except synchronousXMLHttpRequests.) - Fixed the referrer of a document to be set correctly when redirects are involved; it is now the initiating page, not the last hop in the redirect chain.
- Fixed correctness bugs when passing
ArrayBuffers or typed arrays to various APIs, where they would not correctly snapshot the data. - Fixed
require("url").parse()deprecation warning when usingWebSockets. - Fixed
<iframe>,<frame>, and<img>(whencanvasis installed) to fireloadevents, noterrorevents, on non-OK HTTP responses. - Fixed many small issues in
XMLHttpRequest.