Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuerySelector Not working with Node v12.16.1 #2870

Closed
dvreed77 opened this issue Feb 27, 2020 · 1 comment
Closed

QuerySelector Not working with Node v12.16.1 #2870

dvreed77 opened this issue Feb 27, 2020 · 1 comment

Comments

@dvreed77
Copy link

Basic info:

  • Node.js version: v12.16.1
  • jsdom version: 16.2.0

Minimal reproduction case

const jsdom = require("jsdom");
const { JSDOM } = jsdom;

const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
console.log(dom.window.document.querySelectorAll("p"));

When running this with Node version 12.16.1, the output of this is NodeList {}. When running with Node version <= 11, the output is NodeList { '0': HTMLParagraphElement {} }

@TimothyGu
Copy link
Member

This is an artifact of recent changes to Node.js' util.format function, that is used in console.log. If you explicitly print out the length of the NodeList (or if you convert the NodeList to an array through Array.from or [...obj]), you see that the object is in fact not empty. See https://runkit.com/timothygu/5e588813857db1001441093f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants