# @tiddo/set-html-content

> Small wrapper around morphdom to replace the content of a node

Latest version **1.0.1** (published 2016-09-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tiddo/set-html-content
pnpm add @tiddo/set-html-content
yarn add @tiddo/set-html-content
bun add @tiddo/set-html-content
```

## 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.1 |
| Published | 2016-09-27 |
| First published | 2016-09-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Tiddo Langerak |
| Maintainers | tiddo |

## Links

- npm: https://www.npmjs.com/package/@tiddo/set-html-content
- Repository: https://github.com/TiddoLangerak/set-html-content
- Homepage: https://github.com/TiddoLangerak/set-html-content#readme
- Issues: https://github.com/TiddoLangerak/set-html-content/issues
- npm.io page: https://npm.io/package/@tiddo/set-html-content

## Dependencies (1)

- [morphdom](https://npm.io/package/morphdom.md) ^2.1.0

## Recent versions

- 1.0.1 (latest) — 2016-09-27
- 1.0.0 — 2016-09-27

## README

Small wrapper around morphdom to replace the *content* of a node

[Morphdom](https://github.com/patrick-steele-idem/morphdom) allows to efficiently update the state of a DOM element to the state of another DOM element. A common use case for this is to set the *content* of an element. Setting the content of an element with morphdom requires some extra wrapping though. This module contains all that wrapping.


## Usage

The `setHtmlContent` function has the same signature as the `morphdom` function, the only difference being that `setHtmlContent` expects only the content as second argument, without an encapsulating element.

### Examples:

String based:
```javascript
import setHtmlContent from '@tiddo/set-html-content';

const element = document.querySelector('<my-element>');

setHtmlContent(element, '<p>New content</p>');
//element.outerHTML === '<my-element><p>New content</p></my-element>'
```

DOM based:
```javascript
import setHtmlContent from '@tiddo/set-html-content';

const element = document.querySelector('<my-element>');

const content = document.createElement('p');
content.textContent = 'New content';

setHtmlContent(element, content);
//element.outerHTML === '<my-element><p>New content</p></my-element>'
```

---
_Source: https://npm.io/package/@tiddo/set-html-content · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
