observablehq / htl

A tagged template literal that allows safe interpolation of values into HTML, following the HTML5 spec
https://observablehq.com/@observablehq/htl
ISC License
305 stars 24 forks source link

Feature request: Ability to use JSDOM or other dom library #42

Open lajoiemedia opened 2 years ago

lajoiemedia commented 2 years ago

It would be useful for nodejs and testing to have an option to use jsdom (or something else) as the provider of the dom.

It could be an option to html, e.g.

html({window: new JSDOM("").window})`<div>This is a test</div>`

Or else the htl library could export a setWindow function.

It would be a lot cleaner than what's being done here: https://github.com/observablehq/htl/blob/main/test/jsdom.js