-
-
Notifications
You must be signed in to change notification settings - Fork 210
Happy DOM Without Node
David Ortner edited this page Apr 19, 2024
·
2 revisions
There is a separate project called happy-dom-without-node that makes it possible to use Happy DOM without Node.js (e.g. in a real browser such as Chrome).
The long term goal is for Happy DOM to support this built into the happy-dom
package.
npm install happy-dom-without-node
import { Window } from 'happy-dom-without-node';
const window = new Window({ url: 'https://localhost:8080' });
const document = window.document;
document.body.innerHTML = '<div class="container"></div>';
const container = document.querySelector('.container');
const button = document.createElement('button');
container.appendChild(button);
// Outputs "<div class="container"><button></button></div>"
console.log(document.body.innerHTML);