# nano-dom

> A minimal DOM-like implementation

Latest version **0.3.3** (published 2019-02-11) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2019-02-11 |
| First published | 2017-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 45.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Robert Kunze |
| Maintainers | andcake |
| Keywords | DOM |

## Links

- npm: https://www.npmjs.com/package/nano-dom
- Repository: https://github.com/AndCake/nano-dom
- npm.io page: https://npm.io/package/nano-dom

## 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

- 0.3.3 (latest) — 2019-02-11
- 0.3.2 — 2019-02-11
- 0.3.1 — 2019-02-08
- 0.3.0 — 2019-02-08
- 0.2.4 — 2018-10-23
- 0.2.3 — 2018-10-23
- 0.2.2 — 2018-10-22
- 0.2.1 — 2018-10-18
- 0.2.0 — 2018-10-18
- 0.1.12 — 2017-09-10
- 0.1.11 — 2017-09-10
- 0.1.10 — 2017-09-10
- 0.1.9 — 2017-09-10
- 0.1.8 — 2017-09-10
- 0.1.7 — 2017-09-09
- … 15 more at https://npm.io/package/nano-dom/versions

## README

# nano-dom

A light DOM implementation that can be used to test DOM modification on the server-side. This package contains a simple HTML parser to convert the HTML source code to a DOM structure. It provides only the most basic DOM API to be still useful.

Installation
------------

```
$ npm i nano-dom -D
```

Usage
-----

```js
import Document from 'nano-dom';

const document = new Document('<div class="greeting">Hello world!</div>');

console.log(document.querySelector('.greeting').innerHTML); // Hello world!
```

Support for custom tags
-----------------------

You can configure which custom tags are allowed to be self-closing ones. If not configured, you may have to close them explicitly.

```js
import { options }, Document from 'nano-dom';

options.customSelfClosingTags = ['chicken', 'run'];

const document = new Document(`
    <div class="yard">
        <chicken name="Prillan"/>
        <my-non-self-closing>text content</my-non-self-closing>
        <run speed="fast"/>
    </div>
`);

```

Supported DOM API
-----------------

* DOMText
* DOMElement
  - childNodes
  - children
  - nodeName
  - nodeType
  - tagName
  - className
  - classList
  - firstElementChild
  - innerHTML
  - outerHTML
  - appendChild()
  - replaceChild()
  - removeChild()
  - remove()
  - setAttribute()
  - removeAttribute()
  - getAttribute()
  - addEventListener()
  - removeEventListener()
  - dispatchEvent()
  - getElementByTagName()
  - getElementByClassName()
  - getElementById()
  - querySelectorAll()
  - querySelector()
  - click()
  - focus()
  - blur()
* Document
  - documentElement
  - childNodes
  - children
  - nodeType
  - body
  - head
  - createElement()
  - createTextNode()
  - getElementById()
  - getElementsByTagName()
  - getElementsByClassName()
  - querySelectorAll()
  - querySelector()
  - addEventListener()
  - removeEventListener()

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