Skip to content

Commit 0c92f20

Browse files
committed
Document how to serialize a document.
1 parent 7b82aaa commit 0c92f20

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,18 @@ window.document.body.appendChild(scriptEl);
294294
// though it originated in Node!
295295
```
296296

297+
### Serializing a document
298+
299+
```js
300+
var jsdom = require("jsdom").jsdom;
301+
var serializeDocument = require("jsdom").serializeDocument;
302+
303+
var doc = jsdom("<!DOCTYPE html>hello");
304+
305+
serializeDocument(doc) === "<!DOCTYPE html><html><head></head><body>hello</body></html>";
306+
doc.documentElement.outerHTML === "<html><head></head><body>hello</body></html>";
307+
```
308+
297309
## What Standards Does jsdom Support, Exactly?
298310

299311
Our mission is to get something very close to a headless browser, with emphasis more on the DOM/HTML side of things than the CSS side. As such, our primary goals are supporting [The DOM Standard](http://dom.spec.whatwg.org/) and [The HTML Standard](http://www.whatwg.org/specs/web-apps/current-work/multipage/). We only support some subset of these so far; in particular we have the subset covered by the outdated DOM 2 spec family down pretty well. We're slowly including more and more from the modern DOM and HTML specs, including some `Node` APIs, `querySelector(All)`, attribute semantics, the history and URL APIs, and the HTML parsing algorithm.

0 commit comments

Comments
 (0)