# dom-lite

> A small DOM implementation for server-side

Latest version **23.2.1** (published 2023-02-06) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install dom-lite
pnpm add dom-lite
yarn add dom-lite
bun add dom-lite
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 23.2.1 |
| Published | 2023-02-06 |
| First published | 2014-03-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 22.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Lauri Rooden |
| Maintainers | lauriro |
| Keywords | document, dom, DOMParser, XMLSerializer, litejs |

## Links

- npm: https://www.npmjs.com/package/dom-lite
- Repository: https://github.com/litejs/dom-lite
- Homepage: https://github.com/litejs/dom-lite#readme
- Issues: https://github.com/litejs/dom-lite/issues
- npm.io page: https://npm.io/package/dom-lite

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 23.2.1 (latest) — 2023-02-06
- 23.2.0 — 2023-02-01
- 23.1.0 — 2023-01-22
- 22.10.0 — 2022-10-27
- 22.9.0 — 2022-09-26
- 20.2.0 — 2020-02-05
- 0.5.1 — 2016-07-26
- 0.5.0 — 2015-07-24
- 0.4.0 — 2015-02-19
- 0.3.12 — 2015-02-17
- 0.3.11 — 2015-02-10
- 0.3.10 — 2015-02-05
- 0.3.9 — 2015-02-04
- 0.3.8 — 2015-02-03
- 0.3.7 — 2015-02-03
- … 30 more at https://npm.io/package/dom-lite/versions

## README

[1]: https://badgen.net/coveralls/c/github/litejs/dom-lite
[2]: https://coveralls.io/r/litejs/dom-lite
[3]: https://badgen.net/packagephobia/install/dom-lite
[4]: https://packagephobia.now.sh/result?p=dom-lite
[5]: https://badgen.net/badge/icon/Buy%20Me%20A%20Tea/orange?icon=kofi&label
[6]: https://www.buymeacoffee.com/lauriro


DOM lite &ndash; [![Coverage][1]][2] [![Size][3]][4] [![Buy Me A Tea][5]][6]
========

A small DOM implementation
for testing, server-side rendering and working with html files.


Examples
--------

```javascript
const { document, DOMParser, XMLSerializer } = require("dom-lite");
const { XMLHttpRequest } = require("dom-lite/xmlhttprequest");

// Use XMLHttpRequest in server side
var xhr = new XMLHttpRequest()
xhr.open("GET", "https://litejs.com")
xhr.responseType = "document"
xhr.onload = function() {
	var doc = xhr.responseXML
	// Work with DOM in familiar way
	console.log(doc.querySelector("title").textContent)
}
xhr.send()

// Build DOM manually
const el = document.createElement("h1");
el.id = 123;
el.className = "large";

const fragment = document.createDocumentFragment();
const text1 = document.createTextNode("hello");
const text2 = document.createTextNode(" world");

fragment.appendChild(text1);
fragment.appendChild(text2);
el.appendChild(fragment);

el.innerHTML;
// hello world
el.innerHTML = "<b>hello world</b>";
el.toString();
// <h1 id="123" class="large"><b>hello world</b></h1>

// minify output
el.toString(true);
// <h1 id=123 class=large><b>hello world</b></h1>

el.querySelectorAll("b");
// [ "<b>hello world</b>" ]
```

## Contributing

Follow [Coding Style Guide](https://github.com/litejs/litejs/wiki/Style-Guide)

Run tests

```
npm install
npm test
```


## External links

[GitHub repo](https://github.com/litejs/dom-lite) |
[npm package](https://npmjs.org/package/dom-lite) |
[DOM spec](https://dom.spec.whatwg.org/) |
[Selectors Level 3](http://www.w3.org/TR/selectors/) |
[Coveralls coverage][2]  
[Buy Me A Tea][6]


## Licence

Copyright (c) 2014-2023 Lauri Rooden &lt;lauri@rooden.ee&gt;  
[The MIT License](http://lauri.rooden.ee/mit-license.txt)

---
_Source: https://npm.io/package/dom-lite · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
