Packages

jsdom

31.0.1 · 13 Nov 2026MIT166.8M / weekRepositoryHomepagenpmAtom feed

Your version

5.4.0

10 May 2015Where it was published

5.6.1 is the newest release of 5.x.

In short

3 new2 fixed3 changed

Release note

This is a pretty exciting release! It includes a couple features I never really anticipated jsdom being awesome enough to have, but our wonderful contributors powered through and made them happen anyway:

  • Added support for the default HTML stylesheet when using window.getComputedStyle!

    • Notably, this makes jQuery's show() and hide() methods now work correctly; see #994.

  • Added support for named properties on window: any elements with an id attribute, or certain elements with a name attribute, will cause properties to show up on the window, and thus as global variables within the jsdom.

    • Although this is fairly unfortunate browser behavior, it's standardized and supported everywhere, so the fact that jsdom now supports this too means we can run a lot of scripts that would previously fail.

    • Previously, we only supported this for <iframe>s, and our implementation was quite buggy: e.g., <iframe name="addEventListener"> would override window.addEventListener.

    • Now that we have the infrastructure in place, we anticipate expanding our support so that this works on e.g. HTMLFormElements as well in the future.

We also have a bunch more fixes and additions:

  • Implemented the NonDocumentTypeChildNode mixin. Practically, this means adding nextElementSibling and previousElementSibling to Element and the various types of CharacterData.

  • Updated StyleSheetList to inherit from Array, as per the latest CSSOM spec.

  • Overhauled the handling of attributes throughout the DOM, to follow the spec more exactly.

    • Our NamedNodeMap implementation is up to date, as are the various Element methods; other places in the code that deal with attributes now all go through a spec-compliant set of helpers.

    • Some weirdnesses around the style attribute were fixed along the way; see e.g. #1109.

    • However, Attr objects themselves are not yet spec-compliant (e.g., they still inherit from Node). That's coming soon.

  • Fixed an unfortunate bug where getElementById would fail to work correctly on <img> elements whose id attributes were modified.

  • Fixed the virtualConsole option to work with jsdom.env, not just jsdom.jsdom.

  • Removed a few functions that were erroneously added to window: mapper, mapDOMNodes, and visitTree.

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.