Skip to content

Commit

Permalink
Replace happy-dom with jsdom.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbuck committed Mar 4, 2024
1 parent 0d27ce3 commit a3027a9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Changed

- Revert back to [jsdom](https://www.npmjs.com/package/jsdom) for parsing in Node.js.

## v3.1.0 - 2024-03-04

### Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Parse a string of HTML or XML (including MathML, SVG, XHTML) into a document object.

Uses the [HTML template element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template) in browsers and [Happy DOM](https://github.com/capricorn86/happy-dom) in Node.js.
Uses the [HTML template element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template) in browsers and [jsdom](https://github.com/jsdom/jsdom) in Node.js.

## Usage

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@
},
"homepage": "https://github.com/jacobbuck/dom-parse",
"dependencies": {
"happy-dom": "*"
"jsdom": "^24.0.0"
},
"devDependencies": {
"@vitest/coverage-v8": "^1.3.1",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/browser.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @vitest-environment happy-dom
// @vitest-environment jsdom
import { expect, test } from 'vitest';
import { parse } from '../browser';

Expand Down
6 changes: 2 additions & 4 deletions src/node.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Window, XMLParser } from 'happy-dom';

const { document } = new Window();
import { JSDOM } from 'jsdom';

/**
* Parse a string of HTML or XML to a DOM tree.
* @param {string} [html] String containing HTML or XML to be parsed.
* @returns {DocumentFragment} Object containing Node structure of HTML/XML parsed.
*/
export const parse = (html) => XMLParser.parse(document, html);
export const parse = (html) => JSDOM.fragment(html);
2 changes: 1 addition & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineConfig({
],
},
rollupOptions: {
external: ['happy-dom'],
external: ['jsdom'],
},
sourcemap: true,
},
Expand Down

0 comments on commit a3027a9

Please sign in to comment.