# dom-tree

> DOM Manipulation Library

Latest version **1.0.0** (published 2016-04-09) · BSD license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-04-09 |
| First published | 2014-05-11 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Azer Koçulu |
| Maintainers | tehshrike |
| Keywords | dom, browser |

## Links

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

## Dependencies (2)

- [dom-select](https://npm.io/package/dom-select.md) 0.0.x
- [new-element](https://npm.io/package/new-element.md) 0.0.x

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

- 1.0.0 (latest) — 2016-04-09
- 0.0.1-security — 2016-03-23
- 2.0.0 — 2016-03-22
- 0.0.1 — 2014-05-11
- 0.0.0 — 2014-05-11

## README

## dom-tree

Library to manipulate DOM elements

Example:

```js
var dom = require('dom-tree')

dom.add(document.body, '<h1>{title}</h1>{content}', {
  title: 'Hello',
  content: 'Welcome!'
})
```

## Install

```bash
$ npm install dom-tree
```

## API

### add(element, child)

Adds `child` to `el`

```js
add(document.body, document.createElement('textarea'))
add('body .content', document.createElement('textarea'))
add('.content', '<div>hello</div>')
add('.content', '<h1>{title}</h1>', { title: 'Hello!' })
```

### addAfter(parent, child, reference)

Similar to `addBefore`

### addBefore(parent, child, reference)

```js
addBefore(document.body, document.createElement('textarea'), document.body.firstChild)
addBefore('body', '<h1>{msg}</h1>', { msg: 'foobar' }, document.body.firstChild)
```

### insert(element, parent)

insert `element` to `parent` as child

```js
insert(document.createElement('textarea'), document.body)
insert('<input />', '.content')
insert('<h1>{title}</h1>', { title: 'hello' }, '.content')
```

### replace(parent, target, replacement)

replace `target` with `replacement`

```js
replace(document.body, document.body.firstChild, document.createElement('textarea'))
replace('body .content', '.content ul', '<h1>hello</h1>')
replace('body .content', '.content ul', '<h1>{msg}</h1>', { msg: 'hello!' })
```

### remove(element)

remove `element`

```js
remove(document.body.firstChild)
remove('body .content')
```

### remove(parent, child)

remove `child`

```js
remove(document.body.firstChild, 'h1')
```

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