Hacker News new | ask | show | jobs
by nwhit 406 days ago
Jsdom should work in deno, can you open a github issue (https://github.com/denoland/deno/issues) with some details and a reproduction?

All of the simple cases I've tried seem to work fine, e.g:

  import { JSDOM } from "npm:jsdom";
  
  const dom = new JSDOM(
    `<!DOCTYPE html><p>Hello world <img src="https://example.com/logo.svg" /></p>`,
  );
  
  console.log(dom.window.document?.querySelector("p")?.textContent); // "Hello world"
  console.log(dom.window.document?.querySelector("img")?.getAttribute("src")); // "https://example.com/logo.svg"
1 comments

Earlier today, it was producing an error that looked as if it couldn't render some elements. Unfortunately, I switched to a different branch where I tried to switch certain things over to Node, and now when I've switched back, there's a different error, now in the `readability` module, but still connected to its use of jsdom. It looks like it could be due to version mismatches — maybe readability requires a different version of JSDOM to the one installed by default — but now I'm trying to downgrade the currently installed version of JSDOM, and that doesn't seem to work — the version in deno.lock is stubbornly staying at the later version, despite having specified an older version in the `deno.jsonc` (and that older version appearing in the `workspace.dependencies` array at the bottom of the lock file).

I'll try again with a clearer head tomorrow, and maybe if I figure stuff out I can create a proper reproduction, but right now I don't know how to reproduce anything because it doesn't seem like my local environment is consistently reproducible, let alone trying to create something that would work on other machines. I'm surprised at how poor this behaviour is — I thought a big part of Deno@2 was to fix these sorts of dependency issues.