# element-mutator-lib

> It is a wrapper around MutationObserver and it provide more convenient way to track DOM node mutations.

Latest version **1.0.11** (published 2019-10-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install element-mutator-lib
pnpm add element-mutator-lib
yarn add element-mutator-lib
bun add element-mutator-lib
```

## 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.11 |
| Published | 2019-10-29 |
| First published | 2019-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | serj.kzv |
| Maintainers | serj.kzv |

## Links

- npm: https://www.npmjs.com/package/element-mutator-lib
- Repository: https://github.com/serj-kzv/element-mutator-lib
- Homepage: https://github.com/serj-kzv/element-mutator-lib#readme
- Issues: https://github.com/serj-kzv/element-mutator-lib/issues
- npm.io page: https://npm.io/package/element-mutator-lib

## Recent versions

- 1.0.11 (latest) — 2019-10-29
- 1.0.10 — 2019-10-29
- 1.0.9 — 2019-10-29
- 1.0.8 — 2019-10-29
- 1.0.7 — 2019-10-29
- 1.0.6 — 2019-10-29
- 1.0.4 — 2019-10-29
- 1.0.3 — 2019-10-29
- 1.0.2 — 2019-10-29
- 1.0.1 — 2019-10-29
- 1.0.0 — 2019-10-29

## README

# Not for a production!
It is for my "home" project and it has not unit tests and it is my playground.
I strongly recommend to don't use it in production.

# Installation
```bash
npm install element-mutator-lib
```

# How to use
**Example 1.** Run after page is loaded and track all DOM changes.
```js
import ElementMutator from 'element-mutator-lib';

const elementMutator = new ElementMutator({attributeFilter: []}, (cfg, node, attributeName) => {
    // do something
    elementMutator.stop(); // stop
});
```
**Example 2.** Track a specific DOM node and all his descendants (`<body>` body tag in that case).
```js
import ElementMutator from 'element-mutator-lib';

const elementMutator = new ElementMutator({attributeFilter: [], node: document.body}, (cfg, node, attributeName) => {
    // do something
    elementMutator.stop(); // stop
});
```
**Example 3.** Track a specific DOM node attributes (`href` attribute in that case).
If `attributeName` is `undefined` then mutation is a non attribute mutation.
```js
import ElementMutator from 'element-mutator-lib';

const elementMutator = new ElementMutator({attributeFilter: [href]}, (cfg, node, attributeName) => {
    // do something
    elementMutator.stop(); // stop
});
```

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