File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,28 @@ var el = html`
4141console .log (el .toString ())
4242```
4343
44+ ### Node with custom DOM
45+ Modules like [ ` jsdom ` ] ( https://github.com/jsdom/jdsom ) implement (parts of)
46+ the DOM in pure JavaScript. If you don't really need the performance of
47+ string concatenation, or use nanohtml components that modify the raw DOM, use
48+ ` nanohtml/dom ` to give nanohtml a custom Document.
49+
50+ ``` js
51+ var JSDOM = require (' jsdom' ).JSDOM
52+ var nanohtml = require (' ./dom' )
53+ var jsdom = new JSDOM ()
54+
55+ var html = nanohtml (jsdom .window .document )
56+ var el = html `
57+ <body >
58+ <h1 >Hello planet</h1 >
59+ </body >
60+ `
61+ el .appendChild (html ` <p >A paragraph</p >` )
62+
63+ el .outerHTML === ' <body><h1>Hello planet</h1><p>A paragraph</p></body>'
64+ ```
65+
4466### Interpolating unescaped HTML
4567By default all content inside template strings is escaped. This is great for
4668strings, but not ideal if you want to insert HTML that's been returned from
You can’t perform that action at this time.
0 commit comments